From 3fbfde360f775d95115ed6f417cdaf8d63a5f32d Mon Sep 17 00:00:00 2001 From: benthecarman Date: Fri, 10 Nov 2023 16:12:31 -0600 Subject: [PATCH] Impl display for invoice fields --- lightning-invoice/src/lib.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lightning-invoice/src/lib.rs b/lightning-invoice/src/lib.rs index d953795cf..b2fe8a120 100644 --- a/lightning-invoice/src/lib.rs +++ b/lightning-invoice/src/lib.rs @@ -269,6 +269,15 @@ pub enum Bolt11InvoiceDescription<'f> { Hash(&'f Sha256), } +impl<'f> Display for Bolt11InvoiceDescription<'f> { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + match self { + Bolt11InvoiceDescription::Direct(desc) => write!(f, "{}", desc.0), + Bolt11InvoiceDescription::Hash(hash) => write!(f, "{}", hash.0), + } + } +} + /// Represents a signed [`RawBolt11Invoice`] with cached hash. The signature is not checked and may be /// invalid. /// @@ -1526,6 +1535,12 @@ impl Deref for Description { } } +impl Display for Description { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + write!(f, "{}", self.0) + } +} + impl From for PayeePubKey { fn from(pk: PublicKey) -> Self { PayeePubKey(pk) -- 2.39.5