@@ -3838,18 +3838,10 @@ where
3838
3838
return Err(ChannelError::close("Got an accept_channel message at a strange time".to_owned()));
3839
3839
}
3840
3840
3841
- if let Some(ty) = &common_fields.channel_type {
3842
- if ty != funding.get_channel_type() {
3843
- return Err(ChannelError::close("Channel Type in accept_channel didn't match the one sent in open_channel.".to_owned()));
3844
- }
3845
- } else if their_features.supports_channel_type() {
3846
- // Assume they've accepted the channel type as they said they understand it.
3847
- } else {
3848
- let channel_type = ChannelTypeFeatures::from_init(&their_features);
3849
- if channel_type != ChannelTypeFeatures::only_static_remote_key() {
3850
- return Err(ChannelError::close("Only static_remote_key is supported for non-negotiated channel types".to_owned()));
3851
- }
3852
- funding.channel_transaction_parameters.channel_type_features = channel_type;
3841
+ let channel_type = common_fields.channel_type.as_ref()
3842
+ .ok_or_else(|| ChannelError::close("option_channel_type assumed to be supported".to_owned()))?;
3843
+ if channel_type != funding.get_channel_type() {
3844
+ return Err(ChannelError::close("Channel Type in accept_channel didn't match the one sent in open_channel.".to_owned()));
3853
3845
}
3854
3846
3855
3847
if common_fields.dust_limit_satoshis > 21000000 * 100000000 {
@@ -11542,37 +11534,31 @@ where
11542
11534
/// [`msgs::CommonOpenChannelFields`].
11543
11535
#[rustfmt::skip]
11544
11536
pub(super) fn channel_type_from_open_channel(
11545
- common_fields: &msgs::CommonOpenChannelFields, their_features: &InitFeatures,
11546
- our_supported_features: &ChannelTypeFeatures
11537
+ common_fields: &msgs::CommonOpenChannelFields, our_supported_features: &ChannelTypeFeatures
11547
11538
) -> Result<ChannelTypeFeatures, ChannelError> {
11548
- if let Some(channel_type) = &common_fields.channel_type {
11549
- if channel_type.supports_any_optional_bits() {
11550
- return Err(ChannelError::close("Channel Type field contained optional bits - this is not allowed".to_owned()));
11551
- }
11539
+ let channel_type = common_fields.channel_type.as_ref()
11540
+ .ok_or_else(|| ChannelError::close("option_channel_type assumed to be supported".to_owned()))?;
11552
11541
11553
- // We only support the channel types defined by the `ChannelManager` in
11554
- // `provided_channel_type_features`. The channel type must always support
11555
- // `static_remote_key`, either implicitly with `option_zero_fee_commitments`
11556
- // or explicitly.
11557
- if !channel_type.requires_static_remote_key() && !channel_type.requires_anchor_zero_fee_commitments() {
11558
- return Err(ChannelError::close("Channel Type was not understood - we require static remote key".to_owned()));
11559
- }
11560
- // Make sure we support all of the features behind the channel type.
11561
- if channel_type.requires_unknown_bits_from(&our_supported_features) {
11562
- return Err(ChannelError::close("Channel Type contains unsupported features".to_owned()));
11563
- }
11564
- let announce_for_forwarding = if (common_fields.channel_flags & 1) == 1 { true } else { false };
11565
- if channel_type.requires_scid_privacy() && announce_for_forwarding {
11566
- return Err(ChannelError::close("SCID Alias/Privacy Channel Type cannot be set on a public channel".to_owned()));
11567
- }
11568
- Ok(channel_type.clone())
11569
- } else {
11570
- let channel_type = ChannelTypeFeatures::from_init(&their_features);
11571
- if channel_type != ChannelTypeFeatures::only_static_remote_key() {
11572
- return Err(ChannelError::close("Only static_remote_key is supported for non-negotiated channel types".to_owned()));
11573
- }
11574
- Ok(channel_type)
11542
+ if channel_type.supports_any_optional_bits() {
11543
+ return Err(ChannelError::close("Channel Type field contained optional bits - this is not allowed".to_owned()));
11544
+ }
11545
+
11546
+ // We only support the channel types defined by the `ChannelManager` in
11547
+ // `provided_channel_type_features`. The channel type must always support
11548
+ // `static_remote_key`, either implicitly with `option_zero_fee_commitments`
11549
+ // or explicitly.
11550
+ if !channel_type.requires_static_remote_key() && !channel_type.requires_anchor_zero_fee_commitments() {
11551
+ return Err(ChannelError::close("Channel Type was not understood - we require static remote key".to_owned()));
11552
+ }
11553
+ // Make sure we support all of the features behind the channel type.
11554
+ if channel_type.requires_unknown_bits_from(&our_supported_features) {
11555
+ return Err(ChannelError::close("Channel Type contains unsupported features".to_owned()));
11575
11556
}
11557
+ let announce_for_forwarding = if (common_fields.channel_flags & 1) == 1 { true } else { false };
11558
+ if channel_type.requires_scid_privacy() && announce_for_forwarding {
11559
+ return Err(ChannelError::close("SCID Alias/Privacy Channel Type cannot be set on a public channel".to_owned()));
11560
+ }
11561
+ Ok(channel_type.clone())
11576
11562
}
11577
11563
11578
11564
impl<SP: Deref> InboundV1Channel<SP>
@@ -11596,7 +11582,7 @@ where
11596
11582
11597
11583
// First check the channel type is known, failing before we do anything else if we don't
11598
11584
// support this channel type.
11599
- let channel_type = channel_type_from_open_channel(&msg.common_fields, their_features, our_supported_features)?;
11585
+ let channel_type = channel_type_from_open_channel(&msg.common_fields, our_supported_features)?;
11600
11586
11601
11587
let holder_selected_channel_reserve_satoshis = get_holder_selected_channel_reserve_satoshis(msg.common_fields.funding_satoshis, config);
11602
11588
let counterparty_pubkeys = ChannelPublicKeys {
@@ -11993,13 +11979,7 @@ where
11993
11979
let holder_selected_channel_reserve_satoshis = get_v2_channel_reserve_satoshis(
11994
11980
channel_value_satoshis, MIN_CHAN_DUST_LIMIT_SATOSHIS);
11995
11981
11996
- // First check the channel type is known, failing before we do anything else if we don't
11997
- // support this channel type.
11998
- if msg.common_fields.channel_type.is_none() {
11999
- return Err(ChannelError::close(format!("Rejecting V2 channel {} missing channel_type",
12000
- msg.common_fields.temporary_channel_id)))
12001
- }
12002
- let channel_type = channel_type_from_open_channel(&msg.common_fields, their_features, our_supported_features)?;
11982
+ let channel_type = channel_type_from_open_channel(&msg.common_fields, our_supported_features)?;
12003
11983
12004
11984
let counterparty_pubkeys = ChannelPublicKeys {
12005
11985
funding_pubkey: msg.common_fields.funding_pubkey,
0 commit comments