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

Function CreateWalletDescriptor

src/wallet/test/fuzz/scriptpubkeyman.cpp:61–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61static std::optional<std::pair<WalletDescriptor, FlatSigningProvider>> CreateWalletDescriptor(FuzzedDataProvider& fuzzed_data_provider)
62{
63 const std::string mocked_descriptor{fuzzed_data_provider.ConsumeRandomLengthString()};
64 const auto desc_str{MOCKED_DESC_CONVERTER.GetDescriptor(mocked_descriptor)};
65 if (!desc_str.has_value()) return std::nullopt;
66 if (IsTooExpensive(MakeUCharSpan(*desc_str))) return {};
67
68 FlatSigningProvider keys;
69 std::string error;
70 std::vector<std::unique_ptr<Descriptor>> parsed_descs = Parse(desc_str.value(), keys, error, false);
71 if (parsed_descs.empty()) return std::nullopt;
72
73 // Verify expand succeeds before making WalletDescriptor
74 // Expansion results are not needed
75 FlatSigningProvider out_keys;
76 std::vector<CScript> scripts_temp;
77 DescriptorCache temp_cache;
78 if (!parsed_descs.at(0)->Expand(0, keys, scripts_temp, out_keys, &temp_cache)) return std::nullopt;
79
80 WalletDescriptor w_desc{std::move(parsed_descs.at(0)), /*creation_time=*/0, /*range_start=*/0, /*range_end=*/1, /*next_index=*/1};
81 return std::make_pair(w_desc, keys);
82}
83
84static DescriptorScriptPubKeyMan* CreateDescriptor(WalletDescriptor& wallet_desc, FlatSigningProvider& keys, CWallet& keystore)
85{

Callers 1

Calls 10

IsTooExpensiveFunction · 0.85
MakeUCharSpanFunction · 0.85
GetDescriptorMethod · 0.80
ParseFunction · 0.50
has_valueMethod · 0.45
valueMethod · 0.45
emptyMethod · 0.45
ExpandMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected