@@ -94,6 +94,7 @@ pub(crate) enum PendingOutboundPayment {
94
94
payment_secret : Option < PaymentSecret > ,
95
95
payment_metadata : Option < Vec < u8 > > ,
96
96
keysend_preimage : Option < PaymentPreimage > ,
97
+ invoice_request : Option < InvoiceRequest > ,
97
98
custom_tlvs : Vec < ( u64 , Vec < u8 > ) > ,
98
99
pending_amt_msat : u64 ,
99
100
/// Used to track the fee paid. Present iff the payment was serialized on 0.0.103+.
@@ -881,7 +882,7 @@ impl OutboundPayments {
881
882
route_params. max_total_routing_fee_msat = Some ( max_fee_msat) ;
882
883
}
883
884
self . send_payment_for_bolt12_invoice_internal (
884
- payment_id, payment_hash, None , route_params, retry_strategy, router, first_hops,
885
+ payment_id, payment_hash, None , None , route_params, retry_strategy, router, first_hops,
885
886
inflight_htlcs, entropy_source, node_signer, node_id_lookup, secp_ctx, best_block_height,
886
887
logger, pending_events, send_payment_along_path
887
888
)
@@ -891,10 +892,10 @@ impl OutboundPayments {
891
892
R : Deref , ES : Deref , NS : Deref , NL : Deref , IH , SP , L : Deref
892
893
> (
893
894
& self , payment_id : PaymentId , payment_hash : PaymentHash ,
894
- keysend_preimage : Option < PaymentPreimage > , mut route_params : RouteParameters ,
895
- retry_strategy : Retry , router : & R , first_hops : Vec < ChannelDetails > , inflight_htlcs : IH ,
896
- entropy_source : & ES , node_signer : & NS , node_id_lookup : & NL ,
897
- secp_ctx : & Secp256k1 < secp256k1:: All > , best_block_height : u32 , logger : & L ,
895
+ keysend_preimage : Option < PaymentPreimage > , mut invoice_request : Option < InvoiceRequest > ,
896
+ mut route_params : RouteParameters , retry_strategy : Retry , router : & R ,
897
+ first_hops : Vec < ChannelDetails > , inflight_htlcs : IH , entropy_source : & ES , node_signer : & NS ,
898
+ node_id_lookup : & NL , secp_ctx : & Secp256k1 < secp256k1:: All > , best_block_height : u32 , logger : & L ,
898
899
pending_events : & Mutex < VecDeque < ( events:: Event , Option < EventCompletionAction > ) > > ,
899
900
send_payment_along_path : SP ,
900
901
) -> Result < ( ) , Bolt12PaymentError >
@@ -949,8 +950,8 @@ impl OutboundPayments {
949
950
950
951
let payment_params = Some ( route_params. payment_params . clone ( ) ) ;
951
952
let ( retryable_payment, onion_session_privs) = self . create_pending_payment (
952
- payment_hash, recipient_onion. clone ( ) , keysend_preimage, & route , Some ( retry_strategy ) ,
953
- payment_params, entropy_source, best_block_height
953
+ payment_hash, recipient_onion. clone ( ) , keysend_preimage, invoice_request . take ( ) , & route ,
954
+ Some ( retry_strategy ) , payment_params, entropy_source, best_block_height
954
955
) ;
955
956
let mut invoice_request_opt = None ;
956
957
let mut outbounds = self . pending_outbound_payments . lock ( ) . unwrap ( ) ;
@@ -1088,23 +1089,24 @@ impl OutboundPayments {
1088
1089
IH : Fn ( ) -> InFlightHtlcs ,
1089
1090
SP : Fn ( SendAlongPathArgs ) -> Result < ( ) , APIError > ,
1090
1091
{
1091
- let ( payment_hash, keysend_preimage, route_params, retry_strategy) =
1092
+ let ( payment_hash, keysend_preimage, route_params, retry_strategy, invoice_request ) =
1092
1093
match self . pending_outbound_payments . lock ( ) . unwrap ( ) . entry ( payment_id) {
1093
1094
hash_map:: Entry :: Occupied ( entry) => match entry. get ( ) {
1094
1095
PendingOutboundPayment :: StaticInvoiceReceived {
1095
- payment_hash, route_params, retry_strategy, keysend_preimage, ..
1096
+ payment_hash, route_params, retry_strategy, keysend_preimage, invoice_request , ..
1096
1097
} => {
1097
- ( * payment_hash, * keysend_preimage, route_params. clone ( ) , * retry_strategy)
1098
+ ( * payment_hash, * keysend_preimage, route_params. clone ( ) , * retry_strategy,
1099
+ invoice_request. clone ( ) )
1098
1100
} ,
1099
1101
_ => return Err ( Bolt12PaymentError :: DuplicateInvoice ) ,
1100
1102
} ,
1101
1103
hash_map:: Entry :: Vacant ( _) => return Err ( Bolt12PaymentError :: UnexpectedInvoice ) ,
1102
1104
} ;
1103
1105
1104
1106
self . send_payment_for_bolt12_invoice_internal (
1105
- payment_id, payment_hash, Some ( keysend_preimage) , route_params , retry_strategy , router ,
1106
- first_hops , inflight_htlcs , entropy_source , node_signer , node_id_lookup , secp_ctx ,
1107
- best_block_height, logger, pending_events, send_payment_along_path
1107
+ payment_id, payment_hash, Some ( keysend_preimage) , Some ( invoice_request ) , route_params ,
1108
+ retry_strategy , router , first_hops , inflight_htlcs , entropy_source , node_signer ,
1109
+ node_id_lookup , secp_ctx , best_block_height, logger, pending_events, send_payment_along_path
1108
1110
)
1109
1111
}
1110
1112
@@ -1329,14 +1331,14 @@ impl OutboundPayments {
1329
1331
}
1330
1332
}
1331
1333
}
1332
- let ( total_msat, recipient_onion, keysend_preimage, onion_session_privs) = {
1334
+ let ( total_msat, recipient_onion, keysend_preimage, onion_session_privs, invoice_request ) = {
1333
1335
let mut outbounds = self . pending_outbound_payments . lock ( ) . unwrap ( ) ;
1334
1336
match outbounds. entry ( payment_id) {
1335
1337
hash_map:: Entry :: Occupied ( mut payment) => {
1336
1338
match payment. get ( ) {
1337
1339
PendingOutboundPayment :: Retryable {
1338
1340
total_msat, keysend_preimage, payment_secret, payment_metadata,
1339
- custom_tlvs, pending_amt_msat, ..
1341
+ custom_tlvs, pending_amt_msat, invoice_request , ..
1340
1342
} => {
1341
1343
const RETRY_OVERFLOW_PERCENTAGE : u64 = 10 ;
1342
1344
let retry_amt_msat = route. get_total_amount ( ) ;
@@ -1359,6 +1361,7 @@ impl OutboundPayments {
1359
1361
custom_tlvs : custom_tlvs. clone ( ) ,
1360
1362
} ;
1361
1363
let keysend_preimage = * keysend_preimage;
1364
+ let invoice_request = invoice_request. clone ( ) ;
1362
1365
1363
1366
let mut onion_session_privs = Vec :: with_capacity ( route. paths . len ( ) ) ;
1364
1367
for _ in 0 ..route. paths . len ( ) {
@@ -1371,7 +1374,7 @@ impl OutboundPayments {
1371
1374
1372
1375
payment. get_mut ( ) . increment_attempts ( ) ;
1373
1376
1374
- ( total_msat, recipient_onion, keysend_preimage, onion_session_privs)
1377
+ ( total_msat, recipient_onion, keysend_preimage, onion_session_privs, invoice_request )
1375
1378
} ,
1376
1379
PendingOutboundPayment :: Legacy { .. } => {
1377
1380
log_error ! ( logger, "Unable to retry payments that were initially sent on LDK versions prior to 0.0.102" ) ;
@@ -1409,8 +1412,8 @@ impl OutboundPayments {
1409
1412
}
1410
1413
} ;
1411
1414
let res = self . pay_route_internal ( & route, payment_hash, & recipient_onion, keysend_preimage,
1412
- None , payment_id, Some ( total_msat) , onion_session_privs, node_signer, best_block_height ,
1413
- & send_payment_along_path) ;
1415
+ invoice_request . as_ref ( ) , payment_id, Some ( total_msat) , onion_session_privs, node_signer,
1416
+ best_block_height , & send_payment_along_path) ;
1414
1417
log_info ! ( logger, "Result retrying payment id {}: {:?}" , & payment_id, res) ;
1415
1418
if let Err ( e) = res {
1416
1419
self . handle_pay_route_err ( e, payment_id, payment_hash, route, route_params, router, first_hops, inflight_htlcs, entropy_source, node_signer, best_block_height, logger, pending_events, send_payment_along_path) ;
@@ -1562,7 +1565,7 @@ impl OutboundPayments {
1562
1565
hash_map:: Entry :: Occupied ( _) => Err ( PaymentSendFailure :: DuplicatePayment ) ,
1563
1566
hash_map:: Entry :: Vacant ( entry) => {
1564
1567
let ( payment, onion_session_privs) = self . create_pending_payment (
1565
- payment_hash, recipient_onion, keysend_preimage, route, retry_strategy,
1568
+ payment_hash, recipient_onion, keysend_preimage, None , route, retry_strategy,
1566
1569
payment_params, entropy_source, best_block_height
1567
1570
) ;
1568
1571
entry. insert ( payment) ;
@@ -1573,8 +1576,9 @@ impl OutboundPayments {
1573
1576
1574
1577
fn create_pending_payment < ES : Deref > (
1575
1578
& self , payment_hash : PaymentHash , recipient_onion : RecipientOnionFields ,
1576
- keysend_preimage : Option < PaymentPreimage > , route : & Route , retry_strategy : Option < Retry > ,
1577
- payment_params : Option < PaymentParameters > , entropy_source : & ES , best_block_height : u32
1579
+ keysend_preimage : Option < PaymentPreimage > , invoice_request : Option < InvoiceRequest > ,
1580
+ route : & Route , retry_strategy : Option < Retry > , payment_params : Option < PaymentParameters > ,
1581
+ entropy_source : & ES , best_block_height : u32
1578
1582
) -> ( PendingOutboundPayment , Vec < [ u8 ; 32 ] > )
1579
1583
where
1580
1584
ES :: Target : EntropySource ,
@@ -1595,6 +1599,7 @@ impl OutboundPayments {
1595
1599
payment_secret : recipient_onion. payment_secret ,
1596
1600
payment_metadata : recipient_onion. payment_metadata ,
1597
1601
keysend_preimage,
1602
+ invoice_request,
1598
1603
custom_tlvs : recipient_onion. custom_tlvs ,
1599
1604
starting_block_height : best_block_height,
1600
1605
total_msat : route. get_total_amount ( ) ,
@@ -2156,6 +2161,7 @@ impl OutboundPayments {
2156
2161
payment_secret: None , // only used for retries, and we'll never retry on startup
2157
2162
payment_metadata: None , // only used for retries, and we'll never retry on startup
2158
2163
keysend_preimage: None , // only used for retries, and we'll never retry on startup
2164
+ invoice_request: None , // only used for retries, and we'll never retry on startup
2159
2165
custom_tlvs: Vec :: new( ) , // only used for retries, and we'll never retry on startup
2160
2166
pending_amt_msat: path_amt,
2161
2167
pending_fee_msat: Some ( path_fee) ,
@@ -2242,6 +2248,7 @@ impl_writeable_tlv_based_enum_upgradable!(PendingOutboundPayment,
2242
2248
( 9 , custom_tlvs, optional_vec) ,
2243
2249
( 10 , starting_block_height, required) ,
2244
2250
( 11 , remaining_max_total_routing_fee_msat, option) ,
2251
+ ( 13 , invoice_request, option) ,
2245
2252
( not_written, retry_strategy, ( static_value, None ) ) ,
2246
2253
( not_written, attempts, ( static_value, PaymentAttempts :: new( ) ) ) ,
2247
2254
} ,
0 commit comments