Skip to content

Commit 9bf0243

Browse files
committed
bench: Use DescriptorScriptPubKeyMan for wallet things
For wallet related benchmarks that need a ScriptPubKeyMan for operation, use a DescriptorScriptPubKeyMan
1 parent 5e54aa9 commit 9bf0243

File tree

3 files changed

+8
-21
lines changed

3 files changed

+8
-21
lines changed

src/bench/coin_selection.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ static void CoinSelection(benchmark::Bench& bench)
3333
NodeContext node;
3434
auto chain = interfaces::MakeChain(node);
3535
CWallet wallet(chain.get(), "", CreateDummyWalletDatabase());
36-
wallet.SetupLegacyScriptPubKeyMan();
3736
std::vector<std::unique_ptr<CWalletTx>> wtxs;
3837
LOCK(wallet.cs_wallet);
3938

src/bench/wallet_balance.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,22 @@
1414

1515
#include <optional>
1616

17-
static void WalletBalance(benchmark::Bench& bench, const bool set_dirty, const bool add_watchonly, const bool add_mine)
17+
static void WalletBalance(benchmark::Bench& bench, const bool set_dirty, const bool add_mine)
1818
{
1919
const auto test_setup = MakeNoLogFileContext<const TestingSetup>();
2020

2121
const auto& ADDRESS_WATCHONLY = ADDRESS_BCRT1_UNSPENDABLE;
2222

2323
CWallet wallet{test_setup->m_node.chain.get(), "", CreateMockWalletDatabase()};
2424
{
25-
wallet.SetupLegacyScriptPubKeyMan();
25+
LOCK(wallet.cs_wallet);
26+
wallet.SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
27+
wallet.SetupDescriptorScriptPubKeyMans();
2628
if (wallet.LoadWallet() != DBErrors::LOAD_OK) assert(false);
2729
}
2830
auto handler = test_setup->m_node.chain->handleNotifications({&wallet, [](CWallet*) {}});
2931

3032
const std::optional<std::string> address_mine{add_mine ? std::optional<std::string>{getnewaddress(wallet)} : std::nullopt};
31-
if (add_watchonly) importaddress(wallet, ADDRESS_WATCHONLY);
3233

3334
for (int i = 0; i < 100; ++i) {
3435
generatetoaddress(test_setup->m_node, address_mine.value_or(ADDRESS_WATCHONLY));
@@ -42,14 +43,13 @@ static void WalletBalance(benchmark::Bench& bench, const bool set_dirty, const b
4243
if (set_dirty) wallet.MarkDirty();
4344
bal = GetBalance(wallet);
4445
if (add_mine) assert(bal.m_mine_trusted > 0);
45-
if (add_watchonly) assert(bal.m_watchonly_trusted > 0);
4646
});
4747
}
4848

49-
static void WalletBalanceDirty(benchmark::Bench& bench) { WalletBalance(bench, /* set_dirty */ true, /* add_watchonly */ true, /* add_mine */ true); }
50-
static void WalletBalanceClean(benchmark::Bench& bench) { WalletBalance(bench, /* set_dirty */ false, /* add_watchonly */ true, /* add_mine */ true); }
51-
static void WalletBalanceMine(benchmark::Bench& bench) { WalletBalance(bench, /* set_dirty */ false, /* add_watchonly */ false, /* add_mine */ true); }
52-
static void WalletBalanceWatch(benchmark::Bench& bench) { WalletBalance(bench, /* set_dirty */ false, /* add_watchonly */ true, /* add_mine */ false); }
49+
static void WalletBalanceDirty(benchmark::Bench& bench) { WalletBalance(bench, /* set_dirty */ true, /* add_mine */ true); }
50+
static void WalletBalanceClean(benchmark::Bench& bench) { WalletBalance(bench, /* set_dirty */ false, /* add_mine */ true); }
51+
static void WalletBalanceMine(benchmark::Bench& bench) { WalletBalance(bench, /* set_dirty */ false, /* add_mine */ true); }
52+
static void WalletBalanceWatch(benchmark::Bench& bench) { WalletBalance(bench, /* set_dirty */ false, /* add_mine */ false); }
5353

5454
BENCHMARK(WalletBalanceDirty);
5555
BENCHMARK(WalletBalanceClean);

src/test/util/wallet.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,4 @@ std::string getnewaddress(CWallet& w)
2525
return EncodeDestination(dest);
2626
}
2727

28-
void importaddress(CWallet& wallet, const std::string& address)
29-
{
30-
auto spk_man = wallet.GetLegacyScriptPubKeyMan();
31-
LOCK2(wallet.cs_wallet, spk_man->cs_KeyStore);
32-
const auto dest = DecodeDestination(address);
33-
assert(IsValidDestination(dest));
34-
const auto script = GetScriptForDestination(dest);
35-
wallet.MarkDirty();
36-
assert(!spk_man->HaveWatchOnly(script));
37-
if (!spk_man->AddWatchOnly(script, 0 /* nCreateTime */)) assert(false);
38-
wallet.SetAddressBook(dest, /* label */ "", "receive");
39-
}
4028
#endif // ENABLE_WALLET

0 commit comments

Comments
 (0)