Skip to content

bkpr: don't exit when an account's debits exceed its credits - #9488

Open
ksedgwic wants to merge 1 commit into
ElementsProject:masterfrom
ksedgwic:fix-bkpr-listbalances-fatal-underflow
Open

bkpr: don't exit when an account's debits exceed its credits#9488
ksedgwic wants to merge 1 commit into
ElementsProject:masterfrom
ksedgwic:fix-bkpr-listbalances-fatal-underflow

Conversation

@ksedgwic

@ksedgwic ksedgwic commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

bkpr-listbalances calls plugin_err when an account's debits exceed its credits. The bookkeeper is an important plugin, so lightningd shuts down with it. Fixes #9487.

The commit replaces the plugin_err with a BROKEN log and reports that account as 0msat, the way 29e0a1d handles a missing open event. The test corrupts one channel_moves row in a stopped node's database, so the next bkpr-listbalances sees debits above credits without a replay.

bkpr-listbalances calls plugin_err when the debit sum for an account is
larger than its credit sum.  The bookkeeper is an important plugin, so
lightningd shuts down with it:

  plugin-bookkeeper: Account balance underflow for account 906c4056... (credit 25339109661msat, debit 25351660836msat)
  plugin-bookkeeper: Killing plugin: exited during normal operation
  Plugin marked as important, shutting down lightningd!

An inconsistent ledger is a bookkeeping defect, not a reason to stop the
node, and no other bkpr command treats it as fatal.  Three different
accounting bugs have reached this exit so far (ElementsProject#5557, ElementsProject#8549, and now one
on a node that already has the ElementsProject#8574 dedup); each time it took the node
down.  Log it as BROKEN and report that account's balance as 0msat, as
29e0a1d already does for a missing open event.

Changelog-Fixed: Plugins: `bkpr-listbalances` no longer exits, taking lightningd down with it, when an account's debits exceed its credits; the inconsistency is logged and that account is reported as 0msat.
Fixes: ElementsProject#9487
@ksedgwic
ksedgwic requested a review from cdecker as a code owner September 8, 2026 23:57
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.

bkpr-listbalances takes lightningd down when an account's debits exceed its credits

1 participant