@@ -163,6 +163,7 @@ impl PendingOutboundPayment {
163
163
_ => None ,
164
164
}
165
165
}
166
+
166
167
fn increment_attempts ( & mut self ) {
167
168
if let PendingOutboundPayment :: Retryable { attempts, .. } = self {
168
169
attempts. count += 1 ;
@@ -797,6 +798,7 @@ pub(super) struct SendAlongPathArgs<'a> {
797
798
pub payment_id : PaymentId ,
798
799
pub keysend_preimage : & ' a Option < PaymentPreimage > ,
799
800
pub invoice_request : Option < & ' a InvoiceRequest > ,
801
+ pub bolt12_invoice : Option < & ' a PaidBolt12Invoice > ,
800
802
pub session_priv_bytes : [ u8 ; 32 ] ,
801
803
}
802
804
@@ -1025,7 +1027,7 @@ impl OutboundPayments {
1025
1027
hash_map:: Entry :: Occupied ( entry) => match entry. get ( ) {
1026
1028
PendingOutboundPayment :: InvoiceReceived { .. } => {
1027
1029
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,
1029
1031
Some ( retry_strategy) , payment_params, entropy_source, best_block_height,
1030
1032
) ;
1031
1033
* entry. into_mut ( ) = retryable_payment;
@@ -1036,7 +1038,7 @@ impl OutboundPayments {
1036
1038
invoice_request
1037
1039
} else { unreachable ! ( ) } ;
1038
1040
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,
1040
1042
Some ( retry_strategy) , payment_params, entropy_source, best_block_height
1041
1043
) ;
1042
1044
outbounds. insert ( payment_id, retryable_payment) ;
@@ -1049,7 +1051,7 @@ impl OutboundPayments {
1049
1051
core:: mem:: drop ( outbounds) ;
1050
1052
1051
1053
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,
1053
1055
Some ( route_params. final_value_msat ) , & onion_session_privs, node_signer, best_block_height,
1054
1056
& send_payment_along_path
1055
1057
) ;
@@ -1342,7 +1344,7 @@ impl OutboundPayments {
1342
1344
} ) ?;
1343
1345
1344
1346
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,
1346
1348
best_block_height, & send_payment_along_path) ;
1347
1349
log_info ! ( logger, "Sending payment with id {} and hash {} returned {:?}" ,
1348
1350
payment_id, payment_hash, res) ;
@@ -1420,7 +1422,7 @@ impl OutboundPayments {
1420
1422
}
1421
1423
}
1422
1424
}
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 ) = {
1424
1426
let mut outbounds = self . pending_outbound_payments . lock ( ) . unwrap ( ) ;
1425
1427
match outbounds. entry ( payment_id) {
1426
1428
hash_map:: Entry :: Occupied ( mut payment) => {
@@ -1462,8 +1464,9 @@ impl OutboundPayments {
1462
1464
}
1463
1465
1464
1466
payment. get_mut ( ) . increment_attempts ( ) ;
1467
+ let bolt12_invoice = payment. get ( ) . bolt12_invoice ( ) ;
1465
1468
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 ( ) )
1467
1470
} ,
1468
1471
PendingOutboundPayment :: Legacy { .. } => {
1469
1472
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 {
1503
1506
}
1504
1507
} ;
1505
1508
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,
1507
1510
best_block_height, & send_payment_along_path) ;
1508
1511
log_info ! ( logger, "Result retrying payment id {}: {:?}" , & payment_id, res) ;
1509
1512
if let Err ( e) = res {
@@ -1656,7 +1659,7 @@ impl OutboundPayments {
1656
1659
1657
1660
let recipient_onion_fields = RecipientOnionFields :: spontaneous_empty ( ) ;
1658
1661
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,
1660
1663
& send_payment_along_path
1661
1664
) {
1662
1665
Ok ( ( ) ) => Ok ( ( payment_hash, payment_id) ) ,
@@ -1893,7 +1896,7 @@ impl OutboundPayments {
1893
1896
1894
1897
fn pay_route_internal < NS : Deref , F > (
1895
1898
& 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 > ,
1897
1900
payment_id : PaymentId , recv_value_msat : Option < u64 > , onion_session_privs : & Vec < [ u8 ; 32 ] > ,
1898
1901
node_signer : & NS , best_block_height : u32 , send_payment_along_path : & F
1899
1902
) -> Result < ( ) , PaymentSendFailure >
@@ -1949,6 +1952,7 @@ impl OutboundPayments {
1949
1952
let path_res = send_payment_along_path ( SendAlongPathArgs {
1950
1953
path : & path, payment_hash : & payment_hash, recipient_onion, total_value,
1951
1954
cur_height, payment_id, keysend_preimage : & keysend_preimage, invoice_request,
1955
+ bolt12_invoice,
1952
1956
session_priv_bytes : * session_priv_bytes
1953
1957
} ) ;
1954
1958
results. push ( path_res) ;
@@ -2015,7 +2019,7 @@ impl OutboundPayments {
2015
2019
F : Fn ( SendAlongPathArgs ) -> Result < ( ) , APIError > ,
2016
2020
{
2017
2021
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,
2019
2023
node_signer, best_block_height, & send_payment_along_path)
2020
2024
. map_err ( |e| { self . remove_outbound_if_all_failed ( payment_id, & e) ; e } )
2021
2025
}
@@ -2036,8 +2040,8 @@ impl OutboundPayments {
2036
2040
}
2037
2041
2038
2042
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 ,
2041
2045
pending_events : & Mutex < VecDeque < ( events:: Event , Option < EventCompletionAction > ) > > ,
2042
2046
logger : & L ,
2043
2047
) where L :: Target : Logger {
@@ -2057,7 +2061,7 @@ impl OutboundPayments {
2057
2061
payment_hash,
2058
2062
amount_msat,
2059
2063
fee_paid_msat,
2060
- bolt12_invoice : payment . get ( ) . bolt12_invoice ( ) . cloned ( ) ,
2064
+ bolt12_invoice : bolt12_invoice,
2061
2065
} , Some ( ev_completion_action. clone ( ) ) ) ) ;
2062
2066
payment. get_mut ( ) . mark_fulfilled ( ) ;
2063
2067
}
0 commit comments