@@ -1811,6 +1811,17 @@ mod fuzzy_internal_msgs {
1811
1811
pub outgoing_cltv_value : u32 ,
1812
1812
}
1813
1813
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
+
1814
1825
pub struct InboundOnionReceivePayload {
1815
1826
pub payment_data : Option < FinalOnionHopData > ,
1816
1827
pub payment_metadata : Option < Vec < u8 > > ,
@@ -1842,6 +1853,8 @@ mod fuzzy_internal_msgs {
1842
1853
1843
1854
pub enum InboundOnionPayload {
1844
1855
Forward ( InboundOnionForwardPayload ) ,
1856
+ #[ cfg( trampoline) ]
1857
+ TrampolineEntrypoint ( InboundTrampolineEntrypointPayload ) ,
1845
1858
Receive ( InboundOnionReceivePayload ) ,
1846
1859
BlindedForward ( InboundOnionBlindedForwardPayload ) ,
1847
1860
BlindedReceive ( InboundOnionBlindedReceivePayload ) ,
@@ -2932,11 +2945,36 @@ impl<NS: Deref> ReadableArgs<(Option<PublicKey>, NS)> for InboundOnionPayload wh
2932
2945
let mut payment_metadata: Option < WithoutLength < Vec < u8 > > > = None ;
2933
2946
let mut total_msat = None ;
2934
2947
let mut keysend_preimage: Option < PaymentPreimage > = None ;
2948
+ #[ cfg( trampoline) ]
2949
+ let mut trampoline_onion_packet: Option < TrampolineOnionPacket > = None ;
2935
2950
let mut invoice_request: Option < InvoiceRequest > = None ;
2936
2951
let mut custom_tlvs = Vec :: new ( ) ;
2937
2952
2938
2953
let tlv_len = BigSize :: read ( r) ?;
2939
2954
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) ) ]
2940
2978
decode_tlv_stream_with_custom_tlv_decode ! ( & mut rd, {
2941
2979
( 2 , amt, ( option, encoding: ( u64 , HighZeroBytesDroppedBigSize ) ) ) ,
2942
2980
( 4 , cltv_value, ( option, encoding: ( u32 , HighZeroBytesDroppedBigSize ) ) ) ,
@@ -2962,6 +3000,20 @@ impl<NS: Deref> ReadableArgs<(Option<PublicKey>, NS)> for InboundOnionPayload wh
2962
3000
return Err ( DecodeError :: InvalidValue )
2963
3001
}
2964
3002
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
+
2965
3017
if let Some ( blinding_point) = intro_node_blinding_point. or ( update_add_blinding_point) {
2966
3018
if short_id. is_some ( ) || payment_data. is_some ( ) || payment_metadata. is_some ( ) {
2967
3019
return Err ( DecodeError :: InvalidValue )
0 commit comments