@@ -1746,9 +1746,9 @@ pub struct FinalOnionHopData {
17461746
17471747mod fuzzy_internal_msgs {
17481748 use bitcoin:: secp256k1:: PublicKey ;
1749- use crate :: blinded_path:: payment:: { PaymentConstraints , PaymentContext , PaymentRelay } ;
1749+ use crate :: blinded_path:: payment:: { BlindedPaymentPath , PaymentConstraints , PaymentContext , PaymentRelay } ;
17501750 use crate :: types:: payment:: { PaymentPreimage , PaymentSecret } ;
1751- use crate :: types:: features:: BlindedHopFeatures ;
1751+ use crate :: types:: features:: { BlindedHopFeatures , Bolt12InvoiceFeatures } ;
17521752 use super :: { FinalOnionHopData , TrampolineOnionPacket } ;
17531753
17541754 #[ allow( unused_imports) ]
@@ -1836,9 +1836,21 @@ mod fuzzy_internal_msgs {
18361836 /// The value, in msat, of the payment after this hop's fee is deducted.
18371837 amt_to_forward : u64 ,
18381838 outgoing_cltv_value : u32 ,
1839- /// The node id to which the trampoline node must find a route
1839+ /// The node id to which the trampoline node must find a route.
18401840 outgoing_node_id : PublicKey ,
1841- }
1841+ } ,
1842+ #[ allow( unused) ]
1843+ /// This is the last Trampoline hop, whereupon the Trampoline forward mechanism is exited,
1844+ /// and payment data is relayed using non-Trampoline blinded hops
1845+ LegacyBlindedPathEntry {
1846+ /// The value, in msat, of the payment after this hop's fee is deducted.
1847+ amt_to_forward : u64 ,
1848+ outgoing_cltv_value : u32 ,
1849+ /// List of blinded path options the last trampoline hop may choose to route through.
1850+ payment_paths : Vec < BlindedPaymentPath > ,
1851+ /// If applicable, features of the BOLT12 invoice being paid.
1852+ invoice_features : Option < Bolt12InvoiceFeatures > ,
1853+ } ,
18421854 }
18431855
18441856 pub struct DecodedOnionErrorPacket {
@@ -2763,7 +2775,25 @@ impl Writeable for OutboundTrampolinePayload {
27632775 ( 4 , HighZeroBytesDroppedBigSize ( * outgoing_cltv_value) , required) ,
27642776 ( 14 , outgoing_node_id, required)
27652777 } ) ;
2766- }
2778+ } ,
2779+ Self :: LegacyBlindedPathEntry { amt_to_forward, outgoing_cltv_value, payment_paths, invoice_features } => {
2780+ let mut blinded_path_serialization = [ 0u8 ; 2048 ] ; // Fixed-length buffer on the stack
2781+ let serialization_length = {
2782+ let mut blinded_path_slice = & mut blinded_path_serialization[ ..] ;
2783+ for current_payment_path in payment_paths {
2784+ current_payment_path. inner_blinded_path ( ) . write ( & mut blinded_path_slice) ?;
2785+ current_payment_path. payinfo . write ( & mut blinded_path_slice) ?;
2786+ }
2787+ 2048 - blinded_path_slice. len ( )
2788+ } ;
2789+ let blinded_path_serialization = & blinded_path_serialization[ ..serialization_length] ;
2790+ _encode_varint_length_prefixed_tlv ! ( w, {
2791+ ( 2 , HighZeroBytesDroppedBigSize ( * amt_to_forward) , required) ,
2792+ ( 4 , HighZeroBytesDroppedBigSize ( * outgoing_cltv_value) , required) ,
2793+ ( 21 , invoice_features. as_ref( ) . map( |m| WithoutLength ( m) ) , option) ,
2794+ ( 22 , WithoutLength ( blinded_path_serialization) , required)
2795+ } ) ;
2796+ } ,
27672797 }
27682798 Ok ( ( ) )
27692799 }
0 commit comments