Skip to content

Commit 479654b

Browse files
authored
Merge pull request #3306 from TheBlueMatt/2024-09-chan-id-hex
Write ChannelIds out as hex in Debug output
2 parents d65dc9c + 98d15f2 commit 479654b

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

lightning-types/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ _test_utils = []
1717

1818
[dependencies]
1919
bitcoin = { version = "0.32.2", default-features = false }
20-
# TODO: Once we switch to bitcoin 0.32 drop this explicit dep:
21-
hex-conservative = { version = "0.2", default-features = false }
2220
bech32 = { version = "0.9", default-features = false }
2321

2422
[lints]

lightning-types/src/payment.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ use alloc::vec::Vec;
1414
use core::borrow::Borrow;
1515

1616
use bitcoin::hashes::{sha256::Hash as Sha256, Hash as _};
17-
18-
// TODO: Once we switch to rust-bitcoin 0.32, import this as bitcoin::hex
19-
use hex_conservative::display::impl_fmt_traits;
17+
use bitcoin::hex::display::impl_fmt_traits;
2018

2119
/// The payment hash is the hash of the [`PaymentPreimage`] which is the value used to lock funds
2220
/// in HTLCs while they transit the lightning network.

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7135,7 +7135,7 @@ where
71357135
chan
71367136
} else {
71377137
let update_actions = peer_state.monitor_update_blocked_actions
7138-
.remove(&channel_id).unwrap_or(Vec::new());
7138+
.remove(channel_id).unwrap_or(Vec::new());
71397139
mem::drop(peer_state_lock);
71407140
mem::drop(per_peer_state);
71417141
self.handle_monitor_update_completion_actions(update_actions);

lightning/src/ln/types.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ use bitcoin::hashes::{
3030
HashEngine as _,
3131
sha256::Hash as Sha256,
3232
};
33-
use core::fmt;
33+
use bitcoin::hex::display::impl_fmt_traits;
34+
use core::borrow::Borrow;
3435
use core::ops::Deref;
3536

3637
/// A unique 32-byte identifier for a channel.
@@ -41,7 +42,7 @@ use core::ops::Deref;
4142
/// A _temporary_ ID is generated randomly.
4243
/// (Later revocation-point-based _v2_ is a possibility.)
4344
/// The variety (context) is not stored, it is relevant only at creation.
44-
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
45+
#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
4546
pub struct ChannelId(pub [u8; 32]);
4647

4748
impl ChannelId {
@@ -121,9 +122,15 @@ impl Readable for ChannelId {
121122
}
122123
}
123124

124-
impl fmt::Display for ChannelId {
125-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
126-
crate::util::logger::DebugBytes(&self.0).fmt(f)
125+
impl Borrow<[u8]> for ChannelId {
126+
fn borrow(&self) -> &[u8] {
127+
&self.0[..]
128+
}
129+
}
130+
131+
impl_fmt_traits! {
132+
impl fmt_traits for ChannelId {
133+
const LENGTH: usize = 32;
127134
}
128135
}
129136

0 commit comments

Comments
 (0)