@@ -2482,17 +2482,14 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
2482
2482
}
2483
2483
2484
2484
let create_pending_htlc_status = |chan : & Channel < ChanSigner > , pending_forward_info : PendingHTLCStatus , error_code : u16 | {
2485
+ // Ensure error_code has the UPDATE flag set, since by default we send a
2486
+ // channel update along as part of failing the HTLC.
2487
+ assert ! ( ( error_code & 0x1000 ) != 0 ) ;
2485
2488
// If the update_add is completely bogus, the call will Err and we will close,
2486
2489
// but if we've sent a shutdown and they haven't acknowledged it yet, we just
2487
2490
// want to reject the new HTLC and fail it backwards instead of forwarding.
2488
2491
match pending_forward_info {
2489
2492
PendingHTLCStatus :: Forward ( PendingHTLCInfo { ref incoming_shared_secret, .. } ) => {
2490
- // The only case where we'd be unable to successfully get a channel
2491
- // update here is if the channel isn't in the fully-funded
2492
- // state yet, implying our counterparty is trying to route payments
2493
- // over the channel back to themselves (cause no one else should
2494
- // know the short_id is a lightning channel yet). We should have no
2495
- // problem just calling this unknown_next_peer, as above (0x4000|10).
2496
2493
let reason = if let Ok ( upd) = self . get_channel_update ( chan) {
2497
2494
onion_utils:: build_first_hop_failure_packet ( incoming_shared_secret, error_code, & {
2498
2495
let mut res = Vec :: with_capacity ( 8 + 128 ) ;
@@ -2501,6 +2498,15 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
2501
2498
res
2502
2499
} [ ..] )
2503
2500
} else {
2501
+ // The only case where we'd be unable to
2502
+ // successfully get a channel update is if the
2503
+ // channel isn't in the fully-funded state yet,
2504
+ // implying our counterparty is trying to route
2505
+ // payments over the channel back to themselves
2506
+ // (cause no one else should know the short_id
2507
+ // is a lightning channel yet). We should have
2508
+ // no problem just calling this
2509
+ // unknown_next_peer (0x4000|10).
2504
2510
onion_utils:: build_first_hop_failure_packet ( incoming_shared_secret, 0x4000 |10 , & [ ] )
2505
2511
} ;
2506
2512
let msg = msgs:: UpdateFailHTLC {
0 commit comments