1 minor finding · 3 suggestions
Earlier concerns neither republished nor resolved: 1 minor finding. See the Run archive for their assessments.
Findings
[minor] · The only write of retained transaction records is unchecked
A transaction-write failure that leaves SQLite able to commit can now silently omit migrated history; no specific commit-permitting SQLite failure was demonstrated.
Location: src/wallet/wallet.cpp:3934 (head).
Details and suggested fix
MigrateToSQLite now skips DBKeys::TX, so WriteTxMetadata(*wtx) is the only write of each transaction retained by the main wallet. Previously, this unchecked call refreshed an original record already copied with checked writes. If it returns false without making the SQLite transaction uncommittable, ApplyMigrationData ignores the failure and RunWithinTxn can commit without that record. A copied tip locator can prevent an automatic rescan. Confirmed history can be recovered by rescanning, but wallet-only metadata and unconfirmed history may require the .legacy.bak backup.
Check the return value and return util::Error on failure so the existing abort-and-backup-restoration path handles it. Failures that also prevent commit already make migration fail rather than silently omit history.
Optional improvements
[suggestion] · The migration flag conflates legacy records with skipped transactions
The DoMigration decision now also depends on skipped tx records despite the legacy-only flag name; no normal producer of a transaction-only legacy wallet was found.
Location: src/wallet/wallet.cpp:3740 (head).
Details and suggested fix
had_legacy_records becomes true for every skipped type, whereas the previous HasLegacyRecords checked only LEGACY_TYPES. A BDB wallet with tx records but no legacy key/script records therefore enters DoMigration without a lazily created LegacyDataSPKM. It reaches Assume(legacy_spkm), which aborts when failed assumptions are enforced; otherwise migration returns an internal-bug error and follows the backup-restoration path.
Name the output skipped_records and document in wallet.h that skipped records are omitted and must be rewritten by the caller. Handle the transaction-only state with an explicit input error rather than an internal-bug check. Do not merely narrow the flag to legacy types: the other branch never rewrites the skipped transactions.
[suggestion] · Migration still collects transaction IDs for the deleted removal step
txids_to_delete is populated but never read after this PR removes its only consumer.
Location: src/wallet/wallet.cpp:3924 (head).
Details and suggested fix
The vector now only collects watch-only transaction IDs before being discarded. The continue performs the required filtering: MigrateToSQLite skipped the original tx records, and this branch prevents rewriting transactions that belong only to the watch-only wallet. Remove the vector and push_back, retain the continue, and change the comment to describe intentionally not rewriting the main wallet's record rather than marking it for removal.
[suggestion] · Skipped records are copied before they are discarded
Migration still allocates and copies every skipped record before discarding it, an avoidable one-time cost rather than a regression from base.
Location: src/wallet/wallet.cpp:3734 (head).
Details and suggested fix
key and value are constructed before checking skip_types, so all skipped legacy and tx records incur these copies without using them. Read the type through a separate SpanReader over the key bytes, continue on a match, and construct the owning copies only for retained records. Simply moving the constructors below ss_key >> type would be incorrect because that extraction consumes the type prefix from ss_key.
Earlier concerns
Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.
- [minor]: Malformed unknown BDB keys now make migration throw (earlier report)