if channel_type_features.supports_anchors_zero_fee_htlc_tx() { WEIGHT_RECEIVED_HTLC_ANCHORS } else { WEIGHT_RECEIVED_HTLC }
}
+/// 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(())
+}
+
// number_of_witness_elements + sig_length + revocation_sig + true_length + op_true + witness_script_length + witness_script
pub(crate) const WEIGHT_REVOKED_OUTPUT: u64 = 1 + 1 + 73 + 1 + 1 + 1 + 77;
(11, channel_type_features, option),
});
+ verify_channel_type_features(&channel_type_features, None)?;
+
Ok(Self {
per_commitment_point: per_commitment_point.0.unwrap(),
counterparty_delayed_payment_base_key: counterparty_delayed_payment_base_key.0.unwrap(),
(9, channel_type_features, option),
});
+ verify_channel_type_features(&channel_type_features, None)?;
+
Ok(Self {
per_commitment_point: per_commitment_point.0.unwrap(),
counterparty_delayed_payment_base_key: counterparty_delayed_payment_base_key.0.unwrap(),
(7, channel_type_features, option),
});
+ verify_channel_type_features(&channel_type_features, None)?;
+
Ok(Self {
amount_msat: amount_msat.0.unwrap(),
cltv_expiry: cltv_expiry.0.unwrap(),
(3, funding_amount, option)
});
+ verify_channel_type_features(&channel_type_features, None)?;
+
Ok(Self {
funding_redeemscript: funding_redeemscript.0.unwrap(),
channel_type_features: channel_type_features.unwrap_or(ChannelTypeFeatures::only_static_remote_key()),
(11, channel_type_features, option),
});
+ let mut additional_features = ChannelTypeFeatures::empty();
+ additional_features.set_anchors_nonzero_fee_htlc_tx_required();
+ chain::package::verify_channel_type_features(&channel_type_features, Some(&additional_features))?;
+
Ok(Self {
holder_pubkeys: holder_pubkeys.0.unwrap(),
holder_selected_contest_delay: holder_selected_contest_delay.0.unwrap(),
(15, channel_type_features, option),
});
+ let mut additional_features = ChannelTypeFeatures::empty();
+ additional_features.set_anchors_nonzero_fee_htlc_tx_required();
+ chain::package::verify_channel_type_features(&channel_type_features, Some(&additional_features))?;
+
Ok(Self {
commitment_number: commitment_number.0.unwrap(),
to_broadcaster_value_sat: to_broadcaster_value_sat.0.unwrap(),