Impl display for invoice fields

This commit is contained in:
benthecarman 2023-11-10 16:12:31 -06:00
parent 6e40e5f18a
commit 3fbfde360f
No known key found for this signature in database
GPG key ID: D7CC770B81FD22A8

View 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)