Skip to content

Commit 3fbfde3

Browse files
committed
Impl display for invoice fields
1 parent 6e40e5f commit 3fbfde3

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lightning-invoice/src/lib.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,15 @@ pub enum Bolt11InvoiceDescription<'f> {
269269
Hash(&'f Sha256),
270270
}
271271

272+
impl<'f> Display for Bolt11InvoiceDescription<'f> {
273+
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
274+
match self {
275+
Bolt11InvoiceDescription::Direct(desc) => write!(f, "{}", desc.0),
276+
Bolt11InvoiceDescription::Hash(hash) => write!(f, "{}", hash.0),
277+
}
278+
}
279+
}
280+
272281
/// Represents a signed [`RawBolt11Invoice`] with cached hash. The signature is not checked and may be
273282
/// invalid.
274283
///
@@ -1526,6 +1535,12 @@ impl Deref for Description {
15261535
}
15271536
}
15281537

1538+
impl Display for Description {
1539+
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
1540+
write!(f, "{}", self.0)
1541+
}
1542+
}
1543+
15291544
impl From<PublicKey> for PayeePubKey {
15301545
fn from(pk: PublicKey) -> Self {
15311546
PayeePubKey(pk)

0 commit comments

Comments
 (0)