@@ -862,16 +862,14 @@ impl OutboundPayments {
862862 IH : Fn ( ) -> InFlightHtlcs ,
863863 SP : Fn ( SendAlongPathArgs ) -> Result < ( ) , APIError > ,
864864 {
865- let payment_hash = invoice. payment_hash ( ) ;
866-
867865 // When manual invoice handling is enabled, the corresponding `PendingOutboundPayment` entry
868866 // is already updated at the time the invoice is received. This ensures that `InvoiceReceived`
869867 // 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) ?
873871 } else {
874- self . mark_invoice_received_and_get_details ( payment_id , payment_hash ) ?
872+ self . mark_invoice_received_and_get_details ( invoice , payment_id ) ?
875873 } ;
876874
877875 if invoice. invoice_features ( ) . requires_unknown_bits_from ( & features) {
@@ -1780,14 +1778,21 @@ impl OutboundPayments {
17801778 }
17811779 }
17821780
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 > {
17861790 match self . pending_outbound_payments . lock ( ) . unwrap ( ) . entry ( payment_id) {
17871791 hash_map:: Entry :: Occupied ( entry) => match entry. get ( ) {
17881792 PendingOutboundPayment :: AwaitingInvoice {
17891793 retry_strategy : retry, route_params_config, ..
17901794 } => {
1795+ let payment_hash = invoice. payment_hash ( ) ;
17911796 let retry = * retry;
17921797 let config = * route_params_config;
17931798 * entry. into_mut ( ) = PendingOutboundPayment :: InvoiceReceived {
@@ -1796,7 +1801,7 @@ impl OutboundPayments {
17961801 route_params_config : config,
17971802 } ;
17981803
1799- Ok ( ( retry, config) )
1804+ Ok ( ( payment_hash , retry, config) )
18001805 } ,
18011806 _ => Err ( Bolt12PaymentError :: DuplicateInvoice ) ,
18021807 } ,
@@ -1805,14 +1810,14 @@ impl OutboundPayments {
18051810 }
18061811
18071812 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 > {
18101815 match self . pending_outbound_payments . lock ( ) . unwrap ( ) . entry ( payment_id) {
18111816 hash_map:: Entry :: Occupied ( entry) => match entry. get ( ) {
18121817 PendingOutboundPayment :: InvoiceReceived {
18131818 retry_strategy, route_params_config, ..
18141819 } => {
1815- Ok ( ( * retry_strategy, * route_params_config) )
1820+ Ok ( ( invoice . payment_hash ( ) , * retry_strategy, * route_params_config) )
18161821 } ,
18171822 _ => Err ( Bolt12PaymentError :: DuplicateInvoice ) ,
18181823 } ,
0 commit comments