Skip to content

Commit 56dd01b

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 56dd01b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lightning-invoice/src/lib.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,17 @@ 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) => {
318+
Bolt11InvoiceDescription::Direct(desc.clone())
319+
},
320+
Bolt11InvoiceDescriptionRef::Hash(hash) => Bolt11InvoiceDescription::Hash(hash.clone()),
321+
}
322+
}
323+
}
324+
314325
/// Represents a signed [`RawBolt11Invoice`] with cached hash. The signature is not checked and may be
315326
/// invalid.
316327
///

0 commit comments

Comments
 (0)