Skip to content

Commit d2e9cb4

Browse files
committed
Add custom tlvs to PendingOutboundPayment::Retryable
1 parent 039b1c8 commit d2e9cb4

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8751,6 +8751,7 @@ where
87518751
payment_secret: None, // only used for retries, and we'll never retry on startup
87528752
payment_metadata: None, // only used for retries, and we'll never retry on startup
87538753
keysend_preimage: None, // only used for retries, and we'll never retry on startup
8754+
custom_tlvs: Vec::new(), // only used for retries, and we'll never retry on startup
87548755
pending_amt_msat: path_amt,
87558756
pending_fee_msat: Some(path_fee),
87568757
total_msat: path_amt,

lightning/src/ln/outbound_payment.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ pub(crate) enum PendingOutboundPayment {
4747
payment_secret: Option<PaymentSecret>,
4848
payment_metadata: Option<Vec<u8>>,
4949
keysend_preimage: Option<PaymentPreimage>,
50+
custom_tlvs: Vec<(u64, Vec<u8>)>,
5051
pending_amt_msat: u64,
5152
/// Used to track the fee paid. Only present if the payment was serialized on 0.0.103+.
5253
pending_fee_msat: Option<u64>,
@@ -804,7 +805,8 @@ impl OutboundPayments {
804805
hash_map::Entry::Occupied(mut payment) => {
805806
let res = match payment.get() {
806807
PendingOutboundPayment::Retryable {
807-
total_msat, keysend_preimage, payment_secret, payment_metadata, pending_amt_msat, ..
808+
total_msat, keysend_preimage, payment_secret, payment_metadata,
809+
custom_tlvs, pending_amt_msat, ..
808810
} => {
809811
let retry_amt_msat = route.get_total_amount();
810812
if retry_amt_msat + *pending_amt_msat > *total_msat * (100 + RETRY_OVERFLOW_PERCENTAGE) / 100 {
@@ -815,7 +817,7 @@ impl OutboundPayments {
815817
(*total_msat, RecipientOnionFields {
816818
payment_secret: *payment_secret,
817819
payment_metadata: payment_metadata.clone(),
818-
custom_tlvs: Vec::new(),
820+
custom_tlvs: custom_tlvs.clone(),
819821
}, *keysend_preimage)
820822
},
821823
PendingOutboundPayment::Legacy { .. } => {
@@ -1014,6 +1016,7 @@ impl OutboundPayments {
10141016
payment_secret: recipient_onion.payment_secret,
10151017
payment_metadata: recipient_onion.payment_metadata,
10161018
keysend_preimage,
1019+
custom_tlvs: recipient_onion.custom_tlvs,
10171020
starting_block_height: best_block_height,
10181021
total_msat: route.get_total_amount(),
10191022
});
@@ -1463,6 +1466,7 @@ impl_writeable_tlv_based_enum_upgradable!(PendingOutboundPayment,
14631466
(6, total_msat, required),
14641467
(7, payment_metadata, option),
14651468
(8, pending_amt_msat, required),
1469+
(9, custom_tlvs, optional_vec),
14661470
(10, starting_block_height, required),
14671471
(not_written, retry_strategy, (static_value, None)),
14681472
(not_written, attempts, (static_value, PaymentAttempts::new())),

0 commit comments

Comments
 (0)