Add channel close and force-close by channel id#40
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.