@@ -1811,7 +1811,7 @@ mod fuzzy_internal_msgs {
1811
1811
pub outgoing_cltv_value : u32 ,
1812
1812
}
1813
1813
1814
- #[ allow ( unused ) ]
1814
+ #[ cfg ( trampoline ) ]
1815
1815
pub struct InboundTrampolineEntrypointPayload {
1816
1816
pub amt_to_forward : u64 ,
1817
1817
pub outgoing_cltv_value : u32 ,
@@ -1853,7 +1853,7 @@ mod fuzzy_internal_msgs {
1853
1853
1854
1854
pub enum InboundOnionPayload {
1855
1855
Forward ( InboundOnionForwardPayload ) ,
1856
- #[ allow ( unused ) ]
1856
+ #[ cfg ( trampoline ) ]
1857
1857
TrampolineEntrypoint ( InboundTrampolineEntrypointPayload ) ,
1858
1858
Receive ( InboundOnionReceivePayload ) ,
1859
1859
BlindedForward ( InboundOnionBlindedForwardPayload ) ,
@@ -2945,12 +2945,15 @@ impl<NS: Deref> ReadableArgs<(Option<PublicKey>, NS)> for InboundOnionPayload wh
2945
2945
let mut payment_metadata: Option < WithoutLength < Vec < u8 > > > = None ;
2946
2946
let mut total_msat = None ;
2947
2947
let mut keysend_preimage: Option < PaymentPreimage > = None ;
2948
+ #[ cfg( trampoline) ]
2948
2949
let mut trampoline_onion_packet: Option < TrampolineOnionPacket > = None ;
2949
2950
let mut invoice_request: Option < InvoiceRequest > = None ;
2950
2951
let mut custom_tlvs = Vec :: new ( ) ;
2951
2952
2952
2953
let tlv_len = BigSize :: read ( r) ?;
2953
2954
let mut rd = FixedLengthReader :: new ( r, tlv_len. 0 ) ;
2955
+
2956
+ #[ cfg( trampoline) ]
2954
2957
decode_tlv_stream_with_custom_tlv_decode ! ( & mut rd, {
2955
2958
( 2 , amt, ( option, encoding: ( u64 , HighZeroBytesDroppedBigSize ) ) ) ,
2956
2959
( 4 , cltv_value, ( option, encoding: ( u32 , HighZeroBytesDroppedBigSize ) ) ) ,
@@ -2971,24 +2974,47 @@ impl<NS: Deref> ReadableArgs<(Option<PublicKey>, NS)> for InboundOnionPayload wh
2971
2974
custom_tlvs. push( ( msg_type, value) ) ;
2972
2975
Ok ( true )
2973
2976
} ) ;
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
+ } ) ;
2974
2997
2975
2998
if amt. unwrap_or ( 0 ) > MAX_VALUE_MSAT { return Err ( DecodeError :: InvalidValue ) }
2976
2999
if intro_node_blinding_point. is_some ( ) && update_add_blinding_point. is_some ( ) {
2977
3000
return Err ( DecodeError :: InvalidValue )
2978
3001
}
2979
3002
3003
+ #[ cfg( trampoline) ]
2980
3004
if let Some ( trampoline_onion_packet) = trampoline_onion_packet {
2981
3005
if payment_metadata. is_some ( ) || encrypted_tlvs_opt. is_some ( ) ||
2982
3006
total_msat. is_some ( )
2983
3007
{ return Err ( DecodeError :: InvalidValue ) }
2984
- Ok ( Self :: TrampolineEntrypoint ( InboundTrampolineEntrypointPayload {
3008
+ return Ok ( Self :: TrampolineEntrypoint ( InboundTrampolineEntrypointPayload {
2985
3009
amt_to_forward : amt. ok_or ( DecodeError :: InvalidValue ) ?,
2986
3010
outgoing_cltv_value : cltv_value. ok_or ( DecodeError :: InvalidValue ) ?,
2987
3011
multipath_trampoline_data : payment_data,
2988
3012
trampoline_packet : trampoline_onion_packet,
2989
- current_path_key : intro_node_blinding_point
3013
+ current_path_key : intro_node_blinding_point,
2990
3014
} ) )
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) {
2992
3018
if short_id. is_some ( ) || payment_data. is_some ( ) || payment_metadata. is_some ( ) {
2993
3019
return Err ( DecodeError :: InvalidValue )
2994
3020
}
0 commit comments