Skip to content

Commit 9066f62

Browse files
committed
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.
1 parent ac8f897 commit 9066f62

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lightning-invoice/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,16 @@ impl<H: tb::Bool, T: tb::Bool, C: tb::Bool, S: tb::Bool, M: tb::Bool>
777777
Bolt11InvoiceDescription::Hash(hash) => self.description_hash(hash.0),
778778
}
779779
}
780+
781+
/// Set the description or description hash. This function is only available if no description (hash) was set.
782+
pub fn invoice_description_ref(
783+
self, description_ref: Bolt11InvoiceDescriptionRef<'_>,
784+
) -> InvoiceBuilder<tb::True, H, T, C, S, M> {
785+
match description_ref {
786+
Bolt11InvoiceDescriptionRef::Direct(desc) => self.description(desc.clone().0 .0),
787+
Bolt11InvoiceDescriptionRef::Hash(hash) => self.description_hash(hash.0),
788+
}
789+
}
780790
}
781791

782792
impl<D: tb::Bool, T: tb::Bool, C: tb::Bool, S: tb::Bool, M: tb::Bool>

0 commit comments

Comments
 (0)