Bitcoin Core 32.99.0
P2P Digital Currency
Loading...
Searching...
No Matches
script_descriptor_cache.cpp
Go to the documentation of this file.
1// Copyright (c) 2020-present The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#include <pubkey.h>
6#include <script/descriptor.h>
7#include <streams.h>
9#include <test/fuzz/fuzz.h>
10#include <test/fuzz/util.h>
11
12#include <cstdint>
13#include <optional>
14#include <string>
15#include <vector>
16
18{
19 FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
22 const std::vector<uint8_t> code = fuzzed_data_provider.ConsumeBytes<uint8_t>(BIP32_EXTKEY_SIZE);
23 if (code.size() == BIP32_EXTKEY_SIZE) {
25 SpanReader{code} >> xpub;
29 (void)descriptor_cache.GetCachedParentExtPubKey(key_exp_pos, xpub_fetched);
30 descriptor_cache.CacheParentExtPubKey(key_exp_pos, xpub);
31 assert(descriptor_cache.GetCachedParentExtPubKey(key_exp_pos, xpub_fetched));
32 } else {
34 (void)descriptor_cache.GetCachedDerivedExtPubKey(key_exp_pos, der_index, xpub_fetched);
35 descriptor_cache.CacheDerivedExtPubKey(key_exp_pos, der_index, xpub);
36 assert(descriptor_cache.GetCachedDerivedExtPubKey(key_exp_pos, der_index, xpub_fetched));
37 }
39 }
40 (void)descriptor_cache.GetCachedParentExtPubKeys();
41 (void)descriptor_cache.GetCachedDerivedExtPubKeys();
42 }
43}
Cache for single descriptor's derived extended pubkeys.
Definition descriptor.h:30
std::vector< T > ConsumeBytes(size_t num_bytes)
Minimal stream for reading from an existing byte array by std::span.
Definition streams.h:83
#define FUZZ_TARGET(...)
Definition fuzz.h:35
#define LIMITED_WHILE(condition, limit)
Can be used to limit a theoretically unbounded loop.
Definition fuzz.h:22
constexpr unsigned int BIP32_EXTKEY_SIZE
Definition pubkey.h:22
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
Definition time.h:82
assert(!tx.IsCoinBase())
FuzzedDataProvider & fuzzed_data_provider
Definition fees.cpp:46