1 minor finding · 2 suggestions
Earlier concerns remain unresolved; see the Run archive for their assessments.
Findings
[minor] · Pre-rename refusals unnecessarily delete the intact legacy wallet
The new staging design still deletes an untouched directory wallet after a pre-rename refusal, making recovery depend on copying the backup, although base deleted the original even earlier.
Location: src/wallet/wallet.cpp:3884 (head).
Details and suggested fix
A wallet database at wallet.dat-journal, as arranged by test_db_named_as_journal, makes MoveDatabase refuse before replacing a directory wallet's wallet.dat. Nevertheless, MigrateToSQLite throws while m_database still identifies the original Berkeley file. Common rollback then deletes that intact file and copies the byte-identical .legacy.bak back. If that copy fails or the process stops between deletion and copying, the user needs to restore the surviving backup manually. Have MoveDatabase report whether replacement occurred, and return false with the bilingual error when a directory wallet remains untouched. Reserve throw-driven restoration for failures after the plain-file erase or destination replacement. This also avoids labeling an expected refusal as an untranslated “Unexpected exception”.
Temporary-directory cleanup also needs a scope guard. For example, RunWithinTxn constructs a batch whose SQL preparation can throw before remove_tmp_and_fail runs. The outer rollback does not track that temporary directory, so the exception leaves it behind.
Optional improvements
[suggestion] · Unrecognized journal-named files are deleted during migration
Migration deletes a pre-existing wallet.dat-journal unless it matches this network's wallet format, even if it is a foreign-network SQLite wallet; this is defensive hardening for an unlikely layout, not an observed loss.
Location: src/wallet/db.cpp:198 (head).
Details and suggested fix
SQLiteDatabase::Files() always includes the journal pathname, so MoveDatabase examines it even when the temporary database has no journal. IsSQLiteFile requires both the SQLite header and the current network's application ID. Its negative result therefore does not establish that the destination file is disposable or even a rollback journal. Rename an unrecognized leftover to a unique, non-overwriting pathname and log that location instead of unlinking it. Removing the original journal pathname still prevents the hot-journal recovery covered by test_stale_journal, while preserving contents that migration did not create.
[suggestion] · Interrupted staging databases appear as wallets
After an unclean shutdown during migration, staging databases under walletdir can appear in listwalletdir and the GUI's open-wallet list despite being unfinished migration artifacts.
Location: src/wallet/wallet.cpp:3821 (head).
Details and suggested fix
Once temporary SQLite creation sets the application ID, its wallet.dat satisfies IsSQLiteFile. A crash or kill bypasses the in-process cleanup, leaving <prefix>_sqlite_<timestamp>.tmp beneath the original wallet directory, or directly in walletdir for unnamed and plain-file wallets. ListDatabases recursively discovers these directories without excluding staging artifacts. A later migration uses a new timestamp and does not remove older entries. Make wallet discovery explicitly exclude migration staging directories so users are not offered these artifacts as ordinary wallets. A leading-dot name alone would not suffice because discovery does not skip hidden directories.