Bitcoin Core Overhauls Wallet Migration to SQLite With Safer Rollback
Bitcoin Core's updated wallet migration keeps the legacy database in place until the SQLite copy is fully written, with automatic rollback, clearer errors, and new safeguards on journal files.

Outputs
Bitcoin Core now builds the SQLite wallet database alongside the original file instead of deleting the legacy database first
Migration failures can trigger automatic restoration of the original wallet from its backup
A leftover SQLite journal in the wallet directory now halts migration rather than risking corruption of the new database
Reviewer Ryan Ofsky noted that if the backup copy-back crashes, users must still restore the backup manually
Tests cover wallets on separate filesystems, read-only directories, and post-failure legacy format verification
Bitcoin Core's next release rebuilds wallet migration so the legacy database survives until the new SQLite one is verified. That is the core change. If the migration fails partway, the user's original wallet stays on disk instead of forcing a hand-rolled restore.
The details come from a merged pull request in the Bitcoin Core repository, reviewed by contributor Ryan Ofsky, which rewrites how the node software moves a legacy wallet into its SQLite format.
How the old migration could fail
The previous flow was blunt. Bitcoin Core deleted the original database before writing the new one. If anything went wrong while building the SQLite file or writing wallet records, the software left the user to restore the wallet from a backup by hand.
That is a real operational risk. A wallet is a user's keys, labels, and transaction history. Losing the working copy mid-migration means downtime at best, and a recovery drill at worst, for node operators and custodians running Bitcoin Core wallets in production.
The new code flips the order of operations. Bitcoin Core now builds the SQLite database next to the original file, leaving the legacy database in place while the new one is being written. Only once the wallet records have been written successfully does the software move the new database into position. The pull request includes a test covering a wallet stored on a separate filesystem, a scenario where a cross-filesystem move is not a simple rename.
What happens when migration stops working?
The patch also hardens the failure paths. Some mismatches during wallet creation could previously crash the graphical interface or surface as a generic error. Bitcoin Core now catches those differences and reports them, which lets the migration process automatically restore the original wallet from its backup.
Two edge cases got specific treatment:
- Migrating a wallet in a read-only directory could throw an error and skip cleanup. The process now crashes with a clear error message, and the test suite verifies the wallet is still in the old database format after the failure.
- A leftover SQLite journal in the wallet directory could corrupt the new database if SQLite picks it up for the migrated wallet. Bitcoin Core now halts the migration when it finds such a file. The test checks that the journal stays in place and the wallet keeps its legacy format.
The one case still on the user
Automatic recovery has a boundary, and Ofsky drew it in his review. If the backup copy-back step itself crashes, the user still has to restore the backup by hand. The new design narrows the window for manual intervention; it does not close it.
For node operators, the practical question is what this changes for wallet maintenance. The answer: less downtime risk around format migrations, cleaner error reporting, and a stronger guarantee that a failed migration leaves the wallet usable in its old form. Wallets migrated in place should require fewer operator interventions, and failures that once produced silent corruption or generic errors now fail loudly and early.
The change lands ahead of the next Bitcoin Core release, and anyone running legacy-format wallets should watch the release notes for the migration guidance before upgrading.
via cryptonews.net (Source)
More from Marcus Bennett
Show full bio
Senior reporter covering money, funding and market shifts around crypto and web3 industry at Mempool Brief.
1,846 articles