@@ -420,6 +420,7 @@ pub(crate) struct HTLCPreviousHopData {
420
420
short_channel_id : u64 ,
421
421
htlc_id : u64 ,
422
422
incoming_packet_shared_secret : [ u8 ; 32 ] ,
423
+ phantom_shared_secret : Option < [ u8 ; 32 ] > ,
423
424
424
425
// This field is consumed by `claim_funds_from_hop()` when updating a force-closed backwards
425
426
// channel with a preimage provided by the forward channel.
@@ -3014,17 +3015,18 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
3014
3015
routing, incoming_shared_secret, payment_hash, amt_to_forward, outgoing_cltv_value } ,
3015
3016
prev_funding_outpoint } => {
3016
3017
macro_rules! fail_forward {
3017
- ( $msg: expr, $err_code: expr, $err_data: expr) => {
3018
+ ( $msg: expr, $err_code: expr, $err_data: expr, $phantom_ss : expr ) => {
3018
3019
{
3019
3020
log_info!( self . logger, "Failed to accept/forward incoming HTLC: {}" , $msg) ;
3020
3021
let htlc_source = HTLCSource :: PreviousHopData ( HTLCPreviousHopData {
3021
- short_channel_id: short_chan_id ,
3022
+ short_channel_id: prev_short_channel_id ,
3022
3023
outpoint: prev_funding_outpoint,
3023
3024
htlc_id: prev_htlc_id,
3024
3025
incoming_packet_shared_secret: incoming_shared_secret,
3026
+ phantom_shared_secret: $phantom_ss,
3025
3027
} ) ;
3026
3028
failed_forwards. push( ( htlc_source, payment_hash,
3027
- HTLCFailReason :: Reason { failure_code: $err_code, data: $err_data }
3029
+ HTLCFailReason :: Reason { failure_code: $err_code, data: $err_data }
3028
3030
) ) ;
3029
3031
continue ;
3030
3032
}
@@ -3041,26 +3043,26 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
3041
3043
let next_hop = match onion_utils:: decode_next_hop ( phantom_shared_secret, & onion_packet. hop_data , onion_packet. hmac , payment_hash) {
3042
3044
Ok ( res) => res,
3043
3045
Err ( onion_utils:: OnionDecodeErr :: Malformed { err_msg, err_code } ) => {
3044
- fail_forward ! ( err_msg, err_code, Vec :: new( ) ) ;
3046
+ fail_forward ! ( err_msg, err_code, Vec :: new( ) , None ) ;
3045
3047
} ,
3046
3048
Err ( onion_utils:: OnionDecodeErr :: Relay { err_msg, err_code } ) => {
3047
- fail_forward ! ( err_msg, err_code, Vec :: new( ) ) ;
3049
+ fail_forward ! ( err_msg, err_code, Vec :: new( ) , Some ( phantom_shared_secret ) ) ;
3048
3050
} ,
3049
3051
} ;
3050
3052
match next_hop {
3051
3053
onion_utils:: Hop :: Receive ( hop_data) => {
3052
3054
match self . construct_recv_pending_htlc_info ( hop_data, incoming_shared_secret, payment_hash, amt_to_forward, outgoing_cltv_value, Some ( phantom_shared_secret) ) {
3053
3055
Ok ( info) => phantom_receives. push ( ( prev_short_channel_id, prev_funding_outpoint, vec ! [ ( info, prev_htlc_id) ] ) ) ,
3054
- Err ( ReceiveError { err_code, err_data, msg } ) => fail_forward ! ( msg, err_code, err_data)
3056
+ Err ( ReceiveError { err_code, err_data, msg } ) => fail_forward ! ( msg, err_code, err_data, Some ( phantom_shared_secret ) )
3055
3057
}
3056
3058
} ,
3057
3059
_ => panic ! ( ) ,
3058
3060
}
3059
3061
} else {
3060
- fail_forward ! ( format!( "Unknown short channel id {} for forward HTLC" , short_chan_id) , 0x4000 | 10 , Vec :: new( ) ) ;
3062
+ fail_forward ! ( format!( "Unknown short channel id {} for forward HTLC" , short_chan_id) , 0x4000 | 10 , Vec :: new( ) , None ) ;
3061
3063
}
3062
3064
} else {
3063
- fail_forward ! ( format!( "Unknown short channel id {} for forward HTLC" , short_chan_id) , 0x4000 | 10 , Vec :: new( ) ) ;
3065
+ fail_forward ! ( format!( "Unknown short channel id {} for forward HTLC" , short_chan_id) , 0x4000 | 10 , Vec :: new( ) , None ) ;
3064
3066
}
3065
3067
} ,
3066
3068
HTLCForwardInfo :: FailHTLC { .. } => {
@@ -3093,6 +3095,8 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
3093
3095
outpoint : prev_funding_outpoint,
3094
3096
htlc_id : prev_htlc_id,
3095
3097
incoming_packet_shared_secret : incoming_shared_secret,
3098
+ // Phantom payments are only PendingHTLCRouting::Receive.
3099
+ phantom_shared_secret : None ,
3096
3100
} ) ;
3097
3101
match chan. get_mut ( ) . send_htlc ( amt_to_forward, payment_hash, outgoing_cltv_value, htlc_source. clone ( ) , onion_packet, & self . logger ) {
3098
3102
Err ( e) => {
@@ -3224,6 +3228,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
3224
3228
outpoint : prev_funding_outpoint,
3225
3229
htlc_id : prev_htlc_id,
3226
3230
incoming_packet_shared_secret : incoming_shared_secret,
3231
+ phantom_shared_secret,
3227
3232
} ,
3228
3233
value : amt_to_forward,
3229
3234
cltv_expiry,
@@ -3241,6 +3246,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
3241
3246
outpoint: prev_funding_outpoint,
3242
3247
htlc_id: $htlc. prev_hop. htlc_id,
3243
3248
incoming_packet_shared_secret: $htlc. prev_hop. incoming_packet_shared_secret,
3249
+ phantom_shared_secret,
3244
3250
} ) , payment_hash,
3245
3251
HTLCFailReason :: Reason { failure_code: 0x4000 | 15 , data: htlc_msat_height_data }
3246
3252
) ) ;
@@ -6073,6 +6079,7 @@ impl_writeable_tlv_based_enum!(PendingHTLCStatus, ;
6073
6079
6074
6080
impl_writeable_tlv_based ! ( HTLCPreviousHopData , {
6075
6081
( 0 , short_channel_id, required) ,
6082
+ ( 1 , phantom_shared_secret, option) ,
6076
6083
( 2 , outpoint, required) ,
6077
6084
( 4 , htlc_id, required) ,
6078
6085
( 6 , incoming_packet_shared_secret, required)
0 commit comments