From: Arik Sosman Date: Sun, 22 Sep 2024 14:06:05 +0000 (+0900) Subject: Add non-legacy blinded Trampoline payloads. X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=9c9a31cd35140af3fb2a9107dfedd3c5479caa41;p=rust-lightning Add non-legacy blinded Trampoline payloads. --- diff --git a/lightning/src/ln/msgs.rs b/lightning/src/ln/msgs.rs index 7d6c045bf..31f4d2466 100644 --- a/lightning/src/ln/msgs.rs +++ b/lightning/src/ln/msgs.rs @@ -1830,7 +1830,7 @@ mod fuzzy_internal_msgs { } } - pub(crate) enum OutboundTrampolinePayload { + pub(crate) enum OutboundTrampolinePayload<'a> { #[allow(unused)] Forward { /// The value, in msat, of the payment after this hop's fee is deducted. @@ -1851,6 +1851,21 @@ mod fuzzy_internal_msgs { /// If applicable, features of the BOLT12 invoice being paid. invoice_features: Option, }, + #[allow(unused)] + BlindedForward { + encrypted_tlvs: &'a Vec, + intro_node_blinding_point: Option, + }, + #[allow(unused)] + BlindedReceive { + sender_intended_htlc_amt_msat: u64, + total_msat: u64, + cltv_expiry_height: u32, + encrypted_tlvs: &'a Vec, + intro_node_blinding_point: Option, // Set if the introduction node of the blinded path is the final node + keysend_preimage: Option, + custom_tlvs: &'a Vec<(u64, Vec)>, + } } pub struct DecodedOnionErrorPacket { @@ -2766,7 +2781,7 @@ impl<'a> Writeable for OutboundOnionPayload<'a> { } } -impl Writeable for OutboundTrampolinePayload { +impl<'a> Writeable for OutboundTrampolinePayload<'a> { fn write(&self, w: &mut W) -> Result<(), io::Error> { match self { Self::Forward { amt_to_forward, outgoing_cltv_value, outgoing_node_id } => { @@ -2795,6 +2810,22 @@ impl Writeable for OutboundTrampolinePayload { (22, WithoutLength(blinded_path_serialization), required) }); }, + Self::BlindedForward { encrypted_tlvs, intro_node_blinding_point} => { + _encode_varint_length_prefixed_tlv!(w, { + (10, **encrypted_tlvs, required_vec), + (12, intro_node_blinding_point, option) + }); + }, + Self::BlindedReceive { sender_intended_htlc_amt_msat, total_msat, cltv_expiry_height, encrypted_tlvs, intro_node_blinding_point, keysend_preimage, custom_tlvs } => { + _encode_varint_length_prefixed_tlv!(w, { + (2, HighZeroBytesDroppedBigSize(*sender_intended_htlc_amt_msat), required), + (4, HighZeroBytesDroppedBigSize(*cltv_expiry_height), required), + (10, **encrypted_tlvs, required_vec), + (12, intro_node_blinding_point, option), + (18, HighZeroBytesDroppedBigSize(*total_msat), required), + (20, keysend_preimage, option) + }, custom_tlvs.iter()); + } } Ok(()) }