Skip to content

Commit ef441ac

Browse files
committed
Default to anchor channels
Set `negotiate_anchors_zero_fee_htlc_tx` default to true.
1 parent 813c014 commit ef441ac

File tree

8 files changed

+25
-18
lines changed

8 files changed

+25
-18
lines changed

fuzz/src/chanmon_consistency.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -710,8 +710,8 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
710710
config.channel_config.forwarding_fee_proportional_millionths = 0;
711711
config.channel_handshake_config.announce_for_forwarding = true;
712712
config.reject_inbound_splices = false;
713-
if anchors {
714-
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
713+
if !anchors {
714+
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = false;
715715
}
716716
let network = Network::Bitcoin;
717717
let best_block_timestamp = genesis_block(network).header.time;
@@ -760,8 +760,8 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
760760
config.channel_config.forwarding_fee_proportional_millionths = 0;
761761
config.channel_handshake_config.announce_for_forwarding = true;
762762
config.reject_inbound_splices = false;
763-
if anchors {
764-
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
763+
if !anchors {
764+
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = false;
765765
}
766766

767767
let mut monitors = new_hash_map();

lightning-background-processor/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2465,6 +2465,8 @@ mod tests {
24652465
));
24662466
let best_block = BestBlock::from_network(network);
24672467
let params = ChainParameters { network, best_block };
2468+
let mut config = UserConfig::default();
2469+
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = false;
24682470
let manager = Arc::new(ChannelManager::new(
24692471
Arc::clone(&fee_estimator),
24702472
Arc::clone(&chain_monitor),
@@ -2475,7 +2477,7 @@ mod tests {
24752477
Arc::clone(&keys_manager),
24762478
Arc::clone(&keys_manager),
24772479
Arc::clone(&keys_manager),
2478-
UserConfig::default(),
2480+
config,
24792481
params,
24802482
genesis_block.header.time,
24812483
));

lightning/src/ln/channel.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16280,7 +16280,8 @@ mod tests {
1628016280

1628116281
// Create Node A's channel pointing to Node B's pubkey
1628216282
let node_b_node_id = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap());
16283-
let config = UserConfig::default();
16283+
let mut config = UserConfig::default();
16284+
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = false;
1628416285
let mut node_a_chan = OutboundV1Channel::<&TestKeysInterface>::new(&feeest, &&keys_provider, &&keys_provider, node_b_node_id, &channelmanager::provided_init_features(&config), 10000000, 100000, 42, &config, 0, 42, None, &logger).unwrap();
1628516286

1628616287
// Create Node B's channel by receiving Node A's open_channel message
@@ -16370,7 +16371,8 @@ mod tests {
1637016371
let logger = TestLogger::new();
1637116372

1637216373
let node_id = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap());
16373-
let config = UserConfig::default();
16374+
let mut config = UserConfig::default();
16375+
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = false;
1637416376
let mut chan = OutboundV1Channel::<&TestKeysInterface>::new(&fee_est, &&keys_provider, &&keys_provider, node_id, &channelmanager::provided_init_features(&config), 10000000, 100000, 42, &config, 0, 42, None, &logger).unwrap();
1637516377

1637616378
let commitment_tx_fee_0_htlcs = commit_tx_fee_sat(chan.context.feerate_per_kw, 0, chan.funding.get_channel_type()) * 1000;

lightning/src/ln/channel_open_tests.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,7 @@ fn test_0conf_limiting() {
172172

173173
#[test]
174174
fn test_inbound_anchors_manual_acceptance() {
175-
let mut anchors_cfg = test_default_channel_config();
176-
anchors_cfg.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
175+
let anchors_cfg = test_default_anchors_channel_config();
177176
do_test_manual_inbound_accept_with_override(anchors_cfg, None);
178177
}
179178

@@ -191,9 +190,7 @@ fn test_inbound_anchors_config_overridden() {
191190
update_overrides: None,
192191
};
193192

194-
let mut anchors_cfg = test_default_channel_config();
195-
anchors_cfg.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
196-
193+
let mut anchors_cfg = test_default_anchors_channel_config();
197194
let accept_message = do_test_manual_inbound_accept_with_override(anchors_cfg, Some(overrides));
198195
assert_eq!(accept_message.common_fields.max_htlc_value_in_flight_msat, 5_000_000);
199196
assert_eq!(accept_message.common_fields.htlc_minimum_msat, 1_000);
@@ -1066,6 +1063,7 @@ pub fn test_user_configurable_csv_delay() {
10661063
pub fn test_accept_inbound_channel_config_override() {
10671064
let mut conf = UserConfig::default();
10681065
conf.channel_handshake_config.minimum_depth = 1;
1066+
conf.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = false;
10691067

10701068
let chanmon_cfgs = create_chanmon_cfgs(2);
10711069
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);

lightning/src/ln/channel_type_tests.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ fn test_option_anchors_zero_fee_initial() {
3434
let mut expected_type = ChannelTypeFeatures::only_static_remote_key();
3535
expected_type.set_anchors_zero_fee_htlc_tx_required();
3636

37+
let mut start_cfg = UserConfig::default();
38+
start_cfg.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = false;
3739
do_test_get_initial_channel_type(
38-
UserConfig::default(),
40+
start_cfg,
3941
InitFeatures::empty(),
4042
ChannelTypeFeatures::only_static_remote_key(),
4143
|cfg: &mut UserConfig| {
@@ -225,13 +227,15 @@ fn do_test_supports_channel_type(config: UserConfig, expected_channel_type: Chan
225227
let node_id_b =
226228
PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[2; 32]).unwrap());
227229

230+
let mut non_anchors_config = UserConfig::default();
231+
non_anchors_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = false;
228232
// Assert that we get `static_remotekey` when no custom config is negotiated.
229233
let channel_a = OutboundV1Channel::<&TestKeysInterface>::new(
230234
&fee_estimator,
231235
&&keys_provider,
232236
&&keys_provider,
233237
node_id_b,
234-
&channelmanager::provided_init_features(&UserConfig::default()),
238+
&channelmanager::provided_init_features(&non_anchors_config),
235239
10000000,
236240
100000,
237241
42,

lightning/src/ln/channelmanager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2047,7 +2047,7 @@ where
20472047
///
20482048
/// ## Opening Channels
20492049
///
2050-
/// To an open a channel with a peer, call [`create_channel`]. This will initiate the process of
2050+
/// To open a channel with a peer, call [`create_channel`]. This will initiate the process of
20512051
/// opening an outbound channel, which requires self-funding when handling
20522052
/// [`Event::FundingGenerationReady`].
20532053
///
@@ -5388,7 +5388,7 @@ where
53885388
/// using [`ChannelMonitorUpdateStatus::InProgress`]), the payment may be lost on restart. See
53895389
/// [`ChannelManager::list_recent_payments`] for more information.
53905390
///
5391-
/// Routes are automatically found using the [`Router] provided on startup. To fix a route for a
5391+
/// Routes are automatically found using the [`Router`] provided on startup. To fix a route for a
53925392
/// particular payment, use [`Self::send_payment_with_route`] or match the [`PaymentId`] passed to
53935393
/// [`Router::find_route_with_id`].
53945394
///

lightning/src/ln/functional_test_utils.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4555,6 +4555,7 @@ pub fn create_node_cfgs_with_node_id_message_router<'a>(
45554555

45564556
pub fn test_default_channel_config() -> UserConfig {
45574557
let mut default_config = UserConfig::default();
4558+
default_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = false;
45584559
// Set cltv_expiry_delta slightly lower to keep the final CLTV values inside one byte in our
45594560
// tests so that our script-length checks don't fail (see ACCEPTED_HTLC_SCRIPT_WEIGHT).
45604561
default_config.channel_config.cltv_expiry_delta = MIN_CLTV_EXPIRY_DELTA;

lightning/src/util/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ pub struct ChannelHandshakeConfig {
180180
/// counterparties that do not support the `anchors_zero_fee_htlc_tx` option; we will simply
181181
/// fall back to a `static_remote_key` channel.
182182
///
183-
/// Default value: `false` (This value is likely to change to `true` in the future.)
183+
/// Default value: `true`
184184
///
185185
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
186186
/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
@@ -256,7 +256,7 @@ impl Default for ChannelHandshakeConfig {
256256
announce_for_forwarding: false,
257257
commit_upfront_shutdown_pubkey: true,
258258
their_channel_reserve_proportional_millionths: 10_000,
259-
negotiate_anchors_zero_fee_htlc_tx: false,
259+
negotiate_anchors_zero_fee_htlc_tx: true,
260260
negotiate_anchor_zero_fee_commitments: false,
261261
our_max_accepted_htlcs: 50,
262262
}

0 commit comments

Comments
 (0)