3 minor findings
Earlier concerns remain unresolved; see the Run archive for their assessments.
Findings
[minor] · Final rename failures skip restoration after deleting the original
If the final same-filesystem rename fails after unlinking the BDB original, migration skips backup restoration and attempts to delete the staged copy; no production occurrence was identified.
Location: src/wallet/wallet.cpp:3886 (head).
Details and suggested fix
fs::remove(origin_db_path, ...) succeeds before the final fs::rename. On a rename error, fail() attempts to remove the staged database and returns false. MigrateLegacyToDescriptor immediately returns that error, bypassing RestoreWallet, so the live wallet path has no database. The .legacy.bak backup remains available, but the user must restore it manually. For a plain-file wallet, the destination has already become an empty directory, and retrying reports that it is already a descriptor wallet because wallet.dat is missing. Preserve the staged copy on installation failure and report whether the original was removed, so the caller invokes restoration for failures after that point. Add failure-injection coverage for the final rename.
[minor] · Failed temporary-database creation leaves migration artifacts behind
Temporary SQLite creation failures can leave _sqlite_*.tmp artifacts and block same-timestamp retries; the original remains intact, and no production occurrence was identified.
Location: src/wallet/wallet.cpp:3847 (head).
Details and suggested fix
SQLiteDatabase::Open creates the directory and opens wallet.dat before completing schema initialization. A later failure, such as SQLITE_FULL, reaches constructor cleanup, which closes the connection without deleting these paths. MakeDatabase then returns null, but this branch passes an empty removal list to fail(). The temporary directory and possibly an empty or partially initialized database remain. A retry with the same timestamp hits the existence guard; later attempts can accumulate more artifacts. Install a cleanup guard after the nonexistence check that removes the temporary database, its journal, and the directory on unsuccessful exits, including a null factory result.
[minor] · Exception rollback loses track of conversion state and staged files
Although no production occurrence was identified, a MigrateToSQLite exception can trigger deletion and restoration of an untouched original or leave an untracked staged database.
Location: src/wallet/wallet.cpp:4346 (head).
Details and suggested fix
An exception before the unlink enters common rollback while m_database still refers to the BerkeleyRODatabase. Cleanup tracks its original path, deletes that untouched file, and relies on copying the backup back. If restoration also fails, manual recovery becomes necessary where the original could have remained intact. Exceptions after staging bypass fail() and leave the temporary files untracked. For example, a genuine TryCreateDirectories(dst_wallet_dir) failure during plain-file conversion leaves the completed SQLite copy behind, including its key records, while the caller attempts restoration.
Track whether conversion actually removed the original and restore only when necessary. Give the staged files a scope guard so exceptions close the connection and clean up the temporary paths as well as ordinary failure returns.