wallet: Always rewrite tx records during migration

Since loading a wallet may change some parts of tx records (e.g. adding
nOrderPos), we should rewrite the records instead of copying them so
that the automatic upgrade does not need to be performed again when the
wallet is loaded.
This commit is contained in:
Ava Chow 2025-07-15 16:55:46 -07:00
parent 184159e4f3
commit af041c4057

View File

@ -3947,14 +3947,16 @@ util::Result<void> CWallet::ApplyMigrationData(WalletBatch& local_wallet_batch,
// Mark as to remove from the migrated wallet only if it does not also belong to it
if (!is_mine) {
txids_to_delete.push_back(hash);
continue;
}
continue;
}
}
if (!is_mine) {
// Both not ours and not in the watchonly wallet
return util::Error{strprintf(_("Error: Transaction %s in wallet cannot be identified to belong to migrated wallets"), wtx->GetHash().GetHex())};
}
// Rewrite the transaction so that anything that may have changed about it in memory also persists to disk
local_wallet_batch.WriteTx(*wtx);
}
// Do the removes