Skip to content

Commit 77a6c23

Browse files
Include invreq in payment onion when retrying async payments.
1 parent 93b66f6 commit 77a6c23

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
@@ -12465,6 +12465,7 @@ where
1246512465
payment_secret: None, // only used for retries, and we'll never retry on startup
1246612466
payment_metadata: None, // only used for retries, and we'll never retry on startup
1246712467
keysend_preimage: None, // only used for retries, and we'll never retry on startup
12468+
invoice_request: None, // only used for retries, and we'll never retry on startup
1246812469
custom_tlvs: Vec::new(), // only used for retries, and we'll never retry on startup
1246912470
pending_amt_msat: path_amt,
1247012471
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
@@ -86,6 +86,7 @@ pub(crate) enum PendingOutboundPayment {
8686
payment_secret: Option<PaymentSecret>,
8787
payment_metadata: Option<Vec<u8>>,
8888
keysend_preimage: Option<PaymentPreimage>,
89+
invoice_request: Option<InvoiceRequest>,
8990
custom_tlvs: Vec<(u64, Vec<u8>)>,
9091
pending_amt_msat: u64,
9192
/// Used to track the fee paid. Present iff the payment was serialized on 0.0.103+.
@@ -892,7 +893,7 @@ impl OutboundPayments {
892893

893894
let payment_params = Some(route_params.payment_params.clone());
894895
let (retryable_payment, onion_session_privs) = self.create_pending_payment(
895-
payment_hash, recipient_onion.clone(), None, &route,
896+
payment_hash, recipient_onion.clone(), None, None, &route,
896897
retry_strategy, payment_params, entropy_source, best_block_height
897898
);
898899
match self.pending_outbound_payments.lock().unwrap().entry(payment_id) {
@@ -1324,8 +1325,9 @@ impl OutboundPayments {
13241325
let retry_strategy = Some(retry_strategy);
13251326
let payment_params = Some(route_params.payment_params.clone());
13261327
let (retryable_payment, onion_session_privs) = self.create_pending_payment(
1327-
payment_hash, recipient_onion.clone(), Some(keysend_preimage), &route,
1328-
retry_strategy, payment_params, entropy_source, best_block_height
1328+
payment_hash, recipient_onion.clone(), Some(keysend_preimage),
1329+
Some(invoice_request.clone()), &route, retry_strategy, payment_params,
1330+
entropy_source, best_block_height
13291331
);
13301332
outbounds.insert(payment_id, retryable_payment);
13311333
(total_amount, recipient_onion, Some(keysend_preimage), Some(invoice_request),
@@ -1501,7 +1503,7 @@ impl OutboundPayments {
15011503
hash_map::Entry::Occupied(_) => Err(PaymentSendFailure::DuplicatePayment),
15021504
hash_map::Entry::Vacant(entry) => {
15031505
let (payment, onion_session_privs) = self.create_pending_payment(
1504-
payment_hash, recipient_onion, keysend_preimage, route, retry_strategy,
1506+
payment_hash, recipient_onion, keysend_preimage, None, route, retry_strategy,
15051507
payment_params, entropy_source, best_block_height
15061508
);
15071509
entry.insert(payment);
@@ -1512,8 +1514,9 @@ impl OutboundPayments {
15121514

15131515
fn create_pending_payment<ES: Deref>(
15141516
&self, payment_hash: PaymentHash, recipient_onion: RecipientOnionFields,
1515-
keysend_preimage: Option<PaymentPreimage>, route: &Route, retry_strategy: Option<Retry>,
1516-
payment_params: Option<PaymentParameters>, entropy_source: &ES, best_block_height: u32
1517+
keysend_preimage: Option<PaymentPreimage>, invoice_request: Option<InvoiceRequest>,
1518+
route: &Route, retry_strategy: Option<Retry>, payment_params: Option<PaymentParameters>,
1519+
entropy_source: &ES, best_block_height: u32
15171520
) -> (PendingOutboundPayment, Vec<[u8; 32]>)
15181521
where
15191522
ES::Target: EntropySource,
@@ -1534,6 +1537,7 @@ impl OutboundPayments {
15341537
payment_secret: recipient_onion.payment_secret,
15351538
payment_metadata: recipient_onion.payment_metadata,
15361539
keysend_preimage,
1540+
invoice_request,
15371541
custom_tlvs: recipient_onion.custom_tlvs,
15381542
starting_block_height: best_block_height,
15391543
total_msat: route.get_total_amount(),
@@ -2091,6 +2095,7 @@ impl_writeable_tlv_based_enum_upgradable!(PendingOutboundPayment,
20912095
(9, custom_tlvs, optional_vec),
20922096
(10, starting_block_height, required),
20932097
(11, remaining_max_total_routing_fee_msat, option),
2098+
(13, invoice_request, option),
20942099
(not_written, retry_strategy, (static_value, None)),
20952100
(not_written, attempts, (static_value, PaymentAttempts::new())),
20962101
},

0 commit comments

Comments
 (0)