@@ -1811,6 +1811,17 @@ mod fuzzy_internal_msgs {
18111811 pub outgoing_cltv_value : u32 ,
18121812 }
18131813
1814+ #[ cfg( trampoline) ]
1815+ pub struct InboundTrampolineEntrypointPayload {
1816+ pub amt_to_forward : u64 ,
1817+ pub outgoing_cltv_value : u32 ,
1818+ pub multipath_trampoline_data : Option < FinalOnionHopData > ,
1819+ pub trampoline_packet : TrampolineOnionPacket ,
1820+ /// The blinding point this hop needs to decrypt its Trampoline onion.
1821+ /// This is used for Trampoline hops that are not the blinded path intro hop.
1822+ pub current_path_key : Option < PublicKey >
1823+ }
1824+
18141825 pub struct InboundOnionReceivePayload {
18151826 pub payment_data : Option < FinalOnionHopData > ,
18161827 pub payment_metadata : Option < Vec < u8 > > ,
@@ -1842,6 +1853,8 @@ mod fuzzy_internal_msgs {
18421853
18431854 pub enum InboundOnionPayload {
18441855 Forward ( InboundOnionForwardPayload ) ,
1856+ #[ cfg( trampoline) ]
1857+ TrampolineEntrypoint ( InboundTrampolineEntrypointPayload ) ,
18451858 Receive ( InboundOnionReceivePayload ) ,
18461859 BlindedForward ( InboundOnionBlindedForwardPayload ) ,
18471860 BlindedReceive ( InboundOnionBlindedReceivePayload ) ,
@@ -2932,11 +2945,36 @@ impl<NS: Deref> ReadableArgs<(Option<PublicKey>, NS)> for InboundOnionPayload wh
29322945 let mut payment_metadata: Option < WithoutLength < Vec < u8 > > > = None ;
29332946 let mut total_msat = None ;
29342947 let mut keysend_preimage: Option < PaymentPreimage > = None ;
2948+ #[ cfg( trampoline) ]
2949+ let mut trampoline_onion_packet: Option < TrampolineOnionPacket > = None ;
29352950 let mut invoice_request: Option < InvoiceRequest > = None ;
29362951 let mut custom_tlvs = Vec :: new ( ) ;
29372952
29382953 let tlv_len = BigSize :: read ( r) ?;
29392954 let mut rd = FixedLengthReader :: new ( r, tlv_len. 0 ) ;
2955+
2956+ #[ cfg( trampoline) ]
2957+ decode_tlv_stream_with_custom_tlv_decode ! ( & mut rd, {
2958+ ( 2 , amt, ( option, encoding: ( u64 , HighZeroBytesDroppedBigSize ) ) ) ,
2959+ ( 4 , cltv_value, ( option, encoding: ( u32 , HighZeroBytesDroppedBigSize ) ) ) ,
2960+ ( 6 , short_id, option) ,
2961+ ( 8 , payment_data, option) ,
2962+ ( 10 , encrypted_tlvs_opt, option) ,
2963+ ( 12 , intro_node_blinding_point, option) ,
2964+ ( 16 , payment_metadata, option) ,
2965+ ( 18 , total_msat, ( option, encoding: ( u64 , HighZeroBytesDroppedBigSize ) ) ) ,
2966+ ( 20 , trampoline_onion_packet, option) ,
2967+ ( 77_777 , invoice_request, option) ,
2968+ // See https://github.com/lightning/blips/blob/master/blip-0003.md
2969+ ( 5482373484 , keysend_preimage, option)
2970+ } , |msg_type: u64 , msg_reader: & mut FixedLengthReader <_>| -> Result <bool , DecodeError > {
2971+ if msg_type < 1 << 16 { return Ok ( false ) }
2972+ let mut value = Vec :: new( ) ;
2973+ msg_reader. read_to_limit( & mut value, u64 :: MAX ) ?;
2974+ custom_tlvs. push( ( msg_type, value) ) ;
2975+ Ok ( true )
2976+ } ) ;
2977+ #[ cfg( not( trampoline) ) ]
29402978 decode_tlv_stream_with_custom_tlv_decode ! ( & mut rd, {
29412979 ( 2 , amt, ( option, encoding: ( u64 , HighZeroBytesDroppedBigSize ) ) ) ,
29422980 ( 4 , cltv_value, ( option, encoding: ( u32 , HighZeroBytesDroppedBigSize ) ) ) ,
@@ -2962,6 +3000,20 @@ impl<NS: Deref> ReadableArgs<(Option<PublicKey>, NS)> for InboundOnionPayload wh
29623000 return Err ( DecodeError :: InvalidValue )
29633001 }
29643002
3003+ #[ cfg( trampoline) ]
3004+ if let Some ( trampoline_onion_packet) = trampoline_onion_packet {
3005+ if payment_metadata. is_some ( ) || encrypted_tlvs_opt. is_some ( ) ||
3006+ total_msat. is_some ( )
3007+ { return Err ( DecodeError :: InvalidValue ) }
3008+ return Ok ( Self :: TrampolineEntrypoint ( InboundTrampolineEntrypointPayload {
3009+ amt_to_forward : amt. ok_or ( DecodeError :: InvalidValue ) ?,
3010+ outgoing_cltv_value : cltv_value. ok_or ( DecodeError :: InvalidValue ) ?,
3011+ multipath_trampoline_data : payment_data,
3012+ trampoline_packet : trampoline_onion_packet,
3013+ current_path_key : intro_node_blinding_point,
3014+ } ) )
3015+ }
3016+
29653017 if let Some ( blinding_point) = intro_node_blinding_point. or ( update_add_blinding_point) {
29663018 if short_id. is_some ( ) || payment_data. is_some ( ) || payment_metadata. is_some ( ) {
29673019 return Err ( DecodeError :: InvalidValue )
0 commit comments