Merge bitcoin/bitcoin#32985: wallet: Always rewrite tx records during migration

af041c405756d3b8bb04cb2ebd8c32cf237ac2a9 wallet: Always rewrite tx records during migration (Ava Chow)

Pull request description:

  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 is useful for future PRs I'm working on where we need to be sure about what data exists in a tx record in descriptor wallets.

ACKs for top commit:
  rkrux:
    lgtm ACK af041c405756d3b8bb04cb2ebd8c32cf237ac2a9
  Eunovo:
    ACK af041c4057
  furszy:
    ACK af041c405756d3b8bb04cb2ebd8c32cf237ac2a9

Tree-SHA512: 96984e46fe110a7749495965587b88a94d1297794e5d8b632b89dcdb2ebc1cd3070cd4458cf8e1b4ec0c76c4e56994f21867c44fa74f25739cbd9c0c911732a6
This commit is contained in:
merge-script 2026-03-11 10:23:40 +01:00
commit 63f27721c2
No known key found for this signature in database
GPG Key ID: 9B79B45691DB4173

View File

@ -4018,14 +4018,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