From af041c405756d3b8bb04cb2ebd8c32cf237ac2a9 Mon Sep 17 00:00:00 2001 From: Ava Chow Date: Tue, 15 Jul 2025 16:55:46 -0700 Subject: [PATCH] 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. --- src/wallet/wallet.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 3d83f356f64..de7e7e16778 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3947,14 +3947,16 @@ util::Result 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