Skip to content

Commit 4c785b5

Browse files
committed
f adjust blinded path spec compliance
1 parent f5e5c89 commit 4c785b5

File tree

1 file changed

+13
-34
lines changed

1 file changed

+13
-34
lines changed

lightning/src/ln/msgs.rs

+13-34
Original file line numberDiff line numberDiff line change
@@ -1677,9 +1677,10 @@ pub struct FinalOnionHopData {
16771677

16781678
mod fuzzy_internal_msgs {
16791679
use bitcoin::secp256k1::PublicKey;
1680+
use crate::blinded_path::BlindedPath;
16801681
use crate::blinded_path::payment::{PaymentConstraints, PaymentContext, PaymentRelay};
16811682
use crate::ln::types::{PaymentPreimage, PaymentSecret};
1682-
use crate::ln::features::BlindedHopFeatures;
1683+
use crate::ln::features::{BlindedHopFeatures, Bolt12InvoiceFeatures};
16831684
use super::{FinalOnionHopData, TrampolineOnionPacket};
16841685

16851686
#[allow(unused_imports)]
@@ -1771,19 +1772,13 @@ mod fuzzy_internal_msgs {
17711772
},
17721773
#[allow(unused)]
17731774
BlindedForward {
1774-
encrypted_tlvs: Vec<u8>,
1775-
intro_node_blinding_point: Option<PublicKey>,
1775+
amt_to_forward: u64,
1776+
outgoing_cltv_value: u32,
1777+
// experimental TLV: 66102
1778+
payment_paths: Vec<BlindedPath>,
1779+
// experimental TLV: 66097
1780+
invoice_features: Option<Bolt12InvoiceFeatures>
17761781
},
1777-
#[allow(unused)]
1778-
BlindedReceive {
1779-
sender_intended_htlc_amt_msat: u64,
1780-
total_msat: u64,
1781-
cltv_expiry_height: u32,
1782-
encrypted_tlvs: Vec<u8>,
1783-
intro_node_blinding_point: Option<PublicKey>, // Set if the introduction node of the blinded path is the final node
1784-
keysend_preimage: Option<PaymentPreimage>,
1785-
custom_tlvs: Vec<(u64, Vec<u8>)>,
1786-
}
17871782
}
17881783

17891784
pub struct DecodedOnionErrorPacket {
@@ -2681,30 +2676,14 @@ impl Writeable for OutboundTrampolinePayload {
26812676
(14, outgoing_node_id, required)
26822677
});
26832678
},
2684-
Self::BlindedForward { encrypted_tlvs, intro_node_blinding_point } => {
2679+
Self::BlindedForward { amt_to_forward, outgoing_cltv_value, payment_paths, invoice_features } => {
26852680
_encode_varint_length_prefixed_tlv!(w, {
2686-
(10, *encrypted_tlvs, required_vec),
2687-
(12, intro_node_blinding_point, option)
2681+
(2, HighZeroBytesDroppedBigSize(*amt_to_forward), required),
2682+
(4, HighZeroBytesDroppedBigSize(*outgoing_cltv_value), required),
2683+
(66097, invoice_features, option),
2684+
(66102, *payment_paths, required_vec)
26882685
});
26892686
},
2690-
Self::BlindedReceive {
2691-
sender_intended_htlc_amt_msat, total_msat, cltv_expiry_height, encrypted_tlvs,
2692-
intro_node_blinding_point, keysend_preimage, ref custom_tlvs,
2693-
} => {
2694-
// We need to update [`ln::outbound_payment::RecipientOnionFields::with_custom_tlvs`]
2695-
// to reject any reserved types in the experimental range if new ones are ever
2696-
// standardized.
2697-
let keysend_tlv = keysend_preimage.map(|preimage| (5482373484, preimage.encode()));
2698-
let mut custom_tlvs: Vec<&(u64, Vec<u8>)> = custom_tlvs.iter().chain(keysend_tlv.iter()).collect();
2699-
custom_tlvs.sort_unstable_by_key(|(typ, _)| *typ);
2700-
_encode_varint_length_prefixed_tlv!(w, {
2701-
(2, HighZeroBytesDroppedBigSize(*sender_intended_htlc_amt_msat), required),
2702-
(4, HighZeroBytesDroppedBigSize(*cltv_expiry_height), required),
2703-
(10, *encrypted_tlvs, required_vec),
2704-
(12, intro_node_blinding_point, option),
2705-
(18, HighZeroBytesDroppedBigSize(*total_msat), required)
2706-
}, custom_tlvs.iter());
2707-
},
27082687
}
27092688
Ok(())
27102689
}

0 commit comments

Comments
 (0)