Skip to content

Commit 7f10c22

Browse files
committed
Add non-legacy blinded Trampoline payloads.
1 parent a2f4483 commit 7f10c22

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

lightning/src/ln/msgs.rs

+33-2
Original file line numberDiff line numberDiff line change
@@ -1830,7 +1830,7 @@ mod fuzzy_internal_msgs {
18301830
}
18311831
}
18321832

1833-
pub(crate) enum OutboundTrampolinePayload {
1833+
pub(crate) enum OutboundTrampolinePayload<'a> {
18341834
#[allow(unused)]
18351835
Forward {
18361836
/// The value, in msat, of the payment after this hop's fee is deducted.
@@ -1851,6 +1851,21 @@ mod fuzzy_internal_msgs {
18511851
/// If applicable, features of the BOLT12 invoice being paid.
18521852
invoice_features: Option<Bolt12InvoiceFeatures>,
18531853
},
1854+
#[allow(unused)]
1855+
BlindedForward {
1856+
encrypted_tlvs: &'a Vec<u8>,
1857+
intro_node_blinding_point: Option<PublicKey>,
1858+
},
1859+
#[allow(unused)]
1860+
BlindedReceive {
1861+
sender_intended_htlc_amt_msat: u64,
1862+
total_msat: u64,
1863+
cltv_expiry_height: u32,
1864+
encrypted_tlvs: &'a Vec<u8>,
1865+
intro_node_blinding_point: Option<PublicKey>, // Set if the introduction node of the blinded path is the final node
1866+
keysend_preimage: Option<PaymentPreimage>,
1867+
custom_tlvs: &'a Vec<(u64, Vec<u8>)>,
1868+
}
18541869
}
18551870

18561871
pub struct DecodedOnionErrorPacket {
@@ -2766,7 +2781,7 @@ impl<'a> Writeable for OutboundOnionPayload<'a> {
27662781
}
27672782
}
27682783

2769-
impl Writeable for OutboundTrampolinePayload {
2784+
impl<'a> Writeable for OutboundTrampolinePayload<'a> {
27702785
fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
27712786
match self {
27722787
Self::Forward { amt_to_forward, outgoing_cltv_value, outgoing_node_id } => {
@@ -2794,6 +2809,22 @@ impl Writeable for OutboundTrampolinePayload {
27942809
(22, WithoutLength(blinded_path_serialization), required)
27952810
});
27962811
},
2812+
Self::BlindedForward { encrypted_tlvs, intro_node_blinding_point} => {
2813+
_encode_varint_length_prefixed_tlv!(w, {
2814+
(10, **encrypted_tlvs, required_vec),
2815+
(12, intro_node_blinding_point, option)
2816+
});
2817+
},
2818+
Self::BlindedReceive { sender_intended_htlc_amt_msat, total_msat, cltv_expiry_height, encrypted_tlvs, intro_node_blinding_point, keysend_preimage, custom_tlvs } => {
2819+
_encode_varint_length_prefixed_tlv!(w, {
2820+
(2, HighZeroBytesDroppedBigSize(*sender_intended_htlc_amt_msat), required),
2821+
(4, HighZeroBytesDroppedBigSize(*cltv_expiry_height), required),
2822+
(10, **encrypted_tlvs, required_vec),
2823+
(12, intro_node_blinding_point, option),
2824+
(18, HighZeroBytesDroppedBigSize(*total_msat), required),
2825+
(20, keysend_preimage, option)
2826+
}, custom_tlvs.iter());
2827+
}
27972828
}
27982829
Ok(())
27992830
}

0 commit comments

Comments
 (0)