From: benthecarman Date: Fri, 10 Nov 2023 22:12:31 +0000 (-0600) Subject: Impl display for invoice fields X-Git-Tag: v0.0.119~49^2~2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=3fbfde360f775d95115ed6f417cdaf8d63a5f32d;p=rust-lightning Impl display for invoice fields --- 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)