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

lnd.go: sync headers before chain notifier startup to prevent premature rescan

Public commit record

What the developer wrote

Authored by Mohamed Awnallah

95/100 · Strong
lnd.go: sync headers before chain notifier startup to prevent premature rescan

This commit addresses a regression where Neutrino rescanning starts
from an outdated height (~100k blocks behind) instead of using the
current synced height.

Root Cause:
In commit 16a8b623b, the initialization order was changed so that
Chain Notifier starts before wallet syncing completes. This means
the rescan begins using the stale height from BuildChainControl
rather than the fully synced height.

Old behavior (commit 1dfb5a0c2):
1. RPC server starts
2. Headers sync as part of daemon server
3. Chain Notifier starts after sync completes
4. Rescan begins from current (synced) height

Current behavior (regression):
1. Chain Notifier starts in newServer (before RPC)
2. Wallet sync happens after RPC server starts
3. Rescan uses outdated height from BuildChainControl

Solution:
- Ensure headers are fully synced before starting the chain notifier,
and after starting the RPC server.
- Move chain notifier startup to its correct location after headers are
fully synced.
- Make sure the starting beat is lazily called after chain notifier
started and before that starting beat result is used.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode✓ Mentions testing or verification
The short version

What changed, and why it matters

This patch fixes a startup-order bug in the Lightning Network Daemon (LND). Because a previous change started the chain notifier before the wallet's block headers were fully synced, rescans could begin from an old block height roughly 100,000 blocks behind the current chain tip. The fix moves chain notifier startup to after header synchronization and delays the 'starting beat' block reference until after the notifier is running. The main risk is operational/money-loss: a node that rescans from a stale height can miss recent on-chain events such as channel closes, force-closes, or swept funds, which may lead to incorrect balances or delayed detection of transactions. It is not a remote code execution or direct theft vulnerability.

Recommended action

Nodes running affected LND versions with Neutrino or similar SPV backends should upgrade to a version containing this fix. Operators should verify that rescan heights are current after restart and monitor for missed on-chain events if they previously ran the regressed code. No immediate emergency response is required, but the fix should be included in the next maintenance release.

Security signals we found

01

Startup-order race between chain notifier and header sync

02

Rescan from stale block height (~100k blocks behind)

03

Potential missed on-chain events (channel closes, sweeps, force closes)

04

Operational integrity / balance accuracy impact

05

No input validation, authentication, or cryptography change

Risk score

Why this scored 43/100

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