@@ -13005,6 +13005,12 @@ pub fn provided_init_features(config: &UserConfig) -> InitFeatures {
13005
13005
// quiescent-dependent protocols (e.g., splicing).
13006
13006
#[cfg(any(test, fuzzing))]
13007
13007
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
+
13008
13014
features
13009
13015
}
13010
13016
@@ -16371,29 +16377,71 @@ mod tests {
16371
16377
16372
16378
#[test]
16373
16379
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
16375
16381
// remote node advertises the features but does not accept the channel, asserting that
16376
16382
// `option_scid_alias` is the last feature to be downgraded.
16377
16383
let mut initiator_cfg = test_default_channel_config();
16384
+ initiator_cfg.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
16378
16385
initiator_cfg.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
16379
16386
initiator_cfg.channel_handshake_config.negotiate_scid_privacy = true;
16380
16387
initiator_cfg.channel_handshake_config.announce_for_forwarding = false;
16381
16388
16382
16389
let mut receiver_cfg = test_default_channel_config();
16390
+ receiver_cfg.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
16383
16391
receiver_cfg.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
16384
16392
receiver_cfg.channel_handshake_config.negotiate_scid_privacy = true;
16385
16393
receiver_cfg.manually_accept_inbound_channels = true;
16386
16394
16387
- let mut start_type = ChannelTypeFeatures::anchors_zero_htlc_fee_and_dependencies ();
16395
+ let mut start_type = ChannelTypeFeatures::anchors_zero_fee_commitments ();
16388
16396
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();
16389
16399
let mut with_scid_privacy = ChannelTypeFeatures::only_static_remote_key();
16390
16400
with_scid_privacy.set_scid_privacy_required();
16391
16401
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;
16393
16419
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
+ ];
16394
16425
do_test_channel_type_downgrade(initiator_cfg, receiver_cfg, start_type, downgrade_types);
16395
16426
}
16396
16427
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
+
16397
16445
#[rustfmt::skip]
16398
16446
fn do_test_channel_type_downgrade(initiator_cfg: UserConfig, acceptor_cfg: UserConfig,
16399
16447
start_type: ChannelTypeFeatures, downgrade_types: Vec<ChannelTypeFeatures>) {
0 commit comments