Skip to content

Commit e8db681

Browse files
Include invreq in payment onion when retrying async payments.
1 parent 1c5e07a commit e8db681

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12326,6 +12326,7 @@ where
1232612326
payment_secret: None, // only used for retries, and we'll never retry on startup
1232712327
payment_metadata: None, // only used for retries, and we'll never retry on startup
1232812328
keysend_preimage: None, // only used for retries, and we'll never retry on startup
12329+
invoice_request: None, // only used for retries, and we'll never retry on startup
1232912330
custom_tlvs: Vec::new(), // only used for retries, and we'll never retry on startup
1233012331
pending_amt_msat: path_amt,
1233112332
pending_fee_msat: Some(path_fee),

lightning/src/ln/outbound_payment.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ pub(crate) enum PendingOutboundPayment {
8383
payment_secret: Option<PaymentSecret>,
8484
payment_metadata: Option<Vec<u8>>,
8585
keysend_preimage: Option<PaymentPreimage>,
86+
invoice_request: Option<InvoiceRequest>,
8687
custom_tlvs: Vec<(u64, Vec<u8>)>,
8788
pending_amt_msat: u64,
8889
/// Used to track the fee paid. Present iff the payment was serialized on 0.0.103+.
@@ -1225,7 +1226,7 @@ impl OutboundPayments {
12251226
let retry_strategy = Some(*retry_strategy);
12261227
let payment_params = Some(route_params.payment_params.clone());
12271228
let (retryable_payment, onion_session_privs) = self.create_pending_payment(
1228-
*payment_hash, recipient_onion.clone(), None, &route,
1229+
*payment_hash, recipient_onion.clone(), None, None, &route,
12291230
retry_strategy, payment_params, entropy_source, best_block_height
12301231
);
12311232
*payment.into_mut() = retryable_payment;
@@ -1239,8 +1240,9 @@ impl OutboundPayments {
12391240
let recipient_onion = RecipientOnionFields::spontaneous_empty();
12401241
let payment_params = Some(route_params.payment_params.clone());
12411242
let (retryable_payment, onion_session_privs) = self.create_pending_payment(
1242-
payment_hash, recipient_onion.clone(), Some(keysend_preimage), &route,
1243-
Some(retry_strategy), payment_params, entropy_source, best_block_height
1243+
payment_hash, recipient_onion.clone(), Some(keysend_preimage),
1244+
Some(invoice_request.clone()), &route, Some(retry_strategy), payment_params,
1245+
entropy_source, best_block_height
12441246
);
12451247
outbounds.insert(payment_id, retryable_payment);
12461248
(total_amount, recipient_onion, Some(keysend_preimage), Some(invoice_request),
@@ -1416,7 +1418,7 @@ impl OutboundPayments {
14161418
hash_map::Entry::Occupied(_) => Err(PaymentSendFailure::DuplicatePayment),
14171419
hash_map::Entry::Vacant(entry) => {
14181420
let (payment, onion_session_privs) = self.create_pending_payment(
1419-
payment_hash, recipient_onion, keysend_preimage, route, retry_strategy,
1421+
payment_hash, recipient_onion, keysend_preimage, None, route, retry_strategy,
14201422
payment_params, entropy_source, best_block_height
14211423
);
14221424
entry.insert(payment);
@@ -1427,8 +1429,9 @@ impl OutboundPayments {
14271429

14281430
fn create_pending_payment<ES: Deref>(
14291431
&self, payment_hash: PaymentHash, recipient_onion: RecipientOnionFields,
1430-
keysend_preimage: Option<PaymentPreimage>, route: &Route, retry_strategy: Option<Retry>,
1431-
payment_params: Option<PaymentParameters>, entropy_source: &ES, best_block_height: u32
1432+
keysend_preimage: Option<PaymentPreimage>, invoice_request: Option<InvoiceRequest>,
1433+
route: &Route, retry_strategy: Option<Retry>, payment_params: Option<PaymentParameters>,
1434+
entropy_source: &ES, best_block_height: u32
14321435
) -> (PendingOutboundPayment, Vec<[u8; 32]>)
14331436
where
14341437
ES::Target: EntropySource,
@@ -1449,6 +1452,7 @@ impl OutboundPayments {
14491452
payment_secret: recipient_onion.payment_secret,
14501453
payment_metadata: recipient_onion.payment_metadata,
14511454
keysend_preimage,
1455+
invoice_request,
14521456
custom_tlvs: recipient_onion.custom_tlvs,
14531457
starting_block_height: best_block_height,
14541458
total_msat: route.get_total_amount(),
@@ -2001,6 +2005,7 @@ impl_writeable_tlv_based_enum_upgradable!(PendingOutboundPayment,
20012005
(9, custom_tlvs, optional_vec),
20022006
(10, starting_block_height, required),
20032007
(11, remaining_max_total_routing_fee_msat, option),
2008+
(13, invoice_request, option),
20042009
(not_written, retry_strategy, (static_value, None)),
20052010
(not_written, attempts, (static_value, PaymentAttempts::new())),
20062011
},

0 commit comments

Comments
 (0)