@@ -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,8 @@ 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+ // FIXME: remove the bolt12_invoice here! we need to clean up this part!
1048+ payment_hash, recipient_onion. clone ( ) , keysend_preimage, None , Some ( bolt12_invoice. clone ( ) ) , & route,
10461049 Some ( retry_strategy) , payment_params, entropy_source, best_block_height,
10471050 ) ;
10481051 * entry. into_mut ( ) = retryable_payment;
@@ -1053,7 +1056,8 @@ impl OutboundPayments {
10531056 invoice_request
10541057 } else { unreachable ! ( ) } ;
10551058 let ( retryable_payment, onion_session_privs) = Self :: create_pending_payment (
1056- payment_hash, recipient_onion. clone ( ) , keysend_preimage, Some ( invreq) , Some ( bolt12_invoice) , & route,
1059+ // FIXME: We do not need anymore the bolt12_invoice here! we need to clean up this part!
1060+ payment_hash, recipient_onion. clone ( ) , keysend_preimage, Some ( invreq) , Some ( bolt12_invoice. clone ( ) ) , & route,
10571061 Some ( retry_strategy) , payment_params, entropy_source, best_block_height
10581062 ) ;
10591063 outbounds. insert ( payment_id, retryable_payment) ;
@@ -1066,7 +1070,7 @@ impl OutboundPayments {
10661070 core:: mem:: drop ( outbounds) ;
10671071
10681072 let result = self . pay_route_internal (
1069- & route, payment_hash, & recipient_onion, keysend_preimage, invoice_request, payment_id,
1073+ & route, payment_hash, & recipient_onion, keysend_preimage, invoice_request, Some ( bolt12_invoice ) , payment_id,
10701074 Some ( route_params. final_value_msat ) , & onion_session_privs, node_signer, best_block_height,
10711075 & send_payment_along_path
10721076 ) ;
@@ -1359,7 +1363,7 @@ impl OutboundPayments {
13591363 } ) ?;
13601364
13611365 let res = self . pay_route_internal ( & route, payment_hash, & recipient_onion,
1362- keysend_preimage, None , payment_id, None , & onion_session_privs, node_signer,
1366+ keysend_preimage, None , None , payment_id, None , & onion_session_privs, node_signer,
13631367 best_block_height, & send_payment_along_path) ;
13641368 log_info ! ( logger, "Sending payment with id {} and hash {} returned {:?}" ,
13651369 payment_id, payment_hash, res) ;
@@ -1437,7 +1441,7 @@ impl OutboundPayments {
14371441 }
14381442 }
14391443 }
1440- let ( total_msat, recipient_onion, keysend_preimage, onion_session_privs, invoice_request) = {
1444+ let ( total_msat, recipient_onion, keysend_preimage, onion_session_privs, invoice_request, bolt12_invoice ) = {
14411445 let mut outbounds = self . pending_outbound_payments . lock ( ) . unwrap ( ) ;
14421446 match outbounds. entry ( payment_id) {
14431447 hash_map:: Entry :: Occupied ( mut payment) => {
@@ -1479,8 +1483,9 @@ impl OutboundPayments {
14791483 }
14801484
14811485 payment. get_mut ( ) . increment_attempts ( ) ;
1486+ let bolt12_invoice = payment. get ( ) . bolt12_invoice ( ) ;
14821487
1483- ( total_msat, recipient_onion, keysend_preimage, onion_session_privs, invoice_request)
1488+ ( total_msat, recipient_onion, keysend_preimage, onion_session_privs, invoice_request, bolt12_invoice . cloned ( ) )
14841489 } ,
14851490 PendingOutboundPayment :: Legacy { .. } => {
14861491 log_error ! ( logger, "Unable to retry payments that were initially sent on LDK versions prior to 0.0.102" ) ;
@@ -1520,7 +1525,7 @@ impl OutboundPayments {
15201525 }
15211526 } ;
15221527 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,
1528+ invoice_request. as_ref ( ) , bolt12_invoice , payment_id, Some ( total_msat) , & onion_session_privs, node_signer,
15241529 best_block_height, & send_payment_along_path) ;
15251530 log_info ! ( logger, "Result retrying payment id {}: {:?}" , & payment_id, res) ;
15261531 if let Err ( e) = res {
@@ -1673,7 +1678,7 @@ impl OutboundPayments {
16731678
16741679 let recipient_onion_fields = RecipientOnionFields :: spontaneous_empty ( ) ;
16751680 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,
1681+ None , None , None , payment_id, None , & onion_session_privs, node_signer, best_block_height,
16771682 & send_payment_along_path
16781683 ) {
16791684 Ok ( ( ) ) => Ok ( ( payment_hash, payment_id) ) ,
@@ -1865,7 +1870,7 @@ impl OutboundPayments {
18651870
18661871 fn pay_route_internal < NS : Deref , F > (
18671872 & self , route : & Route , payment_hash : PaymentHash , recipient_onion : & RecipientOnionFields ,
1868- keysend_preimage : Option < PaymentPreimage > , invoice_request : Option < & InvoiceRequest > ,
1873+ keysend_preimage : Option < PaymentPreimage > , invoice_request : Option < & InvoiceRequest > , bolt12_invoice : Option < PaidBolt12Invoice > ,
18691874 payment_id : PaymentId , recv_value_msat : Option < u64 > , onion_session_privs : & Vec < [ u8 ; 32 ] > ,
18701875 node_signer : & NS , best_block_height : u32 , send_payment_along_path : & F
18711876 ) -> Result < ( ) , PaymentSendFailure >
@@ -1921,6 +1926,7 @@ impl OutboundPayments {
19211926 let path_res = send_payment_along_path ( SendAlongPathArgs {
19221927 path : & path, payment_hash : & payment_hash, recipient_onion, total_value,
19231928 cur_height, payment_id, keysend_preimage : & keysend_preimage, invoice_request,
1929+ bolt12_invoice : bolt12_invoice. as_ref ( ) ,
19241930 session_priv_bytes : * session_priv_bytes
19251931 } ) ;
19261932 results. push ( path_res) ;
@@ -1987,7 +1993,7 @@ impl OutboundPayments {
19871993 F : Fn ( SendAlongPathArgs ) -> Result < ( ) , APIError > ,
19881994 {
19891995 self . pay_route_internal ( route, payment_hash, & recipient_onion,
1990- keysend_preimage, None , payment_id, recv_value_msat, & onion_session_privs,
1996+ keysend_preimage, None , None , payment_id, recv_value_msat, & onion_session_privs,
19911997 node_signer, best_block_height, & send_payment_along_path)
19921998 . map_err ( |e| { self . remove_outbound_if_all_failed ( payment_id, & e) ; e } )
19931999 }
@@ -2008,8 +2014,8 @@ impl OutboundPayments {
20082014 }
20092015
20102016 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 ,
2017+ & self , payment_id : PaymentId , payment_preimage : PaymentPreimage , bolt12_invoice : Option < PaidBolt12Invoice > ,
2018+ session_priv : SecretKey , path : Path , from_onchain : bool , ev_completion_action : EventCompletionAction ,
20132019 pending_events : & Mutex < VecDeque < ( events:: Event , Option < EventCompletionAction > ) > > ,
20142020 logger : & L ,
20152021 ) where L :: Target : Logger {
@@ -2029,7 +2035,7 @@ impl OutboundPayments {
20292035 payment_hash,
20302036 amount_msat,
20312037 fee_paid_msat,
2032- bolt12_invoice : payment . get ( ) . bolt12_invoice ( ) . cloned ( ) ,
2038+ bolt12_invoice : bolt12_invoice. clone ( ) ,
20332039 } , Some ( ev_completion_action. clone ( ) ) ) ) ;
20342040 payment. get_mut ( ) . mark_fulfilled ( ) ;
20352041 }
@@ -2061,6 +2067,7 @@ impl OutboundPayments {
20612067 let mut outbounds = self . pending_outbound_payments . lock ( ) . unwrap ( ) ;
20622068 let mut pending_events = pending_events. lock ( ) . unwrap ( ) ;
20632069 for source in sources {
2070+ // TODO(vincenzopalazzo): This should contain the paid bolt12 invoice.
20642071 if let HTLCSource :: OutboundRoute { session_priv, payment_id, path, .. } = source {
20652072 let mut session_priv_bytes = [ 0 ; 32 ] ;
20662073 session_priv_bytes. copy_from_slice ( & session_priv[ ..] ) ;
0 commit comments