Skip to content

Commit 5dedfea

Browse files
Support encoding invreqs in outbound onion payloads.
1 parent 1261b19 commit 5dedfea

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

lightning/src/ln/max_payment_path_len_tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ fn one_hop_blinded_path_with_custom_tlv() {
184184
encrypted_tlvs: &blinded_path.blinded_hops()[0].encrypted_payload,
185185
intro_node_blinding_point: Some(blinded_path.blinding_point()),
186186
keysend_preimage: None,
187+
invoice_request: None,
187188
custom_tlvs: &Vec::new()
188189
}.serialized_length();
189190
let max_custom_tlv_len = 1300

lightning/src/ln/msgs.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,6 +1735,7 @@ mod fuzzy_internal_msgs {
17351735
use crate::blinded_path::payment::{PaymentConstraints, PaymentContext, PaymentRelay};
17361736
use crate::ln::types::{PaymentPreimage, PaymentSecret};
17371737
use crate::ln::features::BlindedHopFeatures;
1738+
use crate::offers::invoice_request::InvoiceRequest;
17381739
use super::{FinalOnionHopData, TrampolineOnionPacket};
17391740

17401741
#[allow(unused_imports)]
@@ -1813,6 +1814,7 @@ mod fuzzy_internal_msgs {
18131814
intro_node_blinding_point: Option<PublicKey>, // Set if the introduction node of the blinded path is the final node
18141815
keysend_preimage: Option<PaymentPreimage>,
18151816
custom_tlvs: &'a Vec<(u64, Vec<u8>)>,
1817+
invoice_request: Option<&'a InvoiceRequest>,
18161818
}
18171819
}
18181820

@@ -2719,13 +2721,17 @@ impl<'a> Writeable for OutboundOnionPayload<'a> {
27192721
},
27202722
Self::BlindedReceive {
27212723
sender_intended_htlc_amt_msat, total_msat, cltv_expiry_height, encrypted_tlvs,
2722-
intro_node_blinding_point, keysend_preimage, ref custom_tlvs,
2724+
intro_node_blinding_point, keysend_preimage, ref invoice_request, ref custom_tlvs,
27232725
} => {
27242726
// We need to update [`ln::outbound_payment::RecipientOnionFields::with_custom_tlvs`]
27252727
// to reject any reserved types in the experimental range if new ones are ever
27262728
// standardized.
2729+
let invoice_request_tlv = invoice_request.map(|invreq| (77_777, invreq.encode()));
27272730
let keysend_tlv = keysend_preimage.map(|preimage| (5482373484, preimage.encode()));
2728-
let mut custom_tlvs: Vec<&(u64, Vec<u8>)> = custom_tlvs.iter().chain(keysend_tlv.iter()).collect();
2731+
let mut custom_tlvs: Vec<&(u64, Vec<u8>)> = custom_tlvs.iter()
2732+
.chain(invoice_request_tlv.iter())
2733+
.chain(keysend_tlv.iter())
2734+
.collect();
27292735
custom_tlvs.sort_unstable_by_key(|(typ, _)| *typ);
27302736
_encode_varint_length_prefixed_tlv!(w, {
27312737
(2, HighZeroBytesDroppedBigSize(*sender_intended_htlc_amt_msat), required),

lightning/src/ln/onion_utils.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ where
262262
encrypted_tlvs: &blinded_hop.encrypted_payload,
263263
intro_node_blinding_point: blinding_point.take(),
264264
keysend_preimage: *keysend_preimage,
265+
invoice_request: None,
265266
custom_tlvs: &recipient_onion.custom_tlvs,
266267
},
267268
);

0 commit comments

Comments
 (0)