+/// Verifies deserializable channel type features
+pub(crate) fn verify_channel_type_features(channel_type_features: &Option<ChannelTypeFeatures>, additional_permitted_features: Option<&ChannelTypeFeatures>) -> Result<(), DecodeError> {
+ if let Some(features) = channel_type_features.as_ref() {
+ if features.requires_unknown_bits() {
+ return Err(DecodeError::UnknownRequiredFeature);
+ }
+
+ let mut supported_feature_set = ChannelTypeFeatures::anchors_zero_htlc_fee_and_dependencies();
+ supported_feature_set.set_scid_privacy_required();
+ supported_feature_set.set_zero_conf_required();
+
+ // allow the passing of an additional necessary permitted flag
+ if let Some(additional_permitted_features) = additional_permitted_features {
+ supported_feature_set |= additional_permitted_features;
+ }
+
+ if !features.is_subset(&supported_feature_set) {
+ return Err(DecodeError::UnknownRequiredFeature);
+ }
+ }
+
+ Ok(())
+}
+