Implement utilities for keysending to private nodes
[rust-lightning] / lightning / src / ln / features.rs
index 492cf5ccd198c2829b73b81ab4e5558b9cd14028..eb0100db675de8842e1d317d4a2b9c5c6e7b9ab1 100644 (file)
@@ -400,6 +400,18 @@ impl InvoiceFeatures {
        pub(crate) fn to_context<C: sealed::Context>(&self) -> Features<C> {
                self.to_context_internal()
        }
+
+       /// Getting a route for a keysend payment to a private node requires providing the payee's
+       /// features (since they were not announced in a node announcement). However, keysend payments
+       /// don't have an invoice to pull the payee's features from, so this method is provided for use in
+       /// [`get_keysend_route`], thus omitting the need for payers to manually construct an
+       /// `InvoiceFeatures` for [`get_route`].
+       ///
+       /// [`get_keysend_route`]: crate::routing::router::get_keysend_route
+       /// [`get_route`]: crate::routing::router::get_route
+       pub(crate) fn for_keysend() -> InvoiceFeatures {
+               InvoiceFeatures::empty().set_variable_length_onion_optional()
+       }
 }
 
 impl ToBase32 for InvoiceFeatures {