Skip to content

Commit dbf3d57

Browse files
authored
Merge pull request #2123 from benthecarman/create-inv-desc
Add generic InvoiceDescription to invoice in InvoiceBuilder
2 parents 3d479c9 + 18c3318 commit dbf3d57

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lightning-invoice/src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,18 @@ impl<H: tb::Bool, T: tb::Bool, C: tb::Bool, S: tb::Bool> InvoiceBuilder<tb::Fals
611611
self.tagged_fields.push(TaggedField::DescriptionHash(Sha256(description_hash)));
612612
self.set_flags()
613613
}
614+
615+
/// Set the description or description hash. This function is only available if no description (hash) was set.
616+
pub fn invoice_description(self, description: InvoiceDescription) -> InvoiceBuilder<tb::True, H, T, C, S> {
617+
match description {
618+
InvoiceDescription::Direct(desc) => {
619+
self.description(desc.clone().into_inner())
620+
}
621+
InvoiceDescription::Hash(hash) => {
622+
self.description_hash(hash.0)
623+
}
624+
}
625+
}
614626
}
615627

616628
impl<D: tb::Bool, T: tb::Bool, C: tb::Bool, S: tb::Bool> InvoiceBuilder<D, tb::False, T, C, S> {

0 commit comments

Comments
 (0)