Skip to content

ChannelMonitor balances don't reflect preimages for other channels #2153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
TheBlueMatt opened this issue Apr 5, 2023 · 0 comments · Fixed by #3450
Closed

ChannelMonitor balances don't reflect preimages for other channels #2153

TheBlueMatt opened this issue Apr 5, 2023 · 0 comments · Fixed by #3450
Milestone

Comments

@TheBlueMatt
Copy link
Collaborator

If a ChannelMonitor has a preimage in it that we need to claim an HTLC on a different channel, that ChannelMonior's balance set may still be empty, despite the fact that we absolutely cannot archive/remove it.

@TheBlueMatt TheBlueMatt added this to the 0.1 milestone Apr 5, 2023
TheBlueMatt added a commit to TheBlueMatt/rust-lightning that referenced this issue Dec 8, 2024
When a `ChannelMonitor` sees a payment preimage on chain for an
outbound HTLC, it creates a `MonitorEvent` containing the preimage
to pass to the inbound edge. The inclusion of the transaction
containing the payment preimage (plus six confirmations) also
results in the corresponding `Balance` being removed from the live
balance set, allowing the `ChannelMonitor` to be pruned (after a
further 4032 blocks).

While `MonitorEvent`s should always be processed in a timely
manner, if a node is suffering from a bug  where they are not, its
possible for 4038 blocks to pass with the preimage-containing
`MonitorEvent` still pending. If that happens, its possible the
`ChannelMonitor` is archived even though the preimage in it is
needed in another channel (or `ChannelMonitor`), causing funds
loss.

Luckily the fix is simple - check for pending events before
allowing a `ChannelMonitor` to be archived.

Fixes lightningdevkit#2153
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 a pull request may close this issue.

1 participant