Skip to content

Commit 2f40163

Browse files
Include invreq in payment onion when retrying async payments.
1 parent 883a370 commit 2f40163

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
@@ -12387,6 +12387,7 @@ where
1238712387
payment_secret: None, // only used for retries, and we'll never retry on startup
1238812388
payment_metadata: None, // only used for retries, and we'll never retry on startup
1238912389
keysend_preimage: None, // only used for retries, and we'll never retry on startup
12390+
invoice_request: None, // only used for retries, and we'll never retry on startup
1239012391
custom_tlvs: Vec::new(), // only used for retries, and we'll never retry on startup
1239112392
pending_amt_msat: path_amt,
1239212393
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+.
@@ -910,7 +911,7 @@ impl OutboundPayments {
910911

911912
let payment_params = Some(route_params.payment_params.clone());
912913
let (retryable_payment, onion_session_privs) = self.create_pending_payment(
913-
payment_hash, recipient_onion.clone(), None, &route,
914+
payment_hash, recipient_onion.clone(), None, None, &route,
914915
retry_strategy, payment_params, entropy_source, best_block_height
915916
);
916917
match self.pending_outbound_payments.lock().unwrap().entry(payment_id) {
@@ -1308,8 +1309,9 @@ impl OutboundPayments {
13081309
let retry_strategy = Some(retry_strategy);
13091310
let payment_params = Some(route_params.payment_params.clone());
13101311
let (retryable_payment, onion_session_privs) = self.create_pending_payment(
1311-
payment_hash, recipient_onion.clone(), Some(keysend_preimage), &route,
1312-
retry_strategy, payment_params, entropy_source, best_block_height
1312+
payment_hash, recipient_onion.clone(), Some(keysend_preimage),
1313+
Some(invoice_request.clone()), &route, retry_strategy, payment_params,
1314+
entropy_source, best_block_height
13131315
);
13141316
outbounds.insert(payment_id, retryable_payment);
13151317
(total_amount, recipient_onion, Some(keysend_preimage), Some(invoice_request),
@@ -1485,7 +1487,7 @@ impl OutboundPayments {
14851487
hash_map::Entry::Occupied(_) => Err(PaymentSendFailure::DuplicatePayment),
14861488
hash_map::Entry::Vacant(entry) => {
14871489
let (payment, onion_session_privs) = self.create_pending_payment(
1488-
payment_hash, recipient_onion, keysend_preimage, route, retry_strategy,
1490+
payment_hash, recipient_onion, keysend_preimage, None, route, retry_strategy,
14891491
payment_params, entropy_source, best_block_height
14901492
);
14911493
entry.insert(payment);
@@ -1496,8 +1498,9 @@ impl OutboundPayments {
14961498

14971499
fn create_pending_payment<ES: Deref>(
14981500
&self, payment_hash: PaymentHash, recipient_onion: RecipientOnionFields,
1499-
keysend_preimage: Option<PaymentPreimage>, route: &Route, retry_strategy: Option<Retry>,
1500-
payment_params: Option<PaymentParameters>, entropy_source: &ES, best_block_height: u32
1501+
keysend_preimage: Option<PaymentPreimage>, invoice_request: Option<InvoiceRequest>,
1502+
route: &Route, retry_strategy: Option<Retry>, payment_params: Option<PaymentParameters>,
1503+
entropy_source: &ES, best_block_height: u32
15011504
) -> (PendingOutboundPayment, Vec<[u8; 32]>)
15021505
where
15031506
ES::Target: EntropySource,
@@ -1518,6 +1521,7 @@ impl OutboundPayments {
15181521
payment_secret: recipient_onion.payment_secret,
15191522
payment_metadata: recipient_onion.payment_metadata,
15201523
keysend_preimage,
1524+
invoice_request,
15211525
custom_tlvs: recipient_onion.custom_tlvs,
15221526
starting_block_height: best_block_height,
15231527
total_msat: route.get_total_amount(),
@@ -2075,6 +2079,7 @@ impl_writeable_tlv_based_enum_upgradable!(PendingOutboundPayment,
20752079
(9, custom_tlvs, optional_vec),
20762080
(10, starting_block_height, required),
20772081
(11, remaining_max_total_routing_fee_msat, option),
2082+
(13, invoice_request, option),
20782083
(not_written, retry_strategy, (static_value, None)),
20792084
(not_written, attempts, (static_value, PaymentAttempts::new())),
20802085
},

0 commit comments

Comments
 (0)