Skip to content

Commit 08e6a0f

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 3815fce commit 08e6a0f

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

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

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

0 commit comments

Comments
 (0)