@@ -2510,21 +2510,22 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
2510
2510
// want to reject the new HTLC and fail it backwards instead of forwarding.
2511
2511
match pending_forward_info {
2512
2512
PendingHTLCStatus :: Forward ( PendingHTLCInfo { ref incoming_shared_secret, .. } ) => {
2513
- let mut reason = onion_utils:: build_first_hop_failure_packet ( incoming_shared_secret, 0x4000 |10 , & [ ] ) ;
2514
2513
// The only case where we'd be unable to successfully get a channel
2515
2514
// update here is if the channel isn't in the fully-funded
2516
2515
// state yet, implying our counterparty is trying to route payments
2517
2516
// over the channel back to themselves (cause no one else should
2518
2517
// know the short_id is a lightning channel yet). We should have no
2519
2518
// problem just calling this unknown_next_peer, as above (0x4000|10).
2520
- if let Ok ( upd) = self . get_channel_update ( chan) {
2521
- reason = onion_utils:: build_first_hop_failure_packet ( incoming_shared_secret, error_code, & {
2519
+ let reason = if let Ok ( upd) = self . get_channel_update ( chan) {
2520
+ onion_utils:: build_first_hop_failure_packet ( incoming_shared_secret, error_code, & {
2522
2521
let mut res = Vec :: with_capacity ( 8 + 128 ) ;
2523
2522
res. extend_from_slice ( & byte_utils:: be16_to_array ( upd. contents . flags ) ) ;
2524
2523
res. extend_from_slice ( & upd. encode_with_len ( ) [ ..] ) ;
2525
2524
res
2526
- } [ ..] ) ;
2527
- }
2525
+ } [ ..] )
2526
+ } else {
2527
+ onion_utils:: build_first_hop_failure_packet ( incoming_shared_secret, 0x4000 |10 , & [ ] )
2528
+ } ;
2528
2529
let msg = msgs:: UpdateFailHTLC {
2529
2530
channel_id : msg. channel_id ,
2530
2531
htlc_id : msg. htlc_id ,
@@ -2535,7 +2536,7 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
2535
2536
_ => pending_forward_info
2536
2537
}
2537
2538
} ;
2538
- try_chan_entry ! ( self , chan. get_mut( ) . update_add_htlc( & msg, pending_forward_info, create_pending_htlc_status) , channel_state, chan) ;
2539
+ try_chan_entry ! ( self , chan. get_mut( ) . update_add_htlc( & msg, pending_forward_info, create_pending_htlc_status) , channel_state, chan) ;
2539
2540
} ,
2540
2541
hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" , msg. channel_id ) )
2541
2542
}
0 commit comments