Skip to content

Commit e6e0778

Browse files
committed
Negotiate 0FC channels if the anchor config is set
1 parent 5e4ab12 commit e6e0778

3 files changed

Lines changed: 14 additions & 18 deletions

File tree

src/config.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,17 @@ pub struct Config {
170170
/// used to send pre-flight probes.
171171
pub probing_liquidity_limit_multiplier: u64,
172172
/// Configuration options pertaining to Anchor channels, i.e., channels for which the
173-
/// `option_anchors_zero_fee_htlc_tx` channel type is negotiated.
173+
/// `option_zero_fee_commitments` or `option_anchors_zero_fee_htlc_tx` channel type is
174+
/// negotiated.
174175
///
175176
/// Please refer to [`AnchorChannelsConfig`] for further information on Anchor channels.
176177
///
177178
/// If set to `Some`, we'll try to open new channels with Anchors enabled, i.e., new channels
178-
/// will be negotiated with the `option_anchors_zero_fee_htlc_tx` channel type if supported by
179-
/// the counterparty. Note that this won't prevent us from opening non-Anchor channels if the
180-
/// counterparty doesn't support `option_anchors_zero_fee_htlc_tx`. If set to `None`, new
181-
/// channels will be negotiated with the legacy `option_static_remotekey` channel type only.
179+
/// will be negotiated with the `option_zero_fee_commitments` channel type first, then the
180+
/// `option_anchors_zero_fee_htlc_tx` channel type if supported by the counterparty. Note
181+
/// that this won't prevent us from opening non-Anchor channels if the counterparty doesn't
182+
/// support `option_anchors_zero_fee_htlc_tx`. If set to `None`, new channels will be
183+
/// negotiated with the legacy `option_static_remotekey` channel type only.
182184
///
183185
/// **Note:** If set to `None` *after* some Anchor channels have already been
184186
/// opened, no dedicated emergency on-chain reserve will be maintained for these channels,
@@ -281,7 +283,7 @@ impl Default for HumanReadableNamesConfig {
281283
}
282284

283285
/// Configuration options pertaining to 'Anchor' channels, i.e., channels for which the
284-
/// `option_anchors_zero_fee_htlc_tx` channel type is negotiated.
286+
/// `option_zero_fee_commitments` or `option_anchors_zero_fee_htlc_tx` channel type is negotiated.
285287
///
286288
/// Prior to the introduction of Anchor channels, the on-chain fees paying for the transactions
287289
/// issued on channel closure were pre-determined and locked-in at the time of the channel
@@ -403,6 +405,8 @@ pub(crate) fn default_user_config(config: &Config) -> UserConfig {
403405
user_config.channel_handshake_limits.force_announced_channel_preference = false;
404406
user_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx =
405407
config.anchor_channels_config.is_some();
408+
user_config.channel_handshake_config.negotiate_anchor_zero_fee_commitments =
409+
config.anchor_channels_config.is_some();
406410
user_config.reject_inbound_splices = false;
407411

408412
if may_announce_channel(config).is_err() {

tests/common/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1407,7 +1407,7 @@ pub(crate) async fn do_channel_full_cycle<E: ElectrumApi>(
14071407
// TODO: Zero-fee commitment channels are anchor channels, but do not allocate any
14081408
// funds to the anchor, so this will need to be updated when we ship these channels
14091409
// in ldk-node.
1410-
let node_a_anchors_msat = if expect_anchor_channel { 2 * 330 * 1000 } else { 0 };
1410+
let node_a_anchors_msat = if expect_anchor_channel { 0 } else { 0 };
14111411
let funding_amount_msat = node_a.list_channels()[0].channel_value_sats * 1000;
14121412
// Node B does not have any reserve, so we only subtract a few items on node A's
14131413
// side to arrive at node B's capacity

tests/integration_tests_rust.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,17 +1023,12 @@ async fn splice_channel() {
10231023
let user_channel_id_b = expect_channel_ready_event!(node_b, node_a.node_id());
10241024

10251025
let opening_transaction_fee_sat = 156;
1026-
let closing_transaction_fee_sat = 614;
1027-
let anchor_output_sat = 330;
10281026

10291027
assert_eq!(
10301028
node_a.list_balances().total_onchain_balance_sats,
10311029
premine_amount_sat - 4_000_000 - opening_transaction_fee_sat
10321030
);
1033-
assert_eq!(
1034-
node_a.list_balances().total_lightning_balance_sats,
1035-
4_000_000 - closing_transaction_fee_sat - anchor_output_sat
1036-
);
1031+
assert_eq!(node_a.list_balances().total_lightning_balance_sats, 4_000_000);
10371032
assert_eq!(node_b.list_balances().total_lightning_balance_sats, 0);
10381033

10391034
// Test that splicing and payments fail when there are insufficient funds
@@ -1101,10 +1096,7 @@ async fn splice_channel() {
11011096
// Mine a block to give time for the HTLC to resolve
11021097
generate_blocks_and_wait(&bitcoind.client, &electrsd.client, 1).await;
11031098

1104-
assert_eq!(
1105-
node_a.list_balances().total_lightning_balance_sats,
1106-
4_000_000 - closing_transaction_fee_sat - anchor_output_sat + amount_msat / 1000
1107-
);
1099+
assert_eq!(node_a.list_balances().total_lightning_balance_sats, 4_000_000 + amount_msat / 1000);
11081100
assert_eq!(
11091101
node_b.list_balances().total_lightning_balance_sats,
11101102
expected_splice_in_lightning_balance_sat - amount_msat / 1000
@@ -1138,7 +1130,7 @@ async fn splice_channel() {
11381130
);
11391131
assert_eq!(
11401132
node_a.list_balances().total_lightning_balance_sats,
1141-
4_000_000 - closing_transaction_fee_sat - anchor_output_sat - expected_splice_out_fee_sat
1133+
4_000_000 - expected_splice_out_fee_sat
11421134
);
11431135
}
11441136

0 commit comments

Comments
 (0)