Skip to content

Commit 5ce6539

Browse files
committed
Add easy way to convert Bolt11InvoiceDescriptionRef to Bolt11InvoiceDescription
Small annoyance I found when updating in one of my downstream projects. If you want to turn a Bolt11InvoiceDescriptionRef into a Bolt11InvoiceDescription you had to do it manually. This is useful if you're trying to create an invoice with the same description as another invoice.
1 parent ac8f897 commit 5ce6539

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lightning-invoice/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,15 @@ impl<'f> Display for Bolt11InvoiceDescriptionRef<'f> {
311311
}
312312
}
313313

314+
impl From<Bolt11InvoiceDescriptionRef<'_>> for Bolt11InvoiceDescription {
315+
fn from(desc_ref: Bolt11InvoiceDescriptionRef) -> Self {
316+
match desc_ref {
317+
Bolt11InvoiceDescriptionRef::Direct(desc) => Bolt11InvoiceDescription::Direct(desc.clone()),
318+
Bolt11InvoiceDescriptionRef::Hash(hash) => Bolt11InvoiceDescription::Hash(hash.clone()),
319+
}
320+
}
321+
}
322+
314323
/// Represents a signed [`RawBolt11Invoice`] with cached hash. The signature is not checked and may be
315324
/// invalid.
316325
///

0 commit comments

Comments
 (0)