@@ -2912,7 +2912,8 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
2912
2912
phantom_shared_secret: $phantom_ss,
2913
2913
} ) ;
2914
2914
failed_forwards. push( ( htlc_source, payment_hash,
2915
- HTLCFailReason :: Reason { failure_code: $err_code, data: $err_data }
2915
+ HTLCFailReason :: Reason { failure_code: $err_code, data: $err_data } ,
2916
+ None
2916
2917
) ) ;
2917
2918
continue ;
2918
2919
}
@@ -2991,7 +2992,8 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
2991
2992
}
2992
2993
let ( failure_code, data) = self . get_htlc_temp_fail_err_and_data ( 0x1000 |7 , short_chan_id, chan. get ( ) ) ;
2993
2994
failed_forwards. push ( ( htlc_source, payment_hash,
2994
- HTLCFailReason :: Reason { failure_code, data }
2995
+ HTLCFailReason :: Reason { failure_code, data } ,
2996
+ Some ( chan. get ( ) . get_counterparty_node_id ( ) )
2995
2997
) ) ;
2996
2998
continue ;
2997
2999
} ,
@@ -3133,7 +3135,8 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
3133
3135
incoming_packet_shared_secret: $htlc. prev_hop. incoming_packet_shared_secret,
3134
3136
phantom_shared_secret,
3135
3137
} ) , payment_hash,
3136
- HTLCFailReason :: Reason { failure_code: 0x4000 | 15 , data: htlc_msat_height_data }
3138
+ HTLCFailReason :: Reason { failure_code: 0x4000 | 15 , data: htlc_msat_height_data } ,
3139
+ None
3137
3140
) ) ;
3138
3141
}
3139
3142
}
@@ -3261,8 +3264,8 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
3261
3264
}
3262
3265
}
3263
3266
3264
- for ( htlc_source, payment_hash, failure_reason) in failed_forwards. drain ( ..) {
3265
- self . fail_htlc_backwards_internal ( self . channel_state . lock ( ) . unwrap ( ) , htlc_source, & payment_hash, failure_reason, Some ( self . get_our_node_id ( ) ) ) ;
3267
+ for ( htlc_source, payment_hash, failure_reason, node_id ) in failed_forwards. drain ( ..) {
3268
+ self . fail_htlc_backwards_internal ( self . channel_state . lock ( ) . unwrap ( ) , htlc_source, & payment_hash, failure_reason, node_id ) ;
3266
3269
}
3267
3270
self . forward_htlcs ( & mut phantom_receives) ;
3268
3271
@@ -3576,8 +3579,16 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
3576
3579
hash_map:: Entry :: Vacant ( _) => ( 0x4000 |10 , Vec :: new ( ) )
3577
3580
} ;
3578
3581
let channel_state = self . channel_state . lock ( ) . unwrap ( ) ;
3579
- self . fail_htlc_backwards_internal ( channel_state,
3580
- htlc_src, & payment_hash, HTLCFailReason :: Reason { failure_code, data : onion_failure_data} , Some ( self . get_our_node_id ( ) ) ) ;
3582
+
3583
+ match channel_state. by_id . get ( & channel_id) {
3584
+ Some ( channel) => {
3585
+ let node_id = channel. get_counterparty_node_id ( ) . clone ( ) ;
3586
+ self . fail_htlc_backwards_internal ( channel_state,
3587
+ htlc_src, & payment_hash, HTLCFailReason :: Reason { failure_code, data : onion_failure_data } , Some ( node_id) )
3588
+ } ,
3589
+ None => self . fail_htlc_backwards_internal ( channel_state,
3590
+ htlc_src, & payment_hash, HTLCFailReason :: Reason { failure_code, data : onion_failure_data } , None )
3591
+ }
3581
3592
} ,
3582
3593
HTLCSource :: OutboundRoute { session_priv, payment_id, path, payment_params, .. } => {
3583
3594
let mut session_priv_bytes = [ 0 ; 32 ] ;
@@ -4086,6 +4097,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
4086
4097
return ;
4087
4098
}
4088
4099
4100
+ let counterparty_node_id = channel. get ( ) . get_counterparty_node_id ( ) ;
4089
4101
let updates = channel. get_mut ( ) . monitor_updating_restored ( & self . logger , self . get_our_node_id ( ) , self . genesis_hash , self . best_block . read ( ) . unwrap ( ) . height ( ) ) ;
4090
4102
let channel_update = if updates. funding_locked . is_some ( ) && channel. get ( ) . is_usable ( ) {
4091
4103
// We only send a channel_update in the case where we are just now sending a
@@ -4104,12 +4116,14 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
4104
4116
if let Some ( upd) = channel_update {
4105
4117
channel_state. pending_msg_events . push ( upd) ;
4106
4118
}
4107
- ( updates. failed_htlcs , updates. finalized_claimed_htlcs )
4119
+
4120
+ let failed_htlcs_with_chan_id: Vec < ( HTLCSource , PaymentHash , HTLCFailReason , PublicKey ) > = updates. failed_htlcs . into_iter ( ) . map ( |h| ( h. 0 , h. 1 , h. 2 , counterparty_node_id) ) . collect ( ) ;
4121
+ ( failed_htlcs_with_chan_id, updates. finalized_claimed_htlcs )
4108
4122
} ;
4109
4123
post_handle_chan_restoration ! ( self , chan_restoration_res) ;
4110
4124
self . finalize_claims ( finalized_claims) ;
4111
4125
for failure in pending_failures. drain ( ..) {
4112
- self . fail_htlc_backwards_internal ( self . channel_state . lock ( ) . unwrap ( ) , failure. 0 , & failure. 1 , failure. 2 , Some ( self . get_our_node_id ( ) ) ) ;
4126
+ self . fail_htlc_backwards_internal ( self . channel_state . lock ( ) . unwrap ( ) , failure. 0 , & failure. 1 , failure. 2 , Some ( failure . 3 ) ) ;
4113
4127
}
4114
4128
}
4115
4129
0 commit comments