@@ -3827,18 +3827,10 @@ where
3827
3827
return Err(ChannelError::close("Got an accept_channel message at a strange time".to_owned()));
3828
3828
}
3829
3829
3830
- if let Some(ty) = &common_fields.channel_type {
3831
- if ty != funding.get_channel_type() {
3832
- return Err(ChannelError::close("Channel Type in accept_channel didn't match the one sent in open_channel.".to_owned()));
3833
- }
3834
- } else if their_features.supports_channel_type() {
3835
- // Assume they've accepted the channel type as they said they understand it.
3836
- } else {
3837
- let channel_type = ChannelTypeFeatures::from_init(&their_features);
3838
- if channel_type != ChannelTypeFeatures::only_static_remote_key() {
3839
- return Err(ChannelError::close("Only static_remote_key is supported for non-negotiated channel types".to_owned()));
3840
- }
3841
- funding.channel_transaction_parameters.channel_type_features = channel_type;
3830
+ let channel_type = common_fields.channel_type.as_ref()
3831
+ .ok_or_else(|| ChannelError::close("option_channel_type assumed to be supported".to_owned()))?;
3832
+ if channel_type != funding.get_channel_type() {
3833
+ return Err(ChannelError::close("Channel Type in accept_channel didn't match the one sent in open_channel.".to_owned()));
3842
3834
}
3843
3835
3844
3836
if common_fields.dust_limit_satoshis > 21000000 * 100000000 {
@@ -11526,37 +11518,31 @@ where
11526
11518
/// [`msgs::CommonOpenChannelFields`].
11527
11519
#[rustfmt::skip]
11528
11520
pub(super) fn channel_type_from_open_channel(
11529
- common_fields: &msgs::CommonOpenChannelFields, their_features: &InitFeatures,
11530
- our_supported_features: &ChannelTypeFeatures
11521
+ common_fields: &msgs::CommonOpenChannelFields, our_supported_features: &ChannelTypeFeatures
11531
11522
) -> Result<ChannelTypeFeatures, ChannelError> {
11532
- if let Some(channel_type) = &common_fields.channel_type {
11533
- if channel_type.supports_any_optional_bits() {
11534
- return Err(ChannelError::close("Channel Type field contained optional bits - this is not allowed".to_owned()));
11535
- }
11523
+ let channel_type = common_fields.channel_type.as_ref()
11524
+ .ok_or_else(|| ChannelError::close("option_channel_type assumed to be supported".to_owned()))?;
11536
11525
11537
- // We only support the channel types defined by the `ChannelManager` in
11538
- // `provided_channel_type_features`. The channel type must always support
11539
- // `static_remote_key`, either implicitly with `option_zero_fee_commitments`
11540
- // or explicitly.
11541
- if !channel_type.requires_static_remote_key() && !channel_type.requires_anchor_zero_fee_commitments() {
11542
- return Err(ChannelError::close("Channel Type was not understood - we require static remote key".to_owned()));
11543
- }
11544
- // Make sure we support all of the features behind the channel type.
11545
- if channel_type.requires_unknown_bits_from(&our_supported_features) {
11546
- return Err(ChannelError::close("Channel Type contains unsupported features".to_owned()));
11547
- }
11548
- let announce_for_forwarding = if (common_fields.channel_flags & 1) == 1 { true } else { false };
11549
- if channel_type.requires_scid_privacy() && announce_for_forwarding {
11550
- return Err(ChannelError::close("SCID Alias/Privacy Channel Type cannot be set on a public channel".to_owned()));
11551
- }
11552
- Ok(channel_type.clone())
11553
- } else {
11554
- let channel_type = ChannelTypeFeatures::from_init(&their_features);
11555
- if channel_type != ChannelTypeFeatures::only_static_remote_key() {
11556
- return Err(ChannelError::close("Only static_remote_key is supported for non-negotiated channel types".to_owned()));
11557
- }
11558
- Ok(channel_type)
11526
+ if channel_type.supports_any_optional_bits() {
11527
+ return Err(ChannelError::close("Channel Type field contained optional bits - this is not allowed".to_owned()));
11528
+ }
11529
+
11530
+ // We only support the channel types defined by the `ChannelManager` in
11531
+ // `provided_channel_type_features`. The channel type must always support
11532
+ // `static_remote_key`, either implicitly with `option_zero_fee_commitments`
11533
+ // or explicitly.
11534
+ if !channel_type.requires_static_remote_key() && !channel_type.requires_anchor_zero_fee_commitments() {
11535
+ return Err(ChannelError::close("Channel Type was not understood - we require static remote key".to_owned()));
11536
+ }
11537
+ // Make sure we support all of the features behind the channel type.
11538
+ if channel_type.requires_unknown_bits_from(&our_supported_features) {
11539
+ return Err(ChannelError::close("Channel Type contains unsupported features".to_owned()));
11559
11540
}
11541
+ let announce_for_forwarding = if (common_fields.channel_flags & 1) == 1 { true } else { false };
11542
+ if channel_type.requires_scid_privacy() && announce_for_forwarding {
11543
+ return Err(ChannelError::close("SCID Alias/Privacy Channel Type cannot be set on a public channel".to_owned()));
11544
+ }
11545
+ Ok(channel_type.clone())
11560
11546
}
11561
11547
11562
11548
impl<SP: Deref> InboundV1Channel<SP>
@@ -11580,7 +11566,7 @@ where
11580
11566
11581
11567
// First check the channel type is known, failing before we do anything else if we don't
11582
11568
// support this channel type.
11583
- let channel_type = channel_type_from_open_channel(&msg.common_fields, their_features, our_supported_features)?;
11569
+ let channel_type = channel_type_from_open_channel(&msg.common_fields, our_supported_features)?;
11584
11570
11585
11571
let holder_selected_channel_reserve_satoshis = get_holder_selected_channel_reserve_satoshis(msg.common_fields.funding_satoshis, config);
11586
11572
let counterparty_pubkeys = ChannelPublicKeys {
@@ -11977,13 +11963,7 @@ where
11977
11963
let holder_selected_channel_reserve_satoshis = get_v2_channel_reserve_satoshis(
11978
11964
channel_value_satoshis, MIN_CHAN_DUST_LIMIT_SATOSHIS);
11979
11965
11980
- // First check the channel type is known, failing before we do anything else if we don't
11981
- // support this channel type.
11982
- if msg.common_fields.channel_type.is_none() {
11983
- return Err(ChannelError::close(format!("Rejecting V2 channel {} missing channel_type",
11984
- msg.common_fields.temporary_channel_id)))
11985
- }
11986
- let channel_type = channel_type_from_open_channel(&msg.common_fields, their_features, our_supported_features)?;
11966
+ let channel_type = channel_type_from_open_channel(&msg.common_fields, our_supported_features)?;
11987
11967
11988
11968
let counterparty_pubkeys = ChannelPublicKeys {
11989
11969
funding_pubkey: msg.common_fields.funding_pubkey,
0 commit comments