@@ -163,6 +163,7 @@ impl PendingOutboundPayment {
163163 _ => None ,
164164 }
165165 }
166+
166167 fn increment_attempts ( & mut self ) {
167168 if let PendingOutboundPayment :: Retryable { attempts, .. } = self {
168169 attempts. count += 1 ;
@@ -797,6 +798,7 @@ pub(super) struct SendAlongPathArgs<'a> {
797798 pub payment_id : PaymentId ,
798799 pub keysend_preimage : & ' a Option < PaymentPreimage > ,
799800 pub invoice_request : Option < & ' a InvoiceRequest > ,
801+ pub bolt12_invoice : Option < & ' a PaidBolt12Invoice > ,
800802 pub session_priv_bytes : [ u8 ; 32 ] ,
801803}
802804
@@ -1025,7 +1027,7 @@ impl OutboundPayments {
10251027 hash_map:: Entry :: Occupied ( entry) => match entry. get ( ) {
10261028 PendingOutboundPayment :: InvoiceReceived { .. } => {
10271029 let ( retryable_payment, onion_session_privs) = Self :: create_pending_payment (
1028- payment_hash, recipient_onion. clone ( ) , keysend_preimage, None , Some ( bolt12_invoice) , & route,
1030+ payment_hash, recipient_onion. clone ( ) , keysend_preimage, None , Some ( bolt12_invoice. clone ( ) ) , & route,
10291031 Some ( retry_strategy) , payment_params, entropy_source, best_block_height,
10301032 ) ;
10311033 * entry. into_mut ( ) = retryable_payment;
@@ -1036,7 +1038,7 @@ impl OutboundPayments {
10361038 invoice_request
10371039 } else { unreachable ! ( ) } ;
10381040 let ( retryable_payment, onion_session_privs) = Self :: create_pending_payment (
1039- payment_hash, recipient_onion. clone ( ) , keysend_preimage, Some ( invreq) , Some ( bolt12_invoice) , & route,
1041+ payment_hash, recipient_onion. clone ( ) , keysend_preimage, Some ( invreq) , Some ( bolt12_invoice. clone ( ) ) , & route,
10401042 Some ( retry_strategy) , payment_params, entropy_source, best_block_height
10411043 ) ;
10421044 outbounds. insert ( payment_id, retryable_payment) ;
@@ -1049,7 +1051,7 @@ impl OutboundPayments {
10491051 core:: mem:: drop ( outbounds) ;
10501052
10511053 let result = self . pay_route_internal (
1052- & route, payment_hash, & recipient_onion, keysend_preimage, invoice_request, payment_id,
1054+ & route, payment_hash, & recipient_onion, keysend_preimage, invoice_request, Some ( & bolt12_invoice ) , payment_id,
10531055 Some ( route_params. final_value_msat ) , & onion_session_privs, node_signer, best_block_height,
10541056 & send_payment_along_path
10551057 ) ;
@@ -1342,7 +1344,7 @@ impl OutboundPayments {
13421344 } ) ?;
13431345
13441346 let res = self . pay_route_internal ( & route, payment_hash, & recipient_onion,
1345- keysend_preimage, None , payment_id, None , & onion_session_privs, node_signer,
1347+ keysend_preimage, None , None , payment_id, None , & onion_session_privs, node_signer,
13461348 best_block_height, & send_payment_along_path) ;
13471349 log_info ! ( logger, "Sending payment with id {} and hash {} returned {:?}" ,
13481350 payment_id, payment_hash, res) ;
@@ -1420,7 +1422,7 @@ impl OutboundPayments {
14201422 }
14211423 }
14221424 }
1423- let ( total_msat, recipient_onion, keysend_preimage, onion_session_privs, invoice_request) = {
1425+ let ( total_msat, recipient_onion, keysend_preimage, onion_session_privs, invoice_request, bolt12_invoice ) = {
14241426 let mut outbounds = self . pending_outbound_payments . lock ( ) . unwrap ( ) ;
14251427 match outbounds. entry ( payment_id) {
14261428 hash_map:: Entry :: Occupied ( mut payment) => {
@@ -1462,8 +1464,9 @@ impl OutboundPayments {
14621464 }
14631465
14641466 payment. get_mut ( ) . increment_attempts ( ) ;
1467+ let bolt12_invoice = payment. get ( ) . bolt12_invoice ( ) ;
14651468
1466- ( total_msat, recipient_onion, keysend_preimage, onion_session_privs, invoice_request)
1469+ ( total_msat, recipient_onion, keysend_preimage, onion_session_privs, invoice_request, bolt12_invoice . cloned ( ) )
14671470 } ,
14681471 PendingOutboundPayment :: Legacy { .. } => {
14691472 log_error ! ( logger, "Unable to retry payments that were initially sent on LDK versions prior to 0.0.102" ) ;
@@ -1503,7 +1506,7 @@ impl OutboundPayments {
15031506 }
15041507 } ;
15051508 let res = self . pay_route_internal ( & route, payment_hash, & recipient_onion, keysend_preimage,
1506- invoice_request. as_ref ( ) , payment_id, Some ( total_msat) , & onion_session_privs, node_signer,
1509+ invoice_request. as_ref ( ) , bolt12_invoice . as_ref ( ) , payment_id, Some ( total_msat) , & onion_session_privs, node_signer,
15071510 best_block_height, & send_payment_along_path) ;
15081511 log_info ! ( logger, "Result retrying payment id {}: {:?}" , & payment_id, res) ;
15091512 if let Err ( e) = res {
@@ -1656,7 +1659,7 @@ impl OutboundPayments {
16561659
16571660 let recipient_onion_fields = RecipientOnionFields :: spontaneous_empty ( ) ;
16581661 match self . pay_route_internal ( & route, payment_hash, & recipient_onion_fields,
1659- None , None , payment_id, None , & onion_session_privs, node_signer, best_block_height,
1662+ None , None , None , payment_id, None , & onion_session_privs, node_signer, best_block_height,
16601663 & send_payment_along_path
16611664 ) {
16621665 Ok ( ( ) ) => Ok ( ( payment_hash, payment_id) ) ,
@@ -1893,7 +1896,7 @@ impl OutboundPayments {
18931896
18941897 fn pay_route_internal < NS : Deref , F > (
18951898 & self , route : & Route , payment_hash : PaymentHash , recipient_onion : & RecipientOnionFields ,
1896- keysend_preimage : Option < PaymentPreimage > , invoice_request : Option < & InvoiceRequest > ,
1899+ keysend_preimage : Option < PaymentPreimage > , invoice_request : Option < & InvoiceRequest > , bolt12_invoice : Option < & PaidBolt12Invoice > ,
18971900 payment_id : PaymentId , recv_value_msat : Option < u64 > , onion_session_privs : & Vec < [ u8 ; 32 ] > ,
18981901 node_signer : & NS , best_block_height : u32 , send_payment_along_path : & F
18991902 ) -> Result < ( ) , PaymentSendFailure >
@@ -1949,6 +1952,7 @@ impl OutboundPayments {
19491952 let path_res = send_payment_along_path ( SendAlongPathArgs {
19501953 path : & path, payment_hash : & payment_hash, recipient_onion, total_value,
19511954 cur_height, payment_id, keysend_preimage : & keysend_preimage, invoice_request,
1955+ bolt12_invoice,
19521956 session_priv_bytes : * session_priv_bytes
19531957 } ) ;
19541958 results. push ( path_res) ;
@@ -2015,7 +2019,7 @@ impl OutboundPayments {
20152019 F : Fn ( SendAlongPathArgs ) -> Result < ( ) , APIError > ,
20162020 {
20172021 self . pay_route_internal ( route, payment_hash, & recipient_onion,
2018- keysend_preimage, None , payment_id, recv_value_msat, & onion_session_privs,
2022+ keysend_preimage, None , None , payment_id, recv_value_msat, & onion_session_privs,
20192023 node_signer, best_block_height, & send_payment_along_path)
20202024 . map_err ( |e| { self . remove_outbound_if_all_failed ( payment_id, & e) ; e } )
20212025 }
@@ -2036,8 +2040,8 @@ impl OutboundPayments {
20362040 }
20372041
20382042 pub ( super ) fn claim_htlc < L : Deref > (
2039- & self , payment_id : PaymentId , payment_preimage : PaymentPreimage , session_priv : SecretKey ,
2040- path : Path , from_onchain : bool , ev_completion_action : EventCompletionAction ,
2043+ & self , payment_id : PaymentId , payment_preimage : PaymentPreimage , bolt12_invoice : Option < PaidBolt12Invoice > ,
2044+ session_priv : SecretKey , path : Path , from_onchain : bool , ev_completion_action : EventCompletionAction ,
20412045 pending_events : & Mutex < VecDeque < ( events:: Event , Option < EventCompletionAction > ) > > ,
20422046 logger : & L ,
20432047 ) where L :: Target : Logger {
@@ -2057,7 +2061,7 @@ impl OutboundPayments {
20572061 payment_hash,
20582062 amount_msat,
20592063 fee_paid_msat,
2060- bolt12_invoice : payment . get ( ) . bolt12_invoice ( ) . cloned ( ) ,
2064+ bolt12_invoice : bolt12_invoice,
20612065 } , Some ( ev_completion_action. clone ( ) ) ) ) ;
20622066 payment. get_mut ( ) . mark_fulfilled ( ) ;
20632067 }
0 commit comments