@@ -2073,6 +2073,17 @@ mod fuzzy_internal_msgs {
2073
2073
pub outgoing_cltv_value : u32 ,
2074
2074
}
2075
2075
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
+
2076
2087
pub struct InboundOnionReceivePayload {
2077
2088
pub payment_data : Option < FinalOnionHopData > ,
2078
2089
pub payment_metadata : Option < Vec < u8 > > ,
@@ -2104,6 +2115,8 @@ mod fuzzy_internal_msgs {
2104
2115
2105
2116
pub enum InboundOnionPayload {
2106
2117
Forward ( InboundOnionForwardPayload ) ,
2118
+ #[ cfg( trampoline) ]
2119
+ TrampolineEntrypoint ( InboundTrampolineEntrypointPayload ) ,
2107
2120
Receive ( InboundOnionReceivePayload ) ,
2108
2121
BlindedForward ( InboundOnionBlindedForwardPayload ) ,
2109
2122
BlindedReceive ( InboundOnionBlindedReceivePayload ) ,
@@ -3194,11 +3207,36 @@ impl<NS: Deref> ReadableArgs<(Option<PublicKey>, NS)> for InboundOnionPayload wh
3194
3207
let mut payment_metadata: Option < WithoutLength < Vec < u8 > > > = None ;
3195
3208
let mut total_msat = None ;
3196
3209
let mut keysend_preimage: Option < PaymentPreimage > = None ;
3210
+ #[ cfg( trampoline) ]
3211
+ let mut trampoline_onion_packet: Option < TrampolineOnionPacket > = None ;
3197
3212
let mut invoice_request: Option < InvoiceRequest > = None ;
3198
3213
let mut custom_tlvs = Vec :: new ( ) ;
3199
3214
3200
3215
let tlv_len = BigSize :: read ( r) ?;
3201
3216
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) ) ]
3202
3240
decode_tlv_stream_with_custom_tlv_decode ! ( & mut rd, {
3203
3241
( 2 , amt, ( option, encoding: ( u64 , HighZeroBytesDroppedBigSize ) ) ) ,
3204
3242
( 4 , cltv_value, ( option, encoding: ( u32 , HighZeroBytesDroppedBigSize ) ) ) ,
@@ -3224,6 +3262,20 @@ impl<NS: Deref> ReadableArgs<(Option<PublicKey>, NS)> for InboundOnionPayload wh
3224
3262
return Err ( DecodeError :: InvalidValue )
3225
3263
}
3226
3264
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
+
3227
3279
if let Some ( blinding_point) = intro_node_blinding_point. or ( update_add_blinding_point) {
3228
3280
if short_id. is_some ( ) || payment_data. is_some ( ) || payment_metadata. is_some ( ) {
3229
3281
return Err ( DecodeError :: InvalidValue )
0 commit comments