]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Impl display for invoice fields
authorbenthecarman <benthecarman@live.com>
Fri, 10 Nov 2023 22:12:31 +0000 (16:12 -0600)
committerbenthecarman <benthecarman@live.com>
Sat, 11 Nov 2023 02:41:53 +0000 (20:41 -0600)
lightning-invoice/src/lib.rs

index d953795cf8e061157f1c69e9c5bc5eae2b743ca6..b2fe8a1203057acec3f71000a03cb49f0fdf7397 100644 (file)
@@ -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<PublicKey> for PayeePubKey {
        fn from(pk: PublicKey) -> Self {
                PayeePubKey(pk)