Skip to content

Commit d9e9215

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 d9e9215

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
@@ -777,6 +777,17 @@ 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+
782+
/// Set the description or description hash. This function is only available if no description (hash) was set.
783+
pub fn invoice_description_ref(
784+
self, description_ref: Bolt11InvoiceDescriptionRef<'_>,
785+
) -> InvoiceBuilder<tb::True, H, T, C, S, M> {
786+
match description_ref {
787+
Bolt11InvoiceDescriptionRef::Direct(desc) => self.description(desc.clone().0 .0),
788+
Bolt11InvoiceDescriptionRef::Hash(hash) => self.description_hash(hash.0),
789+
}
790+
}
780791
}
781792

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

0 commit comments

Comments
 (0)