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