Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2023-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or https://www.opensource.org/licenses/mit-license.php.5#include <bench/bench.h>6#include <random.h>7#include <test/util/setup_common.h>8#include <uint256.h>9#include <util/check.h>10#include <util/fs.h>11#include <util/translation.h>12#include <wallet/context.h>13#include <wallet/db.h>14#include <wallet/wallet.h>15#include <wallet/walletutil.h>17#include <memory>18#include <optional>19#include <string>20#include <utility>21#include <vector>23namespace wallet {24static void WalletCreate(benchmark::Bench& bench, bool encrypted)25{26auto test_setup = MakeNoLogFileContext<TestingSetup>();27FastRandomContext random;29WalletContext context;30context.args = &test_setup->m_args;31context.chain = test_setup->m_node.chain.get();33DatabaseOptions options;34options.require_format = DatabaseFormat::SQLITE;35options.require_create = true;36options.create_flags = WALLET_FLAG_DESCRIPTORS;38if (encrypted) {39options.create_passphrase = random.rand256().ToString();40}42DatabaseStatus status;43bilingual_str error_string;44std::vector<bilingual_str> warnings;46const auto wallet_path = test_setup->m_path_root / "test_wallet";47const auto wallet_name = fs::PathToString(wallet_path);49std::shared_ptr<CWallet> wallet;50auto cleanup{[&] {51if (!wallet) return;52// Release wallet53RemoveWallet(context, wallet, /*load_on_start=*/std::nullopt);54WaitForDeleteWallet(std::move(wallet));55fs::remove(wallet_path / "wallet.dat");56fs::remove(wallet_path);57}};58bench.setup(cleanup).run([&] {59wallet = CreateWallet(context, wallet_name, /*load_on_start=*/std::nullopt, options, status, error_string, warnings);60assert(status == DatabaseStatus::SUCCESS);61assert(wallet != nullptr);62});63cleanup();64}66static void WalletCreatePlain(benchmark::Bench& bench) { WalletCreate(bench, /*encrypted=*/false); }67static void WalletCreateEncrypted(benchmark::Bench& bench) { WalletCreate(bench, /*encrypted=*/true); }69BENCHMARK(WalletCreatePlain);70BENCHMARK(WalletCreateEncrypted);72} // namespace wallet
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.