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) 2020-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#include <pubkey.h>6#include <script/descriptor.h>7#include <test/fuzz/FuzzedDataProvider.h>8#include <test/fuzz/fuzz.h>9#include <test/fuzz/util.h>11#include <cstdint>12#include <optional>13#include <string>14#include <vector>16FUZZ_TARGET(script_descriptor_cache)17{18FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());19DescriptorCache descriptor_cache;20LIMITED_WHILE (fuzzed_data_provider.ConsumeBool(), 10000) {21const std::vector<uint8_t> code = fuzzed_data_provider.ConsumeBytes<uint8_t>(BIP32_EXTKEY_SIZE);22if (code.size() == BIP32_EXTKEY_SIZE) {23CExtPubKey xpub;24xpub.Decode(code.data());25const uint32_t key_exp_pos = fuzzed_data_provider.ConsumeIntegral<uint32_t>();26CExtPubKey xpub_fetched;27if (fuzzed_data_provider.ConsumeBool()) {28(void)descriptor_cache.GetCachedParentExtPubKey(key_exp_pos, xpub_fetched);29descriptor_cache.CacheParentExtPubKey(key_exp_pos, xpub);30assert(descriptor_cache.GetCachedParentExtPubKey(key_exp_pos, xpub_fetched));31} else {32const uint32_t der_index = fuzzed_data_provider.ConsumeIntegral<uint32_t>();33(void)descriptor_cache.GetCachedDerivedExtPubKey(key_exp_pos, der_index, xpub_fetched);34descriptor_cache.CacheDerivedExtPubKey(key_exp_pos, der_index, xpub);35assert(descriptor_cache.GetCachedDerivedExtPubKey(key_exp_pos, der_index, xpub_fetched));36}37assert(xpub == xpub_fetched);38}39(void)descriptor_cache.GetCachedParentExtPubKeys();40(void)descriptor_cache.GetCachedDerivedExtPubKeys();41}42}
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.