Skip to content

Protect wallet birthdays from reorg - #1274

Open
tankyleo wants to merge 2 commits into
lightningdevkit:mainfrom
tankyleo:2026-12-wallet-birthday-reorg
Open

tankyleo wants to merge 2 commits into
lightningdevkit:mainfrom
tankyleo:2026-12-wallet-birthday-reorg

Conversation

@tankyleo

@tankyleo tankyleo commented Dec 4, 2026

Copy link
Copy Markdown
Contributor
    Protect new wallets from reorgs near their birthday

    For wallets using Bitcoin Core, a reorg that removes the birthday
    checkpoint can leave BDK unable to connect replacement blocks to its saved
    checkpoints. The wallet then stops tracking the active chain: incoming
    payments can go undiscovered and balances can remain stale. Restarting
    reloads the same orphaned checkpoint, leaving the user needing wallet
    recovery.

    Using the current tip as the birthday exposes a newly created wallet to
    this failure after even a one-block reorg, including before its first
    sync. Avoiding historical scanning should not make ordinary chain
    reorganizations require user intervention.

    We budget for reorgs of up to 10 blocks. Accepting up to 10 additional
    blocks of initial scanning gives the wallet a checkpoint outside that
    window. This bounded startup cost is preferable to leaving a fresh wallet
    unable to synchronize until recovered.

    Co-Authored-By: Codex

For wallets using Bitcoin Core, a reorg that removes the birthday
checkpoint can leave BDK unable to connect replacement blocks to its saved
checkpoints. The wallet then stops tracking the active chain: incoming
payments can go undiscovered and balances can remain stale. Restarting
reloads the same orphaned checkpoint, leaving the user needing wallet
recovery.

Using the current tip as the birthday exposes a newly created wallet to
this failure after even a one-block reorg, including before its first
sync. Avoiding historical scanning should not make ordinary chain
reorganizations require user intervention.

We budget for reorgs of up to 10 blocks. Accepting up to 10 additional
blocks of initial scanning gives the wallet a checkpoint outside that
window. This bounded startup cost is preferable to leaving a fresh wallet
unable to synchronize until recovered.

Co-Authored-By: Codex
Requesting a recent rescan height should not leave a new Bitcoin Core
wallet more vulnerable to reorgs than using the default. If its birthday
checkpoint is removed, the wallet can stop following the active chain.
Restarting reloads the same checkpoint, leaving the user needing wallet
recovery.

Treat the requested height as history we must include, while retaining
at least the same 10-block margin as the default. Scanning a little
extra history is preferable to requiring wallet recovery after an
ordinary reorg, and earlier requests must never lose any requested
history. A fresh wallet therefore needs a known chain tip even when
an explicit rescan height is supplied.

Co-Authored-By: Codex
@ldk-reviews-bot

ldk-reviews-bot commented Dec 4, 2026 •

Copy link
Copy Markdown

👋 Thanks for assigning @tnull as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@tankyleo
tankyleo requested a review from tnull December 4, 2026 01:20
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.

2 participants