]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Add generic InvoiceDescription to invoice in InvoiceBuilder
authorbenthecarman <benthecarman@live.com>
Thu, 23 Mar 2023 05:06:32 +0000 (00:06 -0500)
committerbenthecarman <benthecarman@live.com>
Thu, 23 Mar 2023 05:07:16 +0000 (00:07 -0500)
lightning-invoice/src/lib.rs

index 37c74922ee6957fcb1a0211808e6e13a62f18fac..1421c48b43e1a82c0942141801930c1d69345b0d 100644 (file)
@@ -611,6 +611,18 @@ impl<H: tb::Bool, T: tb::Bool, C: tb::Bool, S: tb::Bool> InvoiceBuilder<tb::Fals
                self.tagged_fields.push(TaggedField::DescriptionHash(Sha256(description_hash)));
                self.set_flags()
        }
+
+       /// Set the description or description hash. This function is only available if no description (hash) was set.
+       pub fn invoice_description(self, description: InvoiceDescription) -> InvoiceBuilder<tb::True, H, T, C, S> {
+               match description {
+                       InvoiceDescription::Direct(desc) => {
+                               self.description(desc.clone().into_inner())
+                       }
+                       InvoiceDescription::Hash(hash) => {
+                               self.description_hash(hash.0)
+                       }
+               }
+       }
 }
 
 impl<D: tb::Bool, T: tb::Bool, C: tb::Bool, S: tb::Bool> InvoiceBuilder<D, tb::False, T, C, S> {