@@ -13005,6 +13005,12 @@ pub fn provided_init_features(config: &UserConfig) -> InitFeatures {
1300513005 // quiescent-dependent protocols (e.g., splicing).
1300613006 #[cfg(any(test, fuzzing))]
1300713007 features.set_quiescence_optional();
13008+
13009+ #[cfg(test)]
13010+ if config.channel_handshake_config.negotiate_anchor_zero_fee_commitments {
13011+ features.set_anchor_zero_fee_commitments_optional();
13012+ }
13013+
1300813014 features
1300913015}
1301013016
@@ -16371,29 +16377,71 @@ mod tests {
1637116377
1637216378 #[test]
1637316379 fn test_scid_privacy_downgrade() {
16374- // Tests downgrade from `anchors_zero_fee_htlc_tx ` with `option_scid_alias` when the
16380+ // Tests downgrade from `anchors_zero_fee_commitments ` with `option_scid_alias` when the
1637516381 // remote node advertises the features but does not accept the channel, asserting that
1637616382 // `option_scid_alias` is the last feature to be downgraded.
1637716383 let mut initiator_cfg = test_default_channel_config();
16384+ initiator_cfg.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
1637816385 initiator_cfg.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
1637916386 initiator_cfg.channel_handshake_config.negotiate_scid_privacy = true;
1638016387 initiator_cfg.channel_handshake_config.announce_for_forwarding = false;
1638116388
1638216389 let mut receiver_cfg = test_default_channel_config();
16390+ receiver_cfg.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
1638316391 receiver_cfg.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
1638416392 receiver_cfg.channel_handshake_config.negotiate_scid_privacy = true;
1638516393 receiver_cfg.manually_accept_inbound_channels = true;
1638616394
16387- let mut start_type = ChannelTypeFeatures::anchors_zero_htlc_fee_and_dependencies ();
16395+ let mut start_type = ChannelTypeFeatures::anchors_zero_fee_commitments ();
1638816396 start_type.set_scid_privacy_required();
16397+ let mut with_anchors = ChannelTypeFeatures::anchors_zero_htlc_fee_and_dependencies();
16398+ with_anchors.set_scid_privacy_required();
1638916399 let mut with_scid_privacy = ChannelTypeFeatures::only_static_remote_key();
1639016400 with_scid_privacy.set_scid_privacy_required();
1639116401 let static_remote = ChannelTypeFeatures::only_static_remote_key();
16392- let downgrade_types = vec![with_scid_privacy, static_remote];
16402+ let downgrade_types = vec![with_anchors, with_scid_privacy, static_remote];
16403+
16404+ do_test_channel_type_downgrade(initiator_cfg, receiver_cfg, start_type, downgrade_types);
16405+ }
16406+
16407+ #[test]
16408+ fn test_zero_fee_commitments_downgrade() {
16409+ // Tests that the local node will retry without zero fee commitments in the case where the
16410+ // remote node supports the feature but does not accept it.
16411+ let mut initiator_cfg = test_default_channel_config();
16412+ initiator_cfg.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
16413+ initiator_cfg.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
16414+
16415+ let mut receiver_cfg = test_default_channel_config();
16416+ receiver_cfg.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
16417+ receiver_cfg.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
16418+ receiver_cfg.manually_accept_inbound_channels = true;
1639316419
16420+ let start_type = ChannelTypeFeatures::anchors_zero_fee_commitments();
16421+ let downgrade_types = vec![
16422+ ChannelTypeFeatures::anchors_zero_htlc_fee_and_dependencies(),
16423+ ChannelTypeFeatures::only_static_remote_key(),
16424+ ];
1639416425 do_test_channel_type_downgrade(initiator_cfg, receiver_cfg, start_type, downgrade_types);
1639516426 }
1639616427
16428+ #[test]
16429+ fn test_zero_fee_commitments_downgrade_to_static_remote() {
16430+ // Tests that the local node will retry with static remote key when zero fee commitments
16431+ // are supported (but not accepted), but not legacy anchors.
16432+ let mut initiator_cfg = test_default_channel_config();
16433+ initiator_cfg.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
16434+ initiator_cfg.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
16435+
16436+ let mut receiver_cfg = test_default_channel_config();
16437+ receiver_cfg.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
16438+ receiver_cfg.manually_accept_inbound_channels = true;
16439+
16440+ let start_type = ChannelTypeFeatures::anchors_zero_fee_commitments();
16441+ let end_type = ChannelTypeFeatures::only_static_remote_key();
16442+ do_test_channel_type_downgrade(initiator_cfg, receiver_cfg, start_type, vec![end_type]);
16443+ }
16444+
1639716445 #[rustfmt::skip]
1639816446 fn do_test_channel_type_downgrade(initiator_cfg: UserConfig, acceptor_cfg: UserConfig,
1639916447 start_type: ChannelTypeFeatures, downgrade_types: Vec<ChannelTypeFeatures>) {
0 commit comments