Skip to content

Commit 0e4aecc

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 f1cae54 commit 0e4aecc

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
@@ -8175,7 +8175,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
81758175
if channel_type.requires_zero_conf() {
81768176
return Err(MsgHandleErrInternal::send_err_msg_no_close("No zero confirmation channels accepted".to_owned(), common_fields.temporary_channel_id));
81778177
}
8178-
if channel_type.requires_anchors_zero_fee_htlc_tx() {
8178+
if channel_type.requires_anchors_zero_fee_htlc_tx() || channel_type.requires_anchor_zero_fee_commitments() {
81798179
return Err(MsgHandleErrInternal::send_err_msg_no_close("No channels with anchor outputs accepted".to_owned(), common_fields.temporary_channel_id));
81808180
}
81818181

@@ -16122,6 +16122,13 @@ mod tests {
1612216122
assert_eq!(accept_message.channel_reserve_satoshis, 2_000);
1612316123
}
1612416124

16125+
#[test]
16126+
fn test_inbound_zero_fee_commitments_acceptance() {
16127+
let mut zero_fee_cfg = test_default_channel_config();
16128+
zero_fee_cfg.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
16129+
do_test_manual_inbound_accept_with_override(zero_fee_cfg, None);
16130+
}
16131+
1612516132
fn do_test_manual_inbound_accept_with_override(start_cfg: UserConfig,
1612616133
config_overrides: Option<ChannelConfigOverrides>) -> AcceptChannel {
1612716134

0 commit comments

Comments
 (0)