Skip to content

Commit 904fd81

Browse files
committed
Use ChannelUpdate::TYPE const.
1 parent 6a196f2 commit 904fd81

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ use ln::msgs;
4848
use ln::msgs::NetAddress;
4949
use ln::onion_utils;
5050
use ln::msgs::{ChannelMessageHandler, DecodeError, LightningError, MAX_VALUE_MSAT, OptionalField};
51+
use ln::wire::Encode;
5152
use chain::keysinterface::{Sign, KeysInterface, KeysManager, InMemorySigner, Recipient};
5253
use util::config::UserConfig;
5354
use util::events::{EventHandler, EventsProvider, MessageSendEvent, MessageSendEventsProvider, ClosureReason};
@@ -3546,7 +3547,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
35463547
0u16.write(&mut enc).expect("Writes cannot fail");
35473548
}
35483549
(upd.serialized_length() as u16 + 2).write(&mut enc).expect("Writes cannot fail");
3549-
let chan_update_type = u16::from_be_bytes([0x01, 0x02]);
3550+
let chan_update_type = msgs::ChannelUpdate::TYPE;
35503551
chan_update_type.write(&mut enc).expect("Writes cannot fail");
35513552
upd.write(&mut enc).expect("Writes cannot fail");
35523553
(desired_err_code, enc.0)

lightning/src/ln/onion_utils.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use ln::{PaymentHash, PaymentPreimage, PaymentSecret};
1111
use ln::channelmanager::HTLCSource;
1212
use ln::msgs;
13+
use ln::wire::Encode;
1314
use routing::network_graph::NetworkUpdate;
1415
use routing::router::RouteHop;
1516
use util::chacha20::{ChaCha20, ChaChaReader};
@@ -410,7 +411,7 @@ pub(super) fn process_onion_failure<T: secp256k1::Signing, L: Deref>(secp_ctx: &
410411
// been updated to indicate that they *are* included, but many
411412
// nodes still send messages without the type bytes, so we
412413
// support both here.
413-
if update_slice.len() > 2 && update_slice[0..2] == [0x01, 0x02] {
414+
if update_slice.len() > 2 && update_slice[0..2] == msgs::ChannelUpdate::TYPE.to_be_bytes() {
414415
update_slice = &update_slice[2..];
415416
}
416417
if let Ok(chan_update) = msgs::ChannelUpdate::read(&mut Cursor::new(&update_slice)) {

0 commit comments

Comments
 (0)