@@ -1811,7 +1811,7 @@ mod fuzzy_internal_msgs {
18111811 pub outgoing_cltv_value : u32 ,
18121812 }
18131813
1814- #[ allow ( unused ) ]
1814+ #[ cfg ( trampoline ) ]
18151815 pub struct InboundTrampolineEntrypointPayload {
18161816 pub amt_to_forward : u64 ,
18171817 pub outgoing_cltv_value : u32 ,
@@ -1853,7 +1853,7 @@ mod fuzzy_internal_msgs {
18531853
18541854 pub enum InboundOnionPayload {
18551855 Forward ( InboundOnionForwardPayload ) ,
1856- #[ allow ( unused ) ]
1856+ #[ cfg ( trampoline ) ]
18571857 TrampolineEntrypoint ( InboundTrampolineEntrypointPayload ) ,
18581858 Receive ( InboundOnionReceivePayload ) ,
18591859 BlindedForward ( InboundOnionBlindedForwardPayload ) ,
@@ -2945,12 +2945,15 @@ impl<NS: Deref> ReadableArgs<(Option<PublicKey>, NS)> for InboundOnionPayload wh
29452945 let mut payment_metadata: Option < WithoutLength < Vec < u8 > > > = None ;
29462946 let mut total_msat = None ;
29472947 let mut keysend_preimage: Option < PaymentPreimage > = None ;
2948+ #[ cfg( trampoline) ]
29482949 let mut trampoline_onion_packet: Option < TrampolineOnionPacket > = None ;
29492950 let mut invoice_request: Option < InvoiceRequest > = None ;
29502951 let mut custom_tlvs = Vec :: new ( ) ;
29512952
29522953 let tlv_len = BigSize :: read ( r) ?;
29532954 let mut rd = FixedLengthReader :: new ( r, tlv_len. 0 ) ;
2955+
2956+ #[ cfg( trampoline) ]
29542957 decode_tlv_stream_with_custom_tlv_decode ! ( & mut rd, {
29552958 ( 2 , amt, ( option, encoding: ( u64 , HighZeroBytesDroppedBigSize ) ) ) ,
29562959 ( 4 , cltv_value, ( option, encoding: ( u32 , HighZeroBytesDroppedBigSize ) ) ) ,
@@ -2971,24 +2974,47 @@ impl<NS: Deref> ReadableArgs<(Option<PublicKey>, NS)> for InboundOnionPayload wh
29712974 custom_tlvs. push( ( msg_type, value) ) ;
29722975 Ok ( true )
29732976 } ) ;
2977+ #[ cfg( not( trampoline) ) ]
2978+ decode_tlv_stream_with_custom_tlv_decode ! ( & mut rd, {
2979+ ( 2 , amt, ( option, encoding: ( u64 , HighZeroBytesDroppedBigSize ) ) ) ,
2980+ ( 4 , cltv_value, ( option, encoding: ( u32 , HighZeroBytesDroppedBigSize ) ) ) ,
2981+ ( 6 , short_id, option) ,
2982+ ( 8 , payment_data, option) ,
2983+ ( 10 , encrypted_tlvs_opt, option) ,
2984+ ( 12 , intro_node_blinding_point, option) ,
2985+ ( 16 , payment_metadata, option) ,
2986+ ( 18 , total_msat, ( option, encoding: ( u64 , HighZeroBytesDroppedBigSize ) ) ) ,
2987+ ( 77_777 , invoice_request, option) ,
2988+ // See https://github.com/lightning/blips/blob/master/blip-0003.md
2989+ ( 5482373484 , keysend_preimage, option)
2990+ } , |msg_type: u64 , msg_reader: & mut FixedLengthReader <_>| -> Result <bool , DecodeError > {
2991+ if msg_type < 1 << 16 { return Ok ( false ) }
2992+ let mut value = Vec :: new( ) ;
2993+ msg_reader. read_to_limit( & mut value, u64 :: MAX ) ?;
2994+ custom_tlvs. push( ( msg_type, value) ) ;
2995+ Ok ( true )
2996+ } ) ;
29742997
29752998 if amt. unwrap_or ( 0 ) > MAX_VALUE_MSAT { return Err ( DecodeError :: InvalidValue ) }
29762999 if intro_node_blinding_point. is_some ( ) && update_add_blinding_point. is_some ( ) {
29773000 return Err ( DecodeError :: InvalidValue )
29783001 }
29793002
3003+ #[ cfg( trampoline) ]
29803004 if let Some ( trampoline_onion_packet) = trampoline_onion_packet {
29813005 if payment_metadata. is_some ( ) || encrypted_tlvs_opt. is_some ( ) ||
29823006 total_msat. is_some ( )
29833007 { return Err ( DecodeError :: InvalidValue ) }
2984- Ok ( Self :: TrampolineEntrypoint ( InboundTrampolineEntrypointPayload {
3008+ return Ok ( Self :: TrampolineEntrypoint ( InboundTrampolineEntrypointPayload {
29853009 amt_to_forward : amt. ok_or ( DecodeError :: InvalidValue ) ?,
29863010 outgoing_cltv_value : cltv_value. ok_or ( DecodeError :: InvalidValue ) ?,
29873011 multipath_trampoline_data : payment_data,
29883012 trampoline_packet : trampoline_onion_packet,
2989- current_path_key : intro_node_blinding_point
3013+ current_path_key : intro_node_blinding_point,
29903014 } ) )
2991- } else if let Some ( blinding_point) = intro_node_blinding_point. or ( update_add_blinding_point) {
3015+ }
3016+
3017+ if let Some ( blinding_point) = intro_node_blinding_point. or ( update_add_blinding_point) {
29923018 if short_id. is_some ( ) || payment_data. is_some ( ) || payment_metadata. is_some ( ) {
29933019 return Err ( DecodeError :: InvalidValue )
29943020 }
0 commit comments