AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Low 27 Bitcoin

wallet: mirror bwatch writes into legacy outputs table

Public commit record

What the developer wrote

Authored by Sangbida Chaudhuri

73/100 · Adequate
wallet: mirror bwatch writes into legacy outputs table

The bwatch path writes wallet UTXOs to our_outputs while the legacy
`outputs` table is what a downgraded binary reads. Mirror every
our_outputs write (insert, spend, unspend-on-spend-revert, reservation)
into `outputs` so a downgrade for one release needs no copy-back or
rescan. Reorg demotion needs no mirror: the legacy rows are demoted by
their blocks(height) foreign keys when chaintopology removes the block.
The mirroring stops in the release that removes chaintopology, freezing
all the legacy tables at the same height.

The spend mirror guards its spend_height the same way the insert guards
confirmation_height: outputs.spend_height has a foreign key on
blocks(height), which only chaintopology populates, and bwatch can
deliver the spend before chaintopology has processed that block.
Record NULL in that case (status already marks the row spent) and let
chaintopology's own spend pass fill in the height.

The wallet still reads from `outputs`; switching reads over to
our_outputs comes next.

Co-authored-by: Cursor <cursoragent@cursor.com>
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This change is a behind-the-scenes bookkeeping patch for Core Lightning's wallet database. The project is moving to a new table (`our_outputs`) for tracking spendable coins, but older versions of the software still read from the old table (`outputs`). The patch copies every new-table write back into the old table so that if a user downgrades to the previous release, their wallet still sees the correct coins and balances. It is not a fix for an externally exploitable bug; it is a compatibility/migration safeguard.

Recommended action

Treat as a normal code-quality/compatibility commit. Review the follow-up commit that switches wallet reads from `outputs` to `our_outputs` to ensure the legacy table is no longer relied on once mirroring ends. No urgent security action is required.

Security signals we found

01

Race-condition guard for foreign-key-backed confirmation_height and spend_height when bwatch is ahead of chaintopology

02

Temporary mirroring to keep legacy outputs table consistent with new our_outputs table

03

ON CONFLICT DO NOTHING used for legacy insert to avoid duplicate-key failures

04

No input validation changes; relies on existing db binding primitives

Risk score

Why this scored 27/100

Our methodology →
Potential impact 5/30
Exploitability 2/25
Stealth signal 3/15
Affected reach 5/15
Confidence 8/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.