Skip to content

Commit 505dbdb

Browse files
committed
ln: do not automatically accept zero fee commitment channels
Like anchor channels, these channels require that the user reserves a UTXO to bump the channel. If we automatically accept this channel type and the user does not have such reserve available, they are at risk of losing funds because they cannot fee bump the channel.
1 parent 6a71d9e commit 505dbdb

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8372,7 +8372,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
83728372
if channel_type.requires_zero_conf() {
83738373
return Err(MsgHandleErrInternal::send_err_msg_no_close("No zero confirmation channels accepted".to_owned(), common_fields.temporary_channel_id));
83748374
}
8375-
if channel_type.requires_anchors_zero_fee_htlc_tx() {
8375+
if channel_type.requires_anchors_zero_fee_htlc_tx() || channel_type.requires_anchor_zero_fee_commitments() {
83768376
return Err(MsgHandleErrInternal::send_err_msg_no_close("No channels with anchor outputs accepted".to_owned(), common_fields.temporary_channel_id));
83778377
}
83788378

@@ -16320,6 +16320,13 @@ mod tests {
1632016320
assert_eq!(accept_message.channel_reserve_satoshis, 2_000);
1632116321
}
1632216322

16323+
#[test]
16324+
fn test_inbound_zero_fee_commitments_manual_acceptance() {
16325+
let mut zero_fee_cfg = test_default_channel_config();
16326+
zero_fee_cfg.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
16327+
do_test_manual_inbound_accept_with_override(zero_fee_cfg, None);
16328+
}
16329+
1632316330
#[rustfmt::skip]
1632416331
fn do_test_manual_inbound_accept_with_override(start_cfg: UserConfig,
1632516332
config_overrides: Option<ChannelConfigOverrides>) -> AcceptChannel {

0 commit comments

Comments
 (0)