@@ -862,16 +862,14 @@ impl OutboundPayments {
862
862
IH : Fn ( ) -> InFlightHtlcs ,
863
863
SP : Fn ( SendAlongPathArgs ) -> Result < ( ) , APIError > ,
864
864
{
865
- let payment_hash = invoice. payment_hash ( ) ;
866
-
867
865
// When manual invoice handling is enabled, the corresponding `PendingOutboundPayment` entry
868
866
// is already updated at the time the invoice is received. This ensures that `InvoiceReceived`
869
867
// event generation remains idempotent, even if the same invoice is received again before the
870
- // current one is handled by the user.
871
- let ( retry_strategy, params_config) = if with_manual_handling {
872
- self . received_invoice_details ( payment_id) ?
868
+ // event is handled by the user.
869
+ let ( payment_hash , retry_strategy, params_config) = if with_manual_handling {
870
+ self . received_invoice_details ( invoice , payment_id) ?
873
871
} else {
874
- self . mark_invoice_received_and_get_details ( payment_id , payment_hash ) ?
872
+ self . mark_invoice_received_and_get_details ( invoice , payment_id ) ?
875
873
} ;
876
874
877
875
if invoice. invoice_features ( ) . requires_unknown_bits_from ( & features) {
@@ -1780,14 +1778,21 @@ impl OutboundPayments {
1780
1778
}
1781
1779
}
1782
1780
1783
- pub ( super ) fn mark_invoice_received_and_get_details (
1784
- & self , payment_id : PaymentId , payment_hash : PaymentHash
1785
- ) -> Result < ( Retry , RouteParametersConfig ) , Bolt12PaymentError > {
1781
+ pub ( super ) fn mark_invoice_received (
1782
+ & self , invoice : & Bolt12Invoice , payment_id : PaymentId
1783
+ ) -> Result < ( ) , Bolt12PaymentError > {
1784
+ self . mark_invoice_received_and_get_details ( invoice, payment_id) . map ( |_| ( ) )
1785
+ }
1786
+
1787
+ fn mark_invoice_received_and_get_details (
1788
+ & self , invoice : & Bolt12Invoice , payment_id : PaymentId
1789
+ ) -> Result < ( PaymentHash , Retry , RouteParametersConfig ) , Bolt12PaymentError > {
1786
1790
match self . pending_outbound_payments . lock ( ) . unwrap ( ) . entry ( payment_id) {
1787
1791
hash_map:: Entry :: Occupied ( entry) => match entry. get ( ) {
1788
1792
PendingOutboundPayment :: AwaitingInvoice {
1789
1793
retry_strategy : retry, route_params_config, ..
1790
1794
} => {
1795
+ let payment_hash = invoice. payment_hash ( ) ;
1791
1796
let retry = * retry;
1792
1797
let config = * route_params_config;
1793
1798
* entry. into_mut ( ) = PendingOutboundPayment :: InvoiceReceived {
@@ -1796,7 +1801,7 @@ impl OutboundPayments {
1796
1801
route_params_config : config,
1797
1802
} ;
1798
1803
1799
- Ok ( ( retry, config) )
1804
+ Ok ( ( payment_hash , retry, config) )
1800
1805
} ,
1801
1806
_ => Err ( Bolt12PaymentError :: DuplicateInvoice ) ,
1802
1807
} ,
@@ -1805,14 +1810,14 @@ impl OutboundPayments {
1805
1810
}
1806
1811
1807
1812
fn received_invoice_details (
1808
- & self , payment_id : PaymentId ,
1809
- ) -> Result < ( Retry , RouteParametersConfig ) , Bolt12PaymentError > {
1813
+ & self , invoice : & Bolt12Invoice , payment_id : PaymentId ,
1814
+ ) -> Result < ( PaymentHash , Retry , RouteParametersConfig ) , Bolt12PaymentError > {
1810
1815
match self . pending_outbound_payments . lock ( ) . unwrap ( ) . entry ( payment_id) {
1811
1816
hash_map:: Entry :: Occupied ( entry) => match entry. get ( ) {
1812
1817
PendingOutboundPayment :: InvoiceReceived {
1813
1818
retry_strategy, route_params_config, ..
1814
1819
} => {
1815
- Ok ( ( * retry_strategy, * route_params_config) )
1820
+ Ok ( ( invoice . payment_hash ( ) , * retry_strategy, * route_params_config) )
1816
1821
} ,
1817
1822
_ => Err ( Bolt12PaymentError :: DuplicateInvoice ) ,
1818
1823
} ,
0 commit comments