| 59 | } |
| 60 | |
| 61 | static 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 | |
| 84 | static DescriptorScriptPubKeyMan* CreateDescriptor(WalletDescriptor& wallet_desc, FlatSigningProvider& keys, CWallet& keystore) |
| 85 | { |
no test coverage detected