Skip to content

Commit 0d14066

Browse files
Include invreq in payment onion when retrying async payments.
1 parent b5192a7 commit 0d14066

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+.
@@ -900,7 +901,7 @@ impl OutboundPayments {
900901

901902
let payment_params = Some(route_params.payment_params.clone());
902903
let (retryable_payment, onion_session_privs) = self.create_pending_payment(
903-
payment_hash, recipient_onion.clone(), None, &route,
904+
payment_hash, recipient_onion.clone(), None, None, &route,
904905
retry_strategy, payment_params, entropy_source, best_block_height
905906
);
906907
match self.pending_outbound_payments.lock().unwrap().entry(payment_id) {
@@ -1297,8 +1298,9 @@ impl OutboundPayments {
12971298
let recipient_onion = RecipientOnionFields::spontaneous_empty();
12981299
let payment_params = Some(route_params.payment_params.clone());
12991300
let (retryable_payment, onion_session_privs) = self.create_pending_payment(
1300-
payment_hash, recipient_onion.clone(), Some(keysend_preimage), &route,
1301-
Some(retry_strategy), payment_params, entropy_source, best_block_height
1301+
payment_hash, recipient_onion.clone(), Some(keysend_preimage),
1302+
Some(invoice_request.clone()), &route, Some(retry_strategy), payment_params,
1303+
entropy_source, best_block_height
13021304
);
13031305
outbounds.insert(payment_id, retryable_payment);
13041306
(total_amount, recipient_onion, Some(keysend_preimage), Some(invoice_request),
@@ -1474,7 +1476,7 @@ impl OutboundPayments {
14741476
hash_map::Entry::Occupied(_) => Err(PaymentSendFailure::DuplicatePayment),
14751477
hash_map::Entry::Vacant(entry) => {
14761478
let (payment, onion_session_privs) = self.create_pending_payment(
1477-
payment_hash, recipient_onion, keysend_preimage, route, retry_strategy,
1479+
payment_hash, recipient_onion, keysend_preimage, None, route, retry_strategy,
14781480
payment_params, entropy_source, best_block_height
14791481
);
14801482
entry.insert(payment);
@@ -1485,8 +1487,9 @@ impl OutboundPayments {
14851487

14861488
fn create_pending_payment<ES: Deref>(
14871489
&self, payment_hash: PaymentHash, recipient_onion: RecipientOnionFields,
1488-
keysend_preimage: Option<PaymentPreimage>, route: &Route, retry_strategy: Option<Retry>,
1489-
payment_params: Option<PaymentParameters>, entropy_source: &ES, best_block_height: u32
1490+
keysend_preimage: Option<PaymentPreimage>, invoice_request: Option<InvoiceRequest>,
1491+
route: &Route, retry_strategy: Option<Retry>, payment_params: Option<PaymentParameters>,
1492+
entropy_source: &ES, best_block_height: u32
14901493
) -> (PendingOutboundPayment, Vec<[u8; 32]>)
14911494
where
14921495
ES::Target: EntropySource,
@@ -1507,6 +1510,7 @@ impl OutboundPayments {
15071510
payment_secret: recipient_onion.payment_secret,
15081511
payment_metadata: recipient_onion.payment_metadata,
15091512
keysend_preimage,
1513+
invoice_request,
15101514
custom_tlvs: recipient_onion.custom_tlvs,
15111515
starting_block_height: best_block_height,
15121516
total_msat: route.get_total_amount(),
@@ -2059,6 +2063,7 @@ impl_writeable_tlv_based_enum_upgradable!(PendingOutboundPayment,
20592063
(9, custom_tlvs, optional_vec),
20602064
(10, starting_block_height, required),
20612065
(11, remaining_max_total_routing_fee_msat, option),
2066+
(13, invoice_request, option),
20622067
(not_written, retry_strategy, (static_value, None)),
20632068
(not_written, attempts, (static_value, PaymentAttempts::new())),
20642069
},

0 commit comments

Comments
 (0)