@@ -3838,12 +3838,10 @@ where
38383838 return Err(ChannelError::close("Got an accept_channel message at a strange time".to_owned()));
38393839 }
38403840
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 {
3846- return Err(ChannelError::close("channel_type assumed to be supported".to_owned()));
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()));
38473845 }
38483846
38493847 if common_fields.dust_limit_satoshis > 21000000 * 100000000 {
@@ -11538,30 +11536,29 @@ where
1153811536pub(super) fn channel_type_from_open_channel(
1153911537 common_fields: &msgs::CommonOpenChannelFields, our_supported_features: &ChannelTypeFeatures
1154011538) -> Result<ChannelTypeFeatures, ChannelError> {
11541- if let Some(channel_type) = &common_fields.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- }
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()))?;
1154511541
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()));
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())
11562- } else {
11563- return Err(ChannelError::close("channel_type assumed to be supported ".to_owned()));
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()));
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()));
1156411560 }
11561+ Ok(channel_type.clone())
1156511562}
1156611563
1156711564impl<SP: Deref> InboundV1Channel<SP>
0 commit comments