@@ -2073,6 +2073,17 @@ mod fuzzy_internal_msgs {
20732073 pub outgoing_cltv_value : u32 ,
20742074 }
20752075
2076+ #[ cfg( trampoline) ]
2077+ pub struct InboundTrampolineEntrypointPayload {
2078+ pub amt_to_forward : u64 ,
2079+ pub outgoing_cltv_value : u32 ,
2080+ pub multipath_trampoline_data : FinalOnionHopData ,
2081+ pub trampoline_packet : TrampolineOnionPacket ,
2082+ /// The blinding point this hop needs to decrypt its Trampoline onion.
2083+ /// This is used for Trampoline hops that are not the blinded path intro hop.
2084+ pub current_path_key : Option < PublicKey >
2085+ }
2086+
20762087 pub struct InboundOnionReceivePayload {
20772088 pub payment_data : Option < FinalOnionHopData > ,
20782089 pub payment_metadata : Option < Vec < u8 > > ,
@@ -2104,6 +2115,8 @@ mod fuzzy_internal_msgs {
21042115
21052116 pub enum InboundOnionPayload {
21062117 Forward ( InboundOnionForwardPayload ) ,
2118+ #[ cfg( trampoline) ]
2119+ TrampolineEntrypoint ( InboundTrampolineEntrypointPayload ) ,
21072120 Receive ( InboundOnionReceivePayload ) ,
21082121 BlindedForward ( InboundOnionBlindedForwardPayload ) ,
21092122 BlindedReceive ( InboundOnionBlindedReceivePayload ) ,
@@ -3194,11 +3207,36 @@ impl<NS: Deref> ReadableArgs<(Option<PublicKey>, NS)> for InboundOnionPayload wh
31943207 let mut payment_metadata: Option < WithoutLength < Vec < u8 > > > = None ;
31953208 let mut total_msat = None ;
31963209 let mut keysend_preimage: Option < PaymentPreimage > = None ;
3210+ #[ cfg( trampoline) ]
3211+ let mut trampoline_onion_packet: Option < TrampolineOnionPacket > = None ;
31973212 let mut invoice_request: Option < InvoiceRequest > = None ;
31983213 let mut custom_tlvs = Vec :: new ( ) ;
31993214
32003215 let tlv_len = BigSize :: read ( r) ?;
32013216 let mut rd = FixedLengthReader :: new ( r, tlv_len. 0 ) ;
3217+
3218+ #[ cfg( trampoline) ]
3219+ decode_tlv_stream_with_custom_tlv_decode ! ( & mut rd, {
3220+ ( 2 , amt, ( option, encoding: ( u64 , HighZeroBytesDroppedBigSize ) ) ) ,
3221+ ( 4 , cltv_value, ( option, encoding: ( u32 , HighZeroBytesDroppedBigSize ) ) ) ,
3222+ ( 6 , short_id, option) ,
3223+ ( 8 , payment_data, option) ,
3224+ ( 10 , encrypted_tlvs_opt, option) ,
3225+ ( 12 , intro_node_blinding_point, option) ,
3226+ ( 16 , payment_metadata, option) ,
3227+ ( 18 , total_msat, ( option, encoding: ( u64 , HighZeroBytesDroppedBigSize ) ) ) ,
3228+ ( 20 , trampoline_onion_packet, option) ,
3229+ ( 77_777 , invoice_request, option) ,
3230+ // See https://github.com/lightning/blips/blob/master/blip-0003.md
3231+ ( 5482373484 , keysend_preimage, option)
3232+ } , |msg_type: u64 , msg_reader: & mut FixedLengthReader <_>| -> Result <bool , DecodeError > {
3233+ if msg_type < 1 << 16 { return Ok ( false ) }
3234+ let mut value = Vec :: new( ) ;
3235+ msg_reader. read_to_limit( & mut value, u64 :: MAX ) ?;
3236+ custom_tlvs. push( ( msg_type, value) ) ;
3237+ Ok ( true )
3238+ } ) ;
3239+ #[ cfg( not( trampoline) ) ]
32023240 decode_tlv_stream_with_custom_tlv_decode ! ( & mut rd, {
32033241 ( 2 , amt, ( option, encoding: ( u64 , HighZeroBytesDroppedBigSize ) ) ) ,
32043242 ( 4 , cltv_value, ( option, encoding: ( u32 , HighZeroBytesDroppedBigSize ) ) ) ,
@@ -3224,6 +3262,20 @@ impl<NS: Deref> ReadableArgs<(Option<PublicKey>, NS)> for InboundOnionPayload wh
32243262 return Err ( DecodeError :: InvalidValue )
32253263 }
32263264
3265+ #[ cfg( trampoline) ]
3266+ if let Some ( trampoline_onion_packet) = trampoline_onion_packet {
3267+ if payment_metadata. is_some ( ) || encrypted_tlvs_opt. is_some ( ) ||
3268+ total_msat. is_some ( )
3269+ { return Err ( DecodeError :: InvalidValue ) }
3270+ return Ok ( Self :: TrampolineEntrypoint ( InboundTrampolineEntrypointPayload {
3271+ amt_to_forward : amt. ok_or ( DecodeError :: InvalidValue ) ?,
3272+ outgoing_cltv_value : cltv_value. ok_or ( DecodeError :: InvalidValue ) ?,
3273+ multipath_trampoline_data : payment_data. ok_or ( DecodeError :: InvalidValue ) ?,
3274+ trampoline_packet : trampoline_onion_packet,
3275+ current_path_key : intro_node_blinding_point,
3276+ } ) )
3277+ }
3278+
32273279 if let Some ( blinding_point) = intro_node_blinding_point. or ( update_add_blinding_point) {
32283280 if short_id. is_some ( ) || payment_data. is_some ( ) || payment_metadata. is_some ( ) {
32293281 return Err ( DecodeError :: InvalidValue )
0 commit comments