@@ -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 } => {
@@ -2788,6 +2803,24 @@ impl Writeable for OutboundTrampolinePayload {
27882803 ( 21 , invoice_features. as_ref( ) . map( |m| WithoutLength ( m) ) , option)
27892804 } , [ & blinded_path_tlv] ) ;
27902805 } ,
2806+ Self :: BlindedForward { encrypted_tlvs, intro_node_blinding_point} => {
2807+ _encode_varint_length_prefixed_tlv ! ( w, {
2808+ ( 10 , * * encrypted_tlvs, required_vec) ,
2809+ ( 12 , intro_node_blinding_point, option)
2810+ } ) ;
2811+ } ,
2812+ Self :: BlindedReceive { sender_intended_htlc_amt_msat, total_msat, cltv_expiry_height, encrypted_tlvs, intro_node_blinding_point, keysend_preimage, custom_tlvs } => {
2813+ let keysend_tlv = keysend_preimage. map ( |preimage| ( 5482373484 , preimage. encode ( ) ) ) ;
2814+ let mut custom_tlvs: Vec < & ( u64 , Vec < u8 > ) > = custom_tlvs. iter ( ) . chain ( keysend_tlv. iter ( ) ) . collect ( ) ;
2815+ custom_tlvs. sort_unstable_by_key ( |( typ, _) | * typ) ;
2816+ _encode_varint_length_prefixed_tlv ! ( w, {
2817+ ( 2 , HighZeroBytesDroppedBigSize ( * sender_intended_htlc_amt_msat) , required) ,
2818+ ( 4 , HighZeroBytesDroppedBigSize ( * cltv_expiry_height) , required) ,
2819+ ( 10 , * * encrypted_tlvs, required_vec) ,
2820+ ( 12 , intro_node_blinding_point, option) ,
2821+ ( 18 , HighZeroBytesDroppedBigSize ( * total_msat) , required)
2822+ } , custom_tlvs. iter( ) ) ;
2823+ }
27912824 }
27922825 Ok ( ( ) )
27932826 }
0 commit comments