5 #include <chainparams.h> 25 if (is_ranged.has_value()) {
30 if (is_solvable.has_value()) {
43 std::vector<CScript> out_scripts;
44 (void)desc.
Expand(0, sig_provider, out_scripts, sig_provider, &cache);
49 if (!out_scripts.empty()) {
61 const bool is_nontop_or_nonsolvable{!*is_solvable || !desc.
GetOutputType()};
62 const bool is_input_size_info_set{max_sat_maxsig && max_sat_nonmaxsig && max_elems};
63 assert(is_input_size_info_set || is_nontop_or_nonsolvable);
93 const std::string mocked_descriptor{buffer.begin(), buffer.end()};
97 const auto desc =
Parse(*descriptor, signing_provider, error);
98 std::optional<bool> is_ranged;
99 std::optional<bool> is_solvable;
100 for (
const auto& d : desc) {
102 TestDescriptor(*d, signing_provider, error, is_ranged, is_solvable);
114 const std::string descriptor(buffer.begin(), buffer.end());
117 for (
const bool require_checksum : {
true,
false}) {
118 const auto desc =
Parse(descriptor, signing_provider, error, require_checksum);
119 std::optional<bool> is_ranged;
120 std::optional<bool> is_solvable;
121 for (
const auto& d : desc) {
123 TestDescriptor(*d, signing_provider, error, is_ranged, is_solvable);
static UniValue Parse(std::string_view raw)
Parse string to UniValue or throw runtime_error if string contains invalid JSON.
virtual std::optional< int64_t > MaxSatisfactionWeight(bool use_max_sig) const =0
Get the maximum size of a satisfaction for this descriptor, in weight units.
virtual bool IsSingleType() const =0
Whether this descriptor will return one scriptPubKey or multiple (aka is or is not combo) ...
static void TestDescriptor(const Descriptor &desc, FlatSigningProvider &sig_provider, std::string &dummy, std::optional< bool > &is_ranged, std::optional< bool > &is_solvable)
Test a successfully parsed descriptor.
RAII class initializing and deinitializing global state for elliptic curve support.
virtual bool IsSolvable() const =0
Whether this descriptor has all information about signing ignoring lack of private keys...
std::unique_ptr< Descriptor > InferDescriptor(const CScript &script, const SigningProvider &provider)
Find a descriptor for the specified script, using information from provider where possible...
virtual bool ExpandFromCache(int pos, const DescriptorCache &read_cache, std::vector< CScript > &output_scripts, FlatSigningProvider &out) const =0
Expand a descriptor at a specified position using cached expansion data.
FUZZ_TARGET(mocked_descriptor_parse,.init=initialize_mocked_descriptor_parse)
virtual void ExpandPrivate(int pos, const SigningProvider &provider, FlatSigningProvider &out) const =0
Expand the private key for a descriptor at a specified position, if possible.
virtual bool ToNormalizedString(const SigningProvider &provider, std::string &out, const DescriptorCache *cache=nullptr) const =0
Convert the descriptor to a normalized string.
void Init()
When initializing the target, populate the list of keys.
void initialize_descriptor_parse()
virtual std::optional< int64_t > MaxSatisfactionElems() const =0
Get the maximum size number of stack elements for satisfying this descriptor.
std::optional< std::string > GetDescriptor(std::string_view mocked_desc) const
Get an actual descriptor string from a descriptor string whose keys were mocked.
void initialize_mocked_descriptor_parse()
virtual std::optional< int64_t > ScriptSize() const =0
Get the size of the scriptPubKey for this descriptor.
virtual bool Expand(int pos, const SigningProvider &provider, std::vector< CScript > &output_scripts, FlatSigningProvider &out, DescriptorCache *write_cache=nullptr) const =0
Expand a descriptor at a specified position.
Converts a mocked descriptor string to a valid one.
Cache for single descriptor's derived extended pubkeys.
bool HasTooManySubFrag(const FuzzBufferType &buff, const int max_subs, const size_t max_nested_subs)
Whether the buffer, if it represents a valid descriptor, contains a fragment with more sub-fragments ...
MockedDescriptorConverter MOCKED_DESC_CONVERTER
The converter of mocked descriptors, needs to be initialized when the target is.
bool HasTooManyWrappers(const FuzzBufferType &buff, const int max_wrappers)
Whether the buffer, if it represents a valid descriptor, contains a fragment with more wrappers than ...
virtual bool IsRange() const =0
Whether the expansion of this descriptor depends on the position.
bool HasDeepDerivPath(const FuzzBufferType &buff, const int max_depth)
Whether the buffer, if it represents a valid descriptor, contains a derivation path deeper than a giv...
virtual std::optional< OutputType > GetOutputType() const =0
virtual std::string ToString(bool compat_format=false) const =0
Convert the descriptor back to a string, undoing parsing.
virtual bool ToPrivateString(const SigningProvider &provider, std::string &out) const =0
Convert the descriptor to a private string.
void SelectParams(const ChainType chain)
Sets the params returned by Params() to those for the given chain type.
Interface for parsed descriptor objects.