@@ -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
@@ -1042,7 +1044,7 @@ impl OutboundPayments {
10421044 hash_map:: Entry :: Occupied ( entry) => match entry. get ( ) {
10431045 PendingOutboundPayment :: InvoiceReceived { .. } => {
10441046 let ( retryable_payment, onion_session_privs) = Self :: create_pending_payment (
1045- payment_hash, recipient_onion. clone ( ) , keysend_preimage, None , Some ( bolt12_invoice) , & route,
1047+ payment_hash, recipient_onion. clone ( ) , keysend_preimage, None , Some ( bolt12_invoice. clone ( ) ) , & route,
10461048 Some ( retry_strategy) , payment_params, entropy_source, best_block_height,
10471049 ) ;
10481050 * entry. into_mut ( ) = retryable_payment;
@@ -1053,7 +1055,7 @@ impl OutboundPayments {
10531055 invoice_request
10541056 } else { unreachable ! ( ) } ;
10551057 let ( retryable_payment, onion_session_privs) = Self :: create_pending_payment (
1056- payment_hash, recipient_onion. clone ( ) , keysend_preimage, Some ( invreq) , Some ( bolt12_invoice) , & route,
1058+ payment_hash, recipient_onion. clone ( ) , keysend_preimage, Some ( invreq) , Some ( bolt12_invoice. clone ( ) ) , & route,
10571059 Some ( retry_strategy) , payment_params, entropy_source, best_block_height
10581060 ) ;
10591061 outbounds. insert ( payment_id, retryable_payment) ;
@@ -1066,7 +1068,7 @@ impl OutboundPayments {
10661068 core:: mem:: drop ( outbounds) ;
10671069
10681070 let result = self . pay_route_internal (
1069- & route, payment_hash, & recipient_onion, keysend_preimage, invoice_request, payment_id,
1071+ & route, payment_hash, & recipient_onion, keysend_preimage, invoice_request, Some ( & bolt12_invoice ) , payment_id,
10701072 Some ( route_params. final_value_msat ) , & onion_session_privs, node_signer, best_block_height,
10711073 & send_payment_along_path
10721074 ) ;
@@ -1359,7 +1361,7 @@ impl OutboundPayments {
13591361 } ) ?;
13601362
13611363 let res = self . pay_route_internal ( & route, payment_hash, & recipient_onion,
1362- keysend_preimage, None , payment_id, None , & onion_session_privs, node_signer,
1364+ keysend_preimage, None , None , payment_id, None , & onion_session_privs, node_signer,
13631365 best_block_height, & send_payment_along_path) ;
13641366 log_info ! ( logger, "Sending payment with id {} and hash {} returned {:?}" ,
13651367 payment_id, payment_hash, res) ;
@@ -1437,7 +1439,7 @@ impl OutboundPayments {
14371439 }
14381440 }
14391441 }
1440- let ( total_msat, recipient_onion, keysend_preimage, onion_session_privs, invoice_request) = {
1442+ let ( total_msat, recipient_onion, keysend_preimage, onion_session_privs, invoice_request, bolt12_invoice ) = {
14411443 let mut outbounds = self . pending_outbound_payments . lock ( ) . unwrap ( ) ;
14421444 match outbounds. entry ( payment_id) {
14431445 hash_map:: Entry :: Occupied ( mut payment) => {
@@ -1479,8 +1481,9 @@ impl OutboundPayments {
14791481 }
14801482
14811483 payment. get_mut ( ) . increment_attempts ( ) ;
1484+ let bolt12_invoice = payment. get ( ) . bolt12_invoice ( ) ;
14821485
1483- ( total_msat, recipient_onion, keysend_preimage, onion_session_privs, invoice_request)
1486+ ( total_msat, recipient_onion, keysend_preimage, onion_session_privs, invoice_request, bolt12_invoice . cloned ( ) )
14841487 } ,
14851488 PendingOutboundPayment :: Legacy { .. } => {
14861489 log_error ! ( logger, "Unable to retry payments that were initially sent on LDK versions prior to 0.0.102" ) ;
@@ -1520,7 +1523,7 @@ impl OutboundPayments {
15201523 }
15211524 } ;
15221525 let res = self . pay_route_internal ( & route, payment_hash, & recipient_onion, keysend_preimage,
1523- invoice_request. as_ref ( ) , payment_id, Some ( total_msat) , & onion_session_privs, node_signer,
1526+ invoice_request. as_ref ( ) , bolt12_invoice . as_ref ( ) , payment_id, Some ( total_msat) , & onion_session_privs, node_signer,
15241527 best_block_height, & send_payment_along_path) ;
15251528 log_info ! ( logger, "Result retrying payment id {}: {:?}" , & payment_id, res) ;
15261529 if let Err ( e) = res {
@@ -1673,7 +1676,7 @@ impl OutboundPayments {
16731676
16741677 let recipient_onion_fields = RecipientOnionFields :: spontaneous_empty ( ) ;
16751678 match self . pay_route_internal ( & route, payment_hash, & recipient_onion_fields,
1676- None , None , payment_id, None , & onion_session_privs, node_signer, best_block_height,
1679+ None , None , None , payment_id, None , & onion_session_privs, node_signer, best_block_height,
16771680 & send_payment_along_path
16781681 ) {
16791682 Ok ( ( ) ) => Ok ( ( payment_hash, payment_id) ) ,
@@ -1865,7 +1868,7 @@ impl OutboundPayments {
18651868
18661869 fn pay_route_internal < NS : Deref , F > (
18671870 & self , route : & Route , payment_hash : PaymentHash , recipient_onion : & RecipientOnionFields ,
1868- keysend_preimage : Option < PaymentPreimage > , invoice_request : Option < & InvoiceRequest > ,
1871+ keysend_preimage : Option < PaymentPreimage > , invoice_request : Option < & InvoiceRequest > , bolt12_invoice : Option < & PaidBolt12Invoice > ,
18691872 payment_id : PaymentId , recv_value_msat : Option < u64 > , onion_session_privs : & Vec < [ u8 ; 32 ] > ,
18701873 node_signer : & NS , best_block_height : u32 , send_payment_along_path : & F
18711874 ) -> Result < ( ) , PaymentSendFailure >
@@ -1921,6 +1924,7 @@ impl OutboundPayments {
19211924 let path_res = send_payment_along_path ( SendAlongPathArgs {
19221925 path : & path, payment_hash : & payment_hash, recipient_onion, total_value,
19231926 cur_height, payment_id, keysend_preimage : & keysend_preimage, invoice_request,
1927+ bolt12_invoice,
19241928 session_priv_bytes : * session_priv_bytes
19251929 } ) ;
19261930 results. push ( path_res) ;
@@ -1987,7 +1991,7 @@ impl OutboundPayments {
19871991 F : Fn ( SendAlongPathArgs ) -> Result < ( ) , APIError > ,
19881992 {
19891993 self . pay_route_internal ( route, payment_hash, & recipient_onion,
1990- keysend_preimage, None , payment_id, recv_value_msat, & onion_session_privs,
1994+ keysend_preimage, None , None , payment_id, recv_value_msat, & onion_session_privs,
19911995 node_signer, best_block_height, & send_payment_along_path)
19921996 . map_err ( |e| { self . remove_outbound_if_all_failed ( payment_id, & e) ; e } )
19931997 }
@@ -2008,8 +2012,8 @@ impl OutboundPayments {
20082012 }
20092013
20102014 pub ( super ) fn claim_htlc < L : Deref > (
2011- & self , payment_id : PaymentId , payment_preimage : PaymentPreimage , session_priv : SecretKey ,
2012- path : Path , from_onchain : bool , ev_completion_action : EventCompletionAction ,
2015+ & self , payment_id : PaymentId , payment_preimage : PaymentPreimage , bolt12_invoice : Option < PaidBolt12Invoice > ,
2016+ session_priv : SecretKey , path : Path , from_onchain : bool , ev_completion_action : EventCompletionAction ,
20132017 pending_events : & Mutex < VecDeque < ( events:: Event , Option < EventCompletionAction > ) > > ,
20142018 logger : & L ,
20152019 ) where L :: Target : Logger {
@@ -2029,7 +2033,7 @@ impl OutboundPayments {
20292033 payment_hash,
20302034 amount_msat,
20312035 fee_paid_msat,
2032- bolt12_invoice : payment . get ( ) . bolt12_invoice ( ) . cloned ( ) ,
2036+ bolt12_invoice : bolt12_invoice,
20332037 } , Some ( ev_completion_action. clone ( ) ) ) ) ;
20342038 payment. get_mut ( ) . mark_fulfilled ( ) ;
20352039 }
0 commit comments