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

bwatch: send chaininfo to watchman on startup

Public commit record

What the developer wrote

Authored by Sangbida Chaudhuri

68/100 · Adequate
bwatch: send chaininfo to watchman on startup

On init, query bcli for chain name, headercount, blockcount and IBD
state, then forward the result to watchman via the chaininfo RPC
before bwatch starts its normal poll loop. Watchman uses this to
gate any work that depends on bitcoind being synced.

If bitcoind's blockcount comes back lower than our persisted tip,
peel stored blocks off until they line up so watchman gets a
consistent picture. During steady-state polling the same case is
handled by hash-mismatch reorg detection inside handle_block; this
shortcut only matters at startup, before we've fetched anything.

If bcli or watchman is not yet ready, log and fall back to scheduling
the poll loop anyway so init never stalls.

bwatch_remove_tip is exposed in bwatch.h so the chaininfo path in
bwatch_interface.c can use it.
✓ 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 defensive startup fix for the bwatch plugin in Core Lightning. It makes the plugin check Bitcoin's sync status and share it with another component (watchman) before starting normal block polling. It also rolls back the plugin's stored block tip if Bitcoin appears to have a shorter chain at startup. The commit does not appear to fix an active exploit; it is more like adding a safety check to prevent inconsistent state when a node restarts while Bitcoin is still syncing or has reorged.

Recommended action

Treat as a normal reliability/consistency improvement. Reviewers should verify that the rollback loop cannot remove more blocks than intended and that current_height is updated consistently inside bwatch_remove_tip. No urgent security action is indicated from the diff alone.

Security signals we found

01

Startup state synchronization between bwatch and watchman to avoid acting on stale or unsynced chain data

02

Rollback of persisted block history when local bitcoind chain is shorter than stored tip, reducing risk of inconsistent state after restart

03

Non-fatal fallback paths prevent init from stalling if dependencies are not ready

04

Existing error log downgraded from LOG_BROKEN to LOG_DBG, reflecting that watchman-not-ready is an expected transient condition

Risk score

Why this scored 23/100

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