+ 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