]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Implement to_lower_hex() Display/Debug for OfferId.
authorG8XSU <3442979+G8XSU@users.noreply.github.com>
Mon, 21 Oct 2024 22:36:11 +0000 (15:36 -0700)
committerG8XSU <3442979+G8XSU@users.noreply.github.com>
Mon, 21 Oct 2024 22:41:42 +0000 (15:41 -0700)
lightning/src/offers/offer.rs

index 6580430fb4f8fd5d7f402a73ce40989217c8d2ae..0880e369eed02f90e221dfc7ec62a5d9b74e418f 100644 (file)
@@ -77,6 +77,7 @@
 //! [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
 //! [`ChannelManager::create_offer_builder`]: crate::ln::channelmanager::ChannelManager::create_offer_builder
 
+use core::borrow::Borrow;
 use bitcoin::constants::ChainHash;
 use bitcoin::network::Network;
 use bitcoin::secp256k1::{Keypair, PublicKey, Secp256k1, self};
@@ -111,12 +112,13 @@ use crate::prelude::*;
 
 #[cfg(feature = "std")]
 use std::time::SystemTime;
+use bitcoin::hex::impl_fmt_traits;
 
 pub(super) const IV_BYTES_WITH_METADATA: &[u8; IV_LEN] = b"LDK Offer ~~~~~~";
 pub(super) const IV_BYTES_WITHOUT_METADATA: &[u8; IV_LEN] = b"LDK Offer v2~~~~";
 
 /// An identifier for an [`Offer`] built using [`DerivedMetadata`].
-#[derive(Clone, Copy, Debug, Eq, PartialEq)]
+#[derive(Clone, Copy, Eq, PartialEq)]
 pub struct OfferId(pub [u8; 32]);
 
 impl OfferId {
@@ -134,6 +136,18 @@ impl OfferId {
        }
 }
 
+impl Borrow<[u8]> for OfferId {
+       fn borrow(&self) -> &[u8] {
+               &self.0[..]
+       }
+}
+
+impl_fmt_traits! {
+       impl fmt_traits for OfferId {
+               const LENGTH: usize = 32;
+       }
+}
+
 impl Writeable for OfferId {
        fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
                self.0.write(w)