Skip to content

Add channel close and force-close by channel id#40

Merged
amackillop merged 1 commit into
lsp-0.7.0from
austin_mdk-859_add-close-by-channel-id
Jun 25, 2026
Merged

Add channel close and force-close by channel id#40
amackillop merged 1 commit into
lsp-0.7.0from
austin_mdk-859_add-close-by-channel-id

Conversation

@amackillop

Copy link
Copy Markdown

close_channel and force_close_channel resolve the target by user_channel_id, scanning a counterparty's channels and acting on the first match. That breaks down here because every LSPS4-opened channel is created with user_channel_id = 0, so a counterparty holding more than one of them has several channels sharing the same id. The find then picks an arbitrary one and we close the wrong channel.

Add close_channel_by_id and force_close_channel_by_id, which target the unique ChannelId directly. The existing user_channel_id methods stay as they were and now resolve user_channel_id to a channel_id before delegating to the shared by-id path, so their behavior is unchanged and the close and peer-cleanup logic lives in one place.

This is what lets an operator close a specific channel, in particular a phantom 0conf channel that shares user_channel_id = 0 with a healthy channel to the same merchant.

This can be dropped once LSPS4 channels are opened with a random user_channel_id and the existing channels stuck on user_channel_id = 0 have been closed. At that point user_channel_id is unique again and the original close_channel path is no longer ambiguous.

close_channel and force_close_channel resolve the target by
user_channel_id, scanning a counterparty's channels and acting on the
first match. That breaks down here because every LSPS4-opened channel is
created with user_channel_id = 0, so a counterparty holding more than one
of them has several channels sharing the same id. The find then picks an
arbitrary one and we close the wrong channel.

Add close_channel_by_id and force_close_channel_by_id, which target the
unique ChannelId directly. The existing user_channel_id methods stay as
they were and now resolve user_channel_id to a channel_id before
delegating to the shared by-id path, so their behavior is unchanged and
the close and peer-cleanup logic lives in one place.

This is what lets an operator close a specific channel, in particular a
phantom 0conf channel that shares user_channel_id = 0 with a healthy
channel to the same merchant.

This can be dropped once LSPS4 channels are opened with a random
user_channel_id and the existing channels stuck on user_channel_id = 0
have been closed. At that point user_channel_id is unique again and the
original close_channel path is no longer ambiguous.
@amackillop amackillop merged commit f36b7f2 into lsp-0.7.0 Jun 25, 2026
4 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant