@@ -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,8 @@ 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
+ // 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,
1046
1049
Some ( retry_strategy) , payment_params, entropy_source, best_block_height,
1047
1050
) ;
1048
1051
* entry. into_mut ( ) = retryable_payment;
@@ -1053,7 +1056,8 @@ impl OutboundPayments {
1053
1056
invoice_request
1054
1057
} else { unreachable ! ( ) } ;
1055
1058
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,
1057
1061
Some ( retry_strategy) , payment_params, entropy_source, best_block_height
1058
1062
) ;
1059
1063
outbounds. insert ( payment_id, retryable_payment) ;
@@ -1066,7 +1070,7 @@ impl OutboundPayments {
1066
1070
core:: mem:: drop ( outbounds) ;
1067
1071
1068
1072
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,
1070
1074
Some ( route_params. final_value_msat ) , & onion_session_privs, node_signer, best_block_height,
1071
1075
& send_payment_along_path
1072
1076
) ;
@@ -1359,7 +1363,7 @@ impl OutboundPayments {
1359
1363
} ) ?;
1360
1364
1361
1365
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,
1363
1367
best_block_height, & send_payment_along_path) ;
1364
1368
log_info ! ( logger, "Sending payment with id {} and hash {} returned {:?}" ,
1365
1369
payment_id, payment_hash, res) ;
@@ -1437,7 +1441,7 @@ impl OutboundPayments {
1437
1441
}
1438
1442
}
1439
1443
}
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 ) = {
1441
1445
let mut outbounds = self . pending_outbound_payments . lock ( ) . unwrap ( ) ;
1442
1446
match outbounds. entry ( payment_id) {
1443
1447
hash_map:: Entry :: Occupied ( mut payment) => {
@@ -1479,8 +1483,9 @@ impl OutboundPayments {
1479
1483
}
1480
1484
1481
1485
payment. get_mut ( ) . increment_attempts ( ) ;
1486
+ let bolt12_invoice = payment. get ( ) . bolt12_invoice ( ) ;
1482
1487
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 ( ) )
1484
1489
} ,
1485
1490
PendingOutboundPayment :: Legacy { .. } => {
1486
1491
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 {
1520
1525
}
1521
1526
} ;
1522
1527
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,
1524
1529
best_block_height, & send_payment_along_path) ;
1525
1530
log_info ! ( logger, "Result retrying payment id {}: {:?}" , & payment_id, res) ;
1526
1531
if let Err ( e) = res {
@@ -1673,7 +1678,7 @@ impl OutboundPayments {
1673
1678
1674
1679
let recipient_onion_fields = RecipientOnionFields :: spontaneous_empty ( ) ;
1675
1680
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,
1677
1682
& send_payment_along_path
1678
1683
) {
1679
1684
Ok ( ( ) ) => Ok ( ( payment_hash, payment_id) ) ,
@@ -1865,7 +1870,7 @@ impl OutboundPayments {
1865
1870
1866
1871
fn pay_route_internal < NS : Deref , F > (
1867
1872
& 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 > ,
1869
1874
payment_id : PaymentId , recv_value_msat : Option < u64 > , onion_session_privs : & Vec < [ u8 ; 32 ] > ,
1870
1875
node_signer : & NS , best_block_height : u32 , send_payment_along_path : & F
1871
1876
) -> Result < ( ) , PaymentSendFailure >
@@ -1921,6 +1926,7 @@ impl OutboundPayments {
1921
1926
let path_res = send_payment_along_path ( SendAlongPathArgs {
1922
1927
path : & path, payment_hash : & payment_hash, recipient_onion, total_value,
1923
1928
cur_height, payment_id, keysend_preimage : & keysend_preimage, invoice_request,
1929
+ bolt12_invoice : bolt12_invoice. as_ref ( ) ,
1924
1930
session_priv_bytes : * session_priv_bytes
1925
1931
} ) ;
1926
1932
results. push ( path_res) ;
@@ -1987,7 +1993,7 @@ impl OutboundPayments {
1987
1993
F : Fn ( SendAlongPathArgs ) -> Result < ( ) , APIError > ,
1988
1994
{
1989
1995
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,
1991
1997
node_signer, best_block_height, & send_payment_along_path)
1992
1998
. map_err ( |e| { self . remove_outbound_if_all_failed ( payment_id, & e) ; e } )
1993
1999
}
@@ -2008,8 +2014,8 @@ impl OutboundPayments {
2008
2014
}
2009
2015
2010
2016
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 ,
2013
2019
pending_events : & Mutex < VecDeque < ( events:: Event , Option < EventCompletionAction > ) > > ,
2014
2020
logger : & L ,
2015
2021
) where L :: Target : Logger {
@@ -2029,7 +2035,7 @@ impl OutboundPayments {
2029
2035
payment_hash,
2030
2036
amount_msat,
2031
2037
fee_paid_msat,
2032
- bolt12_invoice : payment . get ( ) . bolt12_invoice ( ) . cloned ( ) ,
2038
+ bolt12_invoice : bolt12_invoice. clone ( ) ,
2033
2039
} , Some ( ev_completion_action. clone ( ) ) ) ) ;
2034
2040
payment. get_mut ( ) . mark_fulfilled ( ) ;
2035
2041
}
@@ -2061,6 +2067,7 @@ impl OutboundPayments {
2061
2067
let mut outbounds = self . pending_outbound_payments . lock ( ) . unwrap ( ) ;
2062
2068
let mut pending_events = pending_events. lock ( ) . unwrap ( ) ;
2063
2069
for source in sources {
2070
+ // TODO(vincenzopalazzo): This should contain the paid bolt12 invoice.
2064
2071
if let HTLCSource :: OutboundRoute { session_priv, payment_id, path, .. } = source {
2065
2072
let mut session_priv_bytes = [ 0 ; 32 ] ;
2066
2073
session_priv_bytes. copy_from_slice ( & session_priv[ ..] ) ;
0 commit comments