Skip to content

Commit ece5f83

Browse files
committed
Add AnchorChannelsConfig::enable_zero_fee_commitments
This makes `option_anchors_zero_fee_htlc_tx` a prerequisite to `option_anchor_zero_fee_commitments`. While this is not technically required, we assume any user that wants to negotiate zero-fee commitments will also want to negotiate zero-fee htlc transactions.
1 parent 4cbd1bb commit ece5f83

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/config.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,11 @@ impl Default for Config {
216216
///
217217
/// ### Defaults
218218
///
219-
/// | Parameter | Value |
220-
/// |----------------------------|--------|
221-
/// | `trusted_peers_no_reserve` | [] |
222-
/// | `per_channel_reserve_sats` | 25000 |
219+
/// | Parameter | Value |
220+
/// |-------------------------------|--------|
221+
/// | `trusted_peers_no_reserve` | [] |
222+
/// | `per_channel_reserve_sats` | 25000 |
223+
/// | `enable_zero_fee_commitments` | false |
223224
///
224225
///
225226
/// [BOLT 3]: https://github.com/lightning/bolts/blob/master/03-transactions.md#htlc-timeout-and-htlc-success-transactions
@@ -254,13 +255,19 @@ pub struct AnchorChannelsConfig {
254255
/// might not suffice to successfully spend the Anchor output and have the HTLC transactions
255256
/// confirmed on-chain, i.e., you may want to adjust this value accordingly.
256257
pub per_channel_reserve_sats: u64,
258+
/// In addition to `option_anchors_zero_fee_htlc_tx`, we will also attempt to negotiate
259+
/// `option_anchor_zero_fee_commitments`. All the caveats and warnings in
260+
/// [`AnchorChannelsConfig`] still apply.
261+
/// [`AnchorChannelsConfig`]: Config::anchor_channels_config
262+
pub enable_zero_fee_commitments: bool,
257263
}
258264

259265
impl Default for AnchorChannelsConfig {
260266
fn default() -> Self {
261267
Self {
262268
trusted_peers_no_reserve: Vec::new(),
263269
per_channel_reserve_sats: DEFAULT_ANCHOR_PER_CHANNEL_RESERVE_SATS,
270+
enable_zero_fee_commitments: false,
264271
}
265272
}
266273
}
@@ -319,6 +326,8 @@ pub(crate) fn default_user_config(config: &Config) -> UserConfig {
319326
user_config.manually_accept_inbound_channels = true;
320327
user_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx =
321328
config.anchor_channels_config.is_some();
329+
user_config.channel_handshake_config.negotiate_anchor_zero_fee_commitments =
330+
config.anchor_channels_config.as_ref().map(|config| config.enable_zero_fee_commitments).unwrap_or(false);
322331

323332
if may_announce_channel(config).is_err() {
324333
user_config.accept_forwards_to_priv_channels = false;

0 commit comments

Comments
 (0)