+
+ /// 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
+ /// [`PaymentParameters::for_keysend`], thus omitting the need for payers to manually construct an
+ /// `InvoiceFeatures` for [`find_route`].
+ ///
+ /// [`PaymentParameters::for_keysend`]: crate::routing::router::PaymentParameters::for_keysend
+ /// [`find_route`]: crate::routing::router::find_route
+ pub(crate) fn for_keysend() -> InvoiceFeatures {
+ let mut res = InvoiceFeatures::empty();
+ res.set_variable_length_onion_optional();
+ res
+ }
+}
+
+impl ChannelTypeFeatures {
+ /// Constructs the implicit channel type based on the common supported types between us and our
+ /// counterparty
+ pub(crate) fn from_counterparty_init(counterparty_init: &InitFeatures) -> Self {
+ let mut ret = counterparty_init.to_context_internal();
+ // ChannelTypeFeatures must only contain required bits, so we OR the required forms of all
+ // optional bits and then AND out the optional ones.
+ for byte in ret.flags.iter_mut() {
+ *byte |= (*byte & 0b10_10_10_10) >> 1;
+ *byte &= 0b01_01_01_01;
+ }
+ ret
+ }
+
+ /// Constructs a ChannelTypeFeatures with only static_remotekey set
+ pub(crate) fn only_static_remote_key() -> Self {
+ let mut ret = Self::empty();
+ <sealed::ChannelTypeContext as sealed::StaticRemoteKey>::set_required_bit(&mut ret.flags);
+ ret
+ }