Add basic_mpp support to InvoiceBuilder
[rust-lightning] / lightning-invoice / src / lib.rs
index 11406a4644dd0f0e0c5133dc89cf8c84c55f7bbb..9ee8e49b7dcb8d2a2b307f12087b815659764dc0 100644 (file)
@@ -607,6 +607,20 @@ impl<D: tb::Bool, H: tb::Bool, T: tb::Bool, C: tb::Bool> InvoiceBuilder<D, H, T,
        }
 }
 
+impl<D: tb::Bool, H: tb::Bool, T: tb::Bool, C: tb::Bool> InvoiceBuilder<D, H, T, C, tb::True> {
+       /// Sets the `basic_mpp` feature as optional.
+       pub fn basic_mpp(mut self) -> Self {
+               self.tagged_fields = self.tagged_fields
+                       .drain(..)
+                       .map(|field| match field {
+                               TaggedField::Features(f) => TaggedField::Features(f.set_basic_mpp_optional()),
+                               _ => field,
+                       })
+                       .collect();
+               self
+       }
+}
+
 impl<S: tb::Bool> InvoiceBuilder<tb::True, tb::True, tb::True, tb::True, S> {
        /// Builds and signs an invoice using the supplied `sign_function`. This function MAY NOT fail
        /// and MUST produce a recoverable signature valid for the given hash and if applicable also for