Skip to content

Commit 7a3afe6

Browse files
committed
Merge bitcoin/bitcoin#32281: bench: Fix WalletMigration benchmark
7912cd4 bench: Fix WalletMigration benchmark (pablomartin4btc) Pull request description: The keys and scripts created for the Legacy Wallet needed to be persisted in order for the migration to work properly. Fixes #32277. ACKs for top commit: achow101: ACK 7912cd4 davidgumberg: Tested ACK 7912cd4 furszy: utACK 7912cd4 Tree-SHA512: fe7b8e0a80d4d030ad3fd6446717ee09a260ab2bd6140bc817bdca52d233e3af8a8fed2d754743ca2ba022f7d2c8615a36b5070991d12942c13835e8f72e359f
2 parents e66e30c + 7912cd4 commit 7a3afe6

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/bench/wallet_migration.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ static void WalletMigration(benchmark::Bench& bench)
3232
std::unique_ptr<CWallet> wallet = std::make_unique<CWallet>(test_setup->m_node.chain.get(), "", CreateMockableWalletDatabase());
3333
wallet->chainStateFlushed(ChainstateRole::NORMAL, CBlockLocator{});
3434
LegacyDataSPKM* legacy_spkm = wallet->GetOrCreateLegacyDataSPKM();
35+
WalletBatch batch{wallet->GetDatabase()};
3536

3637
// Add watch-only addresses
3738
std::vector<CScript> scripts_watch_only;
@@ -42,6 +43,7 @@ static void WalletMigration(benchmark::Bench& bench)
4243
const CScript& script = scripts_watch_only.emplace_back(GetScriptForDestination(dest));
4344
assert(legacy_spkm->LoadWatchOnly(script));
4445
assert(wallet->SetAddressBook(dest, strprintf("watch_%d", w), /*purpose=*/std::nullopt));
46+
batch.WriteWatchOnly(script, CKeyMetadata());
4547
}
4648

4749
// Generate transactions and local addresses
@@ -58,6 +60,7 @@ static void WalletMigration(benchmark::Bench& bench)
5860
mtx.vout.emplace_back(COIN, scripts_watch_only.at(j % NUM_WATCH_ONLY_ADDR));
5961
mtx.vin.resize(2);
6062
wallet->AddToWallet(MakeTransactionRef(mtx), TxStateInactive{}, /*update_wtx=*/nullptr, /*fFlushOnClose=*/false, /*rescanning_old_block=*/true);
63+
batch.WriteKey(pubkey, key.GetPrivKey(), CKeyMetadata());
6164
}
6265

6366
bench.epochs(/*numEpochs=*/1).run([&context, &wallet] {

0 commit comments

Comments
 (0)