diff --git a/lightning-types/Cargo.toml b/lightning-types/Cargo.toml index 9e8feedf6e..f3eeec0f1a 100644 --- a/lightning-types/Cargo.toml +++ b/lightning-types/Cargo.toml @@ -17,8 +17,6 @@ _test_utils = [] [dependencies] bitcoin = { version = "0.32.2", default-features = false } -# TODO: Once we switch to bitcoin 0.32 drop this explicit dep: -hex-conservative = { version = "0.2", default-features = false } bech32 = { version = "0.9", default-features = false } [lints] diff --git a/lightning-types/src/payment.rs b/lightning-types/src/payment.rs index 6b8854ac5f..a2832c6b55 100644 --- a/lightning-types/src/payment.rs +++ b/lightning-types/src/payment.rs @@ -14,9 +14,7 @@ use alloc::vec::Vec; use core::borrow::Borrow; use bitcoin::hashes::{sha256::Hash as Sha256, Hash as _}; - -// TODO: Once we switch to rust-bitcoin 0.32, import this as bitcoin::hex -use hex_conservative::display::impl_fmt_traits; +use bitcoin::hex::display::impl_fmt_traits; /// The payment hash is the hash of the [`PaymentPreimage`] which is the value used to lock funds /// in HTLCs while they transit the lightning network. diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index 85dc48946e..7d00bc0a49 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -7135,7 +7135,7 @@ where chan } else { let update_actions = peer_state.monitor_update_blocked_actions - .remove(&channel_id).unwrap_or(Vec::new()); + .remove(channel_id).unwrap_or(Vec::new()); mem::drop(peer_state_lock); mem::drop(per_peer_state); self.handle_monitor_update_completion_actions(update_actions); diff --git a/lightning/src/ln/types.rs b/lightning/src/ln/types.rs index 659c7e4cab..dbe1e216b9 100644 --- a/lightning/src/ln/types.rs +++ b/lightning/src/ln/types.rs @@ -30,7 +30,8 @@ use bitcoin::hashes::{ HashEngine as _, sha256::Hash as Sha256, }; -use core::fmt; +use bitcoin::hex::display::impl_fmt_traits; +use core::borrow::Borrow; use core::ops::Deref; /// A unique 32-byte identifier for a channel. @@ -41,7 +42,7 @@ use core::ops::Deref; /// A _temporary_ ID is generated randomly. /// (Later revocation-point-based _v2_ is a possibility.) /// The variety (context) is not stored, it is relevant only at creation. -#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)] pub struct ChannelId(pub [u8; 32]); impl ChannelId { @@ -121,9 +122,15 @@ impl Readable for ChannelId { } } -impl fmt::Display for ChannelId { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - crate::util::logger::DebugBytes(&self.0).fmt(f) +impl Borrow<[u8]> for ChannelId { + fn borrow(&self) -> &[u8] { + &self.0[..] + } +} + +impl_fmt_traits! { + impl fmt_traits for ChannelId { + const LENGTH: usize = 32; } }