From 9066f628e2e25ac8863379e27e856d9c6ffe45fa Mon Sep 17 00:00:00 2001 From: benthecarman Date: Thu, 14 Aug 2025 10:55:46 -0500 Subject: [PATCH] Allow building Invoice from Bolt11InvoiceDescriptionRef Small annoyance I found when updating in one of my downstream projects. Now that there are 2 types of Bolt11InvoiceDescription you can't just copy one from one invoice to a new one. This makes it so we can again build an invoice from the ref version. --- lightning-invoice/src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lightning-invoice/src/lib.rs b/lightning-invoice/src/lib.rs index 9e330a97813..fda7c1003b9 100644 --- a/lightning-invoice/src/lib.rs +++ b/lightning-invoice/src/lib.rs @@ -777,6 +777,16 @@ impl Bolt11InvoiceDescription::Hash(hash) => self.description_hash(hash.0), } } + + /// Set the description or description hash. This function is only available if no description (hash) was set. + pub fn invoice_description_ref( + self, description_ref: Bolt11InvoiceDescriptionRef<'_>, + ) -> InvoiceBuilder { + match description_ref { + Bolt11InvoiceDescriptionRef::Direct(desc) => self.description(desc.clone().0 .0), + Bolt11InvoiceDescriptionRef::Hash(hash) => self.description_hash(hash.0), + } + } } impl