@@ -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
@@ -1042,7 +1044,7 @@ impl OutboundPayments {
1042
1044
hash_map:: Entry :: Occupied ( entry) => match entry. get ( ) {
1043
1045
PendingOutboundPayment :: InvoiceReceived { .. } => {
1044
1046
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,
1046
1048
Some ( retry_strategy) , payment_params, entropy_source, best_block_height,
1047
1049
) ;
1048
1050
* entry. into_mut ( ) = retryable_payment;
@@ -1053,7 +1055,7 @@ impl OutboundPayments {
1053
1055
invoice_request
1054
1056
} else { unreachable ! ( ) } ;
1055
1057
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,
1057
1059
Some ( retry_strategy) , payment_params, entropy_source, best_block_height
1058
1060
) ;
1059
1061
outbounds. insert ( payment_id, retryable_payment) ;
@@ -1066,7 +1068,7 @@ impl OutboundPayments {
1066
1068
core:: mem:: drop ( outbounds) ;
1067
1069
1068
1070
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,
1070
1072
Some ( route_params. final_value_msat ) , & onion_session_privs, node_signer, best_block_height,
1071
1073
& send_payment_along_path
1072
1074
) ;
@@ -1359,7 +1361,7 @@ impl OutboundPayments {
1359
1361
} ) ?;
1360
1362
1361
1363
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,
1363
1365
best_block_height, & send_payment_along_path) ;
1364
1366
log_info ! ( logger, "Sending payment with id {} and hash {} returned {:?}" ,
1365
1367
payment_id, payment_hash, res) ;
@@ -1437,7 +1439,7 @@ impl OutboundPayments {
1437
1439
}
1438
1440
}
1439
1441
}
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 ) = {
1441
1443
let mut outbounds = self . pending_outbound_payments . lock ( ) . unwrap ( ) ;
1442
1444
match outbounds. entry ( payment_id) {
1443
1445
hash_map:: Entry :: Occupied ( mut payment) => {
@@ -1479,8 +1481,9 @@ impl OutboundPayments {
1479
1481
}
1480
1482
1481
1483
payment. get_mut ( ) . increment_attempts ( ) ;
1484
+ let bolt12_invoice = payment. get ( ) . bolt12_invoice ( ) ;
1482
1485
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 ( ) )
1484
1487
} ,
1485
1488
PendingOutboundPayment :: Legacy { .. } => {
1486
1489
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 {
1520
1523
}
1521
1524
} ;
1522
1525
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 , payment_id, Some ( total_msat) , & onion_session_privs, node_signer,
1524
1527
best_block_height, & send_payment_along_path) ;
1525
1528
log_info ! ( logger, "Result retrying payment id {}: {:?}" , & payment_id, res) ;
1526
1529
if let Err ( e) = res {
@@ -1673,7 +1676,7 @@ impl OutboundPayments {
1673
1676
1674
1677
let recipient_onion_fields = RecipientOnionFields :: spontaneous_empty ( ) ;
1675
1678
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,
1677
1680
& send_payment_along_path
1678
1681
) {
1679
1682
Ok ( ( ) ) => Ok ( ( payment_hash, payment_id) ) ,
@@ -1865,7 +1868,7 @@ impl OutboundPayments {
1865
1868
1866
1869
fn pay_route_internal < NS : Deref , F > (
1867
1870
& 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 > ,
1869
1872
payment_id : PaymentId , recv_value_msat : Option < u64 > , onion_session_privs : & Vec < [ u8 ; 32 ] > ,
1870
1873
node_signer : & NS , best_block_height : u32 , send_payment_along_path : & F
1871
1874
) -> Result < ( ) , PaymentSendFailure >
@@ -1921,6 +1924,7 @@ impl OutboundPayments {
1921
1924
let path_res = send_payment_along_path ( SendAlongPathArgs {
1922
1925
path : & path, payment_hash : & payment_hash, recipient_onion, total_value,
1923
1926
cur_height, payment_id, keysend_preimage : & keysend_preimage, invoice_request,
1927
+ bolt12_invoice : bolt12_invoice. as_ref ( ) ,
1924
1928
session_priv_bytes : * session_priv_bytes
1925
1929
} ) ;
1926
1930
results. push ( path_res) ;
@@ -1987,7 +1991,7 @@ impl OutboundPayments {
1987
1991
F : Fn ( SendAlongPathArgs ) -> Result < ( ) , APIError > ,
1988
1992
{
1989
1993
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,
1991
1995
node_signer, best_block_height, & send_payment_along_path)
1992
1996
. map_err ( |e| { self . remove_outbound_if_all_failed ( payment_id, & e) ; e } )
1993
1997
}
@@ -2008,8 +2012,8 @@ impl OutboundPayments {
2008
2012
}
2009
2013
2010
2014
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 ,
2013
2017
pending_events : & Mutex < VecDeque < ( events:: Event , Option < EventCompletionAction > ) > > ,
2014
2018
logger : & L ,
2015
2019
) where L :: Target : Logger {
@@ -2029,7 +2033,7 @@ impl OutboundPayments {
2029
2033
payment_hash,
2030
2034
amount_msat,
2031
2035
fee_paid_msat,
2032
- bolt12_invoice : payment . get ( ) . bolt12_invoice ( ) . cloned ( ) ,
2036
+ bolt12_invoice : bolt12_invoice. clone ( ) ,
2033
2037
} , Some ( ev_completion_action. clone ( ) ) ) ) ;
2034
2038
payment. get_mut ( ) . mark_fulfilled ( ) ;
2035
2039
}
0 commit comments