Skip to content

Commit aebcd1f

Browse files
committed
Default to anchor channels
Set `negotiate_anchors_zero_fee_htlc_tx` default to true.
1 parent cad035d commit aebcd1f

9 files changed

Lines changed: 43 additions & 18 deletions

File tree

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
@@ -2447,6 +2447,8 @@ mod tests {
24472447
));
24482448
let best_block = BestBlock::from_network(network);
24492449
let params = ChainParameters { network, best_block };
2450+
let mut config = UserConfig::default();
2451+
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = false;
24502452
let manager = Arc::new(ChannelManager::new(
24512453
Arc::clone(&fee_estimator),
24522454
Arc::clone(&chain_monitor),
@@ -2457,7 +2459,7 @@ mod tests {
24572459
Arc::clone(&keys_manager),
24582460
Arc::clone(&keys_manager),
24592461
Arc::clone(&keys_manager),
2460-
UserConfig::default(),
2462+
config,
24612463
params,
24622464
genesis_block.header.time,
24632465
));

lightning/src/ln/channel.rs

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

1602716027
// Create Node A's channel pointing to Node B's pubkey
1602816028
let node_b_node_id = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap());
16029-
let config = UserConfig::default();
16029+
let mut config = UserConfig::default();
16030+
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = false;
1603016031
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();
1603116032

1603216033
// Create Node B's channel by receiving Node A's open_channel message
@@ -16116,7 +16117,8 @@ mod tests {
1611616117
let logger = TestLogger::new();
1611716118

1611816119
let node_id = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap());
16119-
let config = UserConfig::default();
16120+
let mut config = UserConfig::default();
16121+
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = false;
1612016122
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();
1612116123

1612216124
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
@@ -2028,7 +2028,7 @@ impl<
20282028
///
20292029
/// ## Opening Channels
20302030
///
2031-
/// To an open a channel with a peer, call [`create_channel`]. This will initiate the process of
2031+
/// To open a channel with a peer, call [`create_channel`]. This will initiate the process of
20322032
/// opening an outbound channel, which requires self-funding when handling
20332033
/// [`Event::FundingGenerationReady`].
20342034
///
@@ -5344,7 +5344,7 @@ impl<
53445344
/// using [`ChannelMonitorUpdateStatus::InProgress`]), the payment may be lost on restart. See
53455345
/// [`ChannelManager::list_recent_payments`] for more information.
53465346
///
5347-
/// Routes are automatically found using the [`Router] provided on startup. To fix a route for a
5347+
/// Routes are automatically found using the [`Router`] provided on startup. To fix a route for a
53485348
/// particular payment, use [`Self::send_payment_with_route`] or match the [`PaymentId`] passed to
53495349
/// [`Router::find_route_with_id`].
53505350
///

lightning/src/ln/functional_test_utils.rs

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

45354535
pub fn test_default_channel_config() -> UserConfig {
45364536
let mut default_config = UserConfig::default();
4537+
default_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = false;
45374538
// Set cltv_expiry_delta slightly lower to keep the final CLTV values inside one byte in our
45384539
// tests so that our script-length checks don't fail (see ACCEPTED_HTLC_SCRIPT_WEIGHT).
45394540
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
@@ -178,7 +178,7 @@ pub struct ChannelHandshakeConfig {
178178
/// counterparties that do not support the `anchors_zero_fee_htlc_tx` option; we will simply
179179
/// fall back to a `static_remote_key` channel.
180180
///
181-
/// Default value: `false` (This value is likely to change to `true` in the future.)
181+
/// Default value: `true`
182182
///
183183
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
184184
/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
@@ -252,7 +252,7 @@ impl Default for ChannelHandshakeConfig {
252252
announce_for_forwarding: false,
253253
commit_upfront_shutdown_pubkey: true,
254254
their_channel_reserve_proportional_millionths: 10_000,
255-
negotiate_anchors_zero_fee_htlc_tx: false,
255+
negotiate_anchors_zero_fee_htlc_tx: true,
256256
negotiate_anchor_zero_fee_commitments: false,
257257
our_max_accepted_htlcs: 50,
258258
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# API Updates
2+
3+
* `ChannelHandshakeConfig::negotiate_anchors_zero_fee_htlc_tx`
4+
now defaults to `true` (previously `false`). This means anchor output channels
5+
will be negotiated by default for all new channels if the counterparty supports
6+
it, requiring users to maintain an on-chain reserve for fee bumping in the
7+
event of force-closes.
8+
9+
* All inbound channels now require manual acceptance.
10+
`UserConfig::manually_accept_inbound_channels` has been removed, and
11+
`Event::OpenChannelRequest` will now always be generated for inbound channel
12+
requests. Users must handle this event and call either
13+
`ChannelManager::accept_inbound_channel` (or
14+
`accept_inbound_channel_from_trusted_peer_0conf` for zero-conf channels) to
15+
accept the channel, or `ChannelManager::force_close_broadcasting_latest_txn`
16+
to reject it. This ensures users can verify they have sufficient on-chain
17+
funds before accepting channels with anchor outputs.
18+

0 commit comments

Comments
 (0)