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

wallet: handle bwatch wallet/utxo spend notifications

Public commit record

What the developer wrote

Authored by Sangbida Chaudhuri

73/100 · Adequate
wallet: handle bwatch wallet/utxo spend notifications

When bwatch_got_utxo() records a wallet output, it arms an outpoint
watch owned by wallet/utxo/<txid>:<outnum>. This adds the receiving
end of that watch: the dispatch entry plus the found/revert handlers.

On watch_found (a tx consumed the outpoint): mark the output spent in
our_outputs, store the spending tx in our_txs, and emit a withdrawal
coin movement. On watch_revert (a reorg removed that tx): clear
spendheight so the UTXO is spendable again.

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 commit adds the missing bookkeeping that runs when Core Lightning's own on-chain wallet spends a UTXO. It makes the node mark the UTXO as spent, record the spending transaction, and log a withdrawal coin movement. It also handles blockchain reorgs by unmarking the UTXO so it can be spent again. There is no direct evidence this fixes an exploitable vulnerability; it appears to be a correctness/ledger-integrity improvement.

Recommended action

Treat as a routine correctness fix. Reviewers should verify that the watch owner suffix format always matches owner_wallet_utxo(), that wallet_utxo_get() cannot return NULL under normal operation, and that clearing spendheight on reorg interacts safely with any existing coin-selection and RBF logic. No urgent security action is indicated by the diff alone.

Security signals we found

01

Missing spend tracking for wallet-owned UTXOs could lead to stale UTXO state or incorrect coin-movement accounting

02

Reorg handling clears spendheight, preventing a spent output from becoming permanently unspendable in the wallet's view

03

Defensive log_broken calls on unexpected missing UTXO or malformed watch suffix

04

No input validation beyond suffix parsing; relies on watch owner string format produced by owner_wallet_utxo()

Risk score

Why this scored 24/100

Our methodology →
Potential impact 5/30
Exploitability 2/25
Stealth signal 3/15
Affected reach 4/15
Confidence 7/10
Evidence quality 3/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.