Skip to content

Persist wallet birthday checkpoint at build - #1251

Open
tnull wants to merge 2 commits into
lightningdevkit:release/0.7from
tnull:2026-11-persist-wallet-birthday-0.7
Open

tnull wants to merge 2 commits into
lightningdevkit:release/0.7from
tnull:2026-11-persist-wallet-birthday-0.7

Conversation

@tnull

@tnull tnull commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Backport of #1250.

@tnull
tnull requested a review from tankyleo November 19, 2026 10:38
@ldk-reviews-bot

ldk-reviews-bot commented Nov 19, 2026 •

Copy link
Copy Markdown

👋 Thanks for assigning @tankyleo 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.

@tnull
tnull force-pushed the 2026-11-persist-wallet-birthday-0.7 branch from e982d01 to 5e0da0c Compare November 19, 2026 10:38
Comment thread src/builder.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create_wallet(&mut wallet_persister) here already persists the wallet at genesis, before the checkpoint is applied. If we crash or the new persist fails in between, storage holds a genesis wallet, the next load_wallet returns it, and the None branch that adds the checkpoint never runs again, so the pruned-node rescan problem is back. #1250 avoids this by using create_wallet_no_persist() and persisting once after the checkpoint is applied. Could the backport do the same (take_staged + persist), or is there a 0.7-specific reason it can't ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, will adapt this once #1250 lands.

tnull added 2 commits December 2, 2026 10:09
When creating a new on-chain wallet, we first persisted it at genesis
and only then inserted the checkpoint acting as its birthday, which
was held in memory until the wallet's first sync persisted it. A
restart, crash or failed write in between left a persisted wallet
that reloads at genesis and tries to rescan the whole chain, which
never succeeds against a pruned bitcoind.

We now apply the checkpoint before the wallet is first persisted, so
that its initial state always includes the birthday. As BDK can't turn
a wallet created in memory into a persisted one, we write that state
ourselves and load the wallet back from the persister.

Backport of 73865bd

Reported-by: vnprclanker
Co-Authored-By: HAL 9000
Nothing covered that a node restarted between its first build and its
first wallet sync keeps the wallet birthday rather than rescanning
from genesis.

We add an integration test that builds a fresh node against bitcoind,
drops it before it syncs, and checks that the wallet's chain state was
written exactly once and that the rebuilt node doesn't pick up a
payment confirmed before its birthday. It covers the RPC and REST
chain sources.

Backport of 227e9ad

Co-Authored-By: HAL 9000
@tnull
tnull force-pushed the 2026-11-persist-wallet-birthday-0.7 branch from 5e0da0c to a1fd5fa Compare December 2, 2026 09:19
@tnull

tnull commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator Author

Updated to match latest state from #1250.

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.

3 participants