MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / Init

Method Init

src/test/fuzz/util/descriptor.cpp:17–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15#include <vector>
16
17void MockedDescriptorConverter::Init()
18{
19 // The data to use as a private key or a seed for an xprv.
20 std::array<std::byte, 32> key_data{std::byte{1}};
21 // Generate keys of all kinds and store them in the keys array.
22 for (size_t i{0}; i < TOTAL_KEYS_GENERATED; i++) {
23 key_data[31] = std::byte(i);
24
25 // If this is a "raw" key, generate a normal privkey. Otherwise generate
26 // an extended one.
27 if (IdIsCompPubKey(i) || IdIsUnCompPubKey(i) || IdIsXOnlyPubKey(i) || IdIsConstPrivKey(i)) {
28 CKey privkey;
29 privkey.Set(key_data.begin(), key_data.end(), !IdIsUnCompPubKey(i));
30 if (IdIsCompPubKey(i) || IdIsUnCompPubKey(i)) {
31 CPubKey pubkey{privkey.GetPubKey()};
32 keys_str[i] = HexStr(pubkey);
33 } else if (IdIsXOnlyPubKey(i)) {
34 const XOnlyPubKey pubkey{privkey.GetPubKey()};
35 keys_str[i] = HexStr(pubkey);
36 } else {
37 keys_str[i] = EncodeSecret(privkey);
38 }
39 } else {
40 CExtKey ext_privkey;
41 ext_privkey.SetSeed(key_data);
42 if (IdIsXprv(i)) {
43 keys_str[i] = EncodeExtKey(ext_privkey);
44 } else {
45 const CExtPubKey ext_pubkey{ext_privkey.Neuter()};
46 keys_str[i] = EncodeExtPubKey(ext_pubkey);
47 }
48 }
49 }
50}
51
52std::optional<uint8_t> MockedDescriptorConverter::IdxFromHex(std::string_view hex_characters) const {
53 if (hex_characters.size() != 2) return {};

Callers 14

AssetTestFunction · 0.45
BOOST_FIXTURE_TEST_CASEFunction · 0.45
BOOST_FIXTURE_TEST_CASEFunction · 0.45
BOOST_FIXTURE_TEST_CASEFunction · 0.45
BOOST_AUTO_TEST_CASEFunction · 0.45
BOOST_FIXTURE_TEST_CASEFunction · 0.45
BOOST_FIXTURE_TEST_CASEFunction · 0.45
DoCheckFunction · 0.45
FUZZ_TARGETFunction · 0.45
TestFunction · 0.45
HeadersSyncSetupMethod · 0.45

Calls 10

EncodeSecretFunction · 0.85
EncodeExtKeyFunction · 0.85
EncodeExtPubKeyFunction · 0.85
NeuterMethod · 0.80
HexStrFunction · 0.50
SetMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
GetPubKeyMethod · 0.45
SetSeedMethod · 0.45

Tested by

no test coverage detected