@@ -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+.
@@ -880,7 +881,7 @@ impl OutboundPayments {
880
881
route_params. max_total_routing_fee_msat = Some ( max_fee_msat) ;
881
882
}
882
883
self . send_payment_for_bolt12_invoice_internal (
883
- payment_id, payment_hash, None , route_params, retry_strategy, router, first_hops,
884
+ payment_id, payment_hash, None , None , route_params, retry_strategy, router, first_hops,
884
885
inflight_htlcs, entropy_source, node_signer, node_id_lookup, secp_ctx, best_block_height,
885
886
logger, pending_events, send_payment_along_path
886
887
)
@@ -890,10 +891,10 @@ impl OutboundPayments {
890
891
R : Deref , ES : Deref , NS : Deref , NL : Deref , IH , SP , L : Deref
891
892
> (
892
893
& self , payment_id : PaymentId , payment_hash : PaymentHash ,
893
- keysend_preimage : Option < PaymentPreimage > , mut route_params : RouteParameters ,
894
- retry_strategy : Retry , router : & R , first_hops : Vec < ChannelDetails > , inflight_htlcs : IH ,
895
- entropy_source : & ES , node_signer : & NS , node_id_lookup : & NL ,
896
- secp_ctx : & Secp256k1 < secp256k1:: All > , best_block_height : u32 , logger : & L ,
894
+ keysend_preimage : Option < PaymentPreimage > , mut invoice_request : Option < InvoiceRequest > ,
895
+ mut route_params : RouteParameters , retry_strategy : Retry , router : & R ,
896
+ first_hops : Vec < ChannelDetails > , inflight_htlcs : IH , entropy_source : & ES , node_signer : & NS ,
897
+ node_id_lookup : & NL , secp_ctx : & Secp256k1 < secp256k1:: All > , best_block_height : u32 , logger : & L ,
897
898
pending_events : & Mutex < VecDeque < ( events:: Event , Option < EventCompletionAction > ) > > ,
898
899
send_payment_along_path : SP ,
899
900
) -> Result < ( ) , Bolt12PaymentError >
@@ -948,8 +949,8 @@ impl OutboundPayments {
948
949
949
950
let payment_params = Some ( route_params. payment_params . clone ( ) ) ;
950
951
let ( retryable_payment, onion_session_privs) = self . create_pending_payment (
951
- payment_hash, recipient_onion. clone ( ) , keysend_preimage, & route , Some ( retry_strategy ) ,
952
- payment_params, entropy_source, best_block_height
952
+ payment_hash, recipient_onion. clone ( ) , keysend_preimage, invoice_request . take ( ) , & route ,
953
+ Some ( retry_strategy ) , payment_params, entropy_source, best_block_height
953
954
) ;
954
955
let mut invoice_request_opt = None ;
955
956
let mut outbounds = self . pending_outbound_payments . lock ( ) . unwrap ( ) ;
@@ -1087,23 +1088,24 @@ impl OutboundPayments {
1087
1088
IH : Fn ( ) -> InFlightHtlcs ,
1088
1089
SP : Fn ( SendAlongPathArgs ) -> Result < ( ) , APIError > ,
1089
1090
{
1090
- let ( payment_hash, keysend_preimage, route_params, retry_strategy) =
1091
+ let ( payment_hash, keysend_preimage, route_params, retry_strategy, invoice_request ) =
1091
1092
match self . pending_outbound_payments . lock ( ) . unwrap ( ) . entry ( payment_id) {
1092
1093
hash_map:: Entry :: Occupied ( entry) => match entry. get ( ) {
1093
1094
PendingOutboundPayment :: StaticInvoiceReceived {
1094
- payment_hash, route_params, retry_strategy, keysend_preimage, ..
1095
+ payment_hash, route_params, retry_strategy, keysend_preimage, invoice_request , ..
1095
1096
} => {
1096
- ( * payment_hash, * keysend_preimage, route_params. clone ( ) , * retry_strategy)
1097
+ ( * payment_hash, * keysend_preimage, route_params. clone ( ) , * retry_strategy,
1098
+ invoice_request. clone ( ) )
1097
1099
} ,
1098
1100
_ => return Err ( Bolt12PaymentError :: DuplicateInvoice ) ,
1099
1101
} ,
1100
1102
hash_map:: Entry :: Vacant ( _) => return Err ( Bolt12PaymentError :: UnexpectedInvoice ) ,
1101
1103
} ;
1102
1104
1103
1105
self . send_payment_for_bolt12_invoice_internal (
1104
- payment_id, payment_hash, Some ( keysend_preimage) , route_params , retry_strategy , router ,
1105
- first_hops , inflight_htlcs , entropy_source , node_signer , node_id_lookup , secp_ctx ,
1106
- best_block_height, logger, pending_events, send_payment_along_path
1106
+ payment_id, payment_hash, Some ( keysend_preimage) , Some ( invoice_request ) , route_params ,
1107
+ retry_strategy , router , first_hops , inflight_htlcs , entropy_source , node_signer ,
1108
+ node_id_lookup , secp_ctx , best_block_height, logger, pending_events, send_payment_along_path
1107
1109
)
1108
1110
}
1109
1111
@@ -1323,14 +1325,14 @@ impl OutboundPayments {
1323
1325
}
1324
1326
}
1325
1327
}
1326
- let ( total_msat, recipient_onion, keysend_preimage, onion_session_privs) = {
1328
+ let ( total_msat, recipient_onion, keysend_preimage, onion_session_privs, invoice_request ) = {
1327
1329
let mut outbounds = self . pending_outbound_payments . lock ( ) . unwrap ( ) ;
1328
1330
match outbounds. entry ( payment_id) {
1329
1331
hash_map:: Entry :: Occupied ( mut payment) => {
1330
1332
match payment. get ( ) {
1331
1333
PendingOutboundPayment :: Retryable {
1332
1334
total_msat, keysend_preimage, payment_secret, payment_metadata,
1333
- custom_tlvs, pending_amt_msat, ..
1335
+ custom_tlvs, pending_amt_msat, invoice_request , ..
1334
1336
} => {
1335
1337
const RETRY_OVERFLOW_PERCENTAGE : u64 = 10 ;
1336
1338
let retry_amt_msat = route. get_total_amount ( ) ;
@@ -1353,6 +1355,7 @@ impl OutboundPayments {
1353
1355
custom_tlvs : custom_tlvs. clone ( ) ,
1354
1356
} ;
1355
1357
let keysend_preimage = * keysend_preimage;
1358
+ let invoice_request = invoice_request. clone ( ) ;
1356
1359
1357
1360
let mut onion_session_privs = Vec :: with_capacity ( route. paths . len ( ) ) ;
1358
1361
for _ in 0 ..route. paths . len ( ) {
@@ -1365,7 +1368,7 @@ impl OutboundPayments {
1365
1368
1366
1369
payment. get_mut ( ) . increment_attempts ( ) ;
1367
1370
1368
- ( total_msat, recipient_onion, keysend_preimage, onion_session_privs)
1371
+ ( total_msat, recipient_onion, keysend_preimage, onion_session_privs, invoice_request )
1369
1372
} ,
1370
1373
PendingOutboundPayment :: Legacy { .. } => {
1371
1374
log_error ! ( logger, "Unable to retry payments that were initially sent on LDK versions prior to 0.0.102" ) ;
@@ -1403,8 +1406,8 @@ impl OutboundPayments {
1403
1406
}
1404
1407
} ;
1405
1408
let res = self . pay_route_internal ( & route, payment_hash, & recipient_onion, keysend_preimage,
1406
- None , payment_id, Some ( total_msat) , onion_session_privs, node_signer, best_block_height ,
1407
- & send_payment_along_path) ;
1409
+ invoice_request . as_ref ( ) , payment_id, Some ( total_msat) , onion_session_privs, node_signer,
1410
+ best_block_height , & send_payment_along_path) ;
1408
1411
log_info ! ( logger, "Result retrying payment id {}: {:?}" , & payment_id, res) ;
1409
1412
if let Err ( e) = res {
1410
1413
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) ;
@@ -1556,7 +1559,7 @@ impl OutboundPayments {
1556
1559
hash_map:: Entry :: Occupied ( _) => Err ( PaymentSendFailure :: DuplicatePayment ) ,
1557
1560
hash_map:: Entry :: Vacant ( entry) => {
1558
1561
let ( payment, onion_session_privs) = self . create_pending_payment (
1559
- payment_hash, recipient_onion, keysend_preimage, route, retry_strategy,
1562
+ payment_hash, recipient_onion, keysend_preimage, None , route, retry_strategy,
1560
1563
payment_params, entropy_source, best_block_height
1561
1564
) ;
1562
1565
entry. insert ( payment) ;
@@ -1567,8 +1570,9 @@ impl OutboundPayments {
1567
1570
1568
1571
fn create_pending_payment < ES : Deref > (
1569
1572
& self , payment_hash : PaymentHash , recipient_onion : RecipientOnionFields ,
1570
- keysend_preimage : Option < PaymentPreimage > , route : & Route , retry_strategy : Option < Retry > ,
1571
- payment_params : Option < PaymentParameters > , entropy_source : & ES , best_block_height : u32
1573
+ keysend_preimage : Option < PaymentPreimage > , invoice_request : Option < InvoiceRequest > ,
1574
+ route : & Route , retry_strategy : Option < Retry > , payment_params : Option < PaymentParameters > ,
1575
+ entropy_source : & ES , best_block_height : u32
1572
1576
) -> ( PendingOutboundPayment , Vec < [ u8 ; 32 ] > )
1573
1577
where
1574
1578
ES :: Target : EntropySource ,
@@ -1589,6 +1593,7 @@ impl OutboundPayments {
1589
1593
payment_secret : recipient_onion. payment_secret ,
1590
1594
payment_metadata : recipient_onion. payment_metadata ,
1591
1595
keysend_preimage,
1596
+ invoice_request,
1592
1597
custom_tlvs : recipient_onion. custom_tlvs ,
1593
1598
starting_block_height : best_block_height,
1594
1599
total_msat : route. get_total_amount ( ) ,
@@ -2150,6 +2155,7 @@ impl OutboundPayments {
2150
2155
payment_secret: None , // only used for retries, and we'll never retry on startup
2151
2156
payment_metadata: None , // only used for retries, and we'll never retry on startup
2152
2157
keysend_preimage: None , // only used for retries, and we'll never retry on startup
2158
+ invoice_request: None , // only used for retries, and we'll never retry on startup
2153
2159
custom_tlvs: Vec :: new( ) , // only used for retries, and we'll never retry on startup
2154
2160
pending_amt_msat: path_amt,
2155
2161
pending_fee_msat: Some ( path_fee) ,
@@ -2236,6 +2242,7 @@ impl_writeable_tlv_based_enum_upgradable!(PendingOutboundPayment,
2236
2242
( 9 , custom_tlvs, optional_vec) ,
2237
2243
( 10 , starting_block_height, required) ,
2238
2244
( 11 , remaining_max_total_routing_fee_msat, option) ,
2245
+ ( 13 , invoice_request, option) ,
2239
2246
( not_written, retry_strategy, ( static_value, None ) ) ,
2240
2247
( not_written, attempts, ( static_value, PaymentAttempts :: new( ) ) ) ,
2241
2248
} ,
0 commit comments