Bitcoin Core 31.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
descriptor.h File Reference
#include <array>
#include <cinttypes>
#include <cstddef>
#include <limits>
#include <optional>
#include <span>
#include <string>
#include <string_view>
Include dependency graph for descriptor.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  MockedDescriptorConverter
 Converts a mocked descriptor string to a valid one. More...

Functions

bool HasDeepDerivPath (std::span< const uint8_t > buff, int max_depth=MAX_DEPTH)
 Whether the buffer, if it represents a valid descriptor, contains a derivation path deeper than a given maximum depth.
bool HasTooManySubFrag (std::span< const uint8_t > buff, int max_subs=MAX_SUBS, size_t max_nested_subs=MAX_NESTED_SUBS)
 Whether the buffer, if it represents a valid descriptor, contains a fragment with more sub-fragments than the given maximum.
bool HasTooManyWrappers (std::span< const uint8_t > buff, int max_wrappers=MAX_WRAPPERS)
 Whether the buffer, if it represents a valid descriptor, contains a fragment with more wrappers than the given maximum.
bool HasTooLargeLeafSize (std::span< const uint8_t > buff, uint32_t max_leaf_size=MAX_LEAF_SIZE)
 Whether the expanded buffer (after calling GetDescriptor() in MockedDescriptorConverter) has a leaf size too large.
bool IsTooExpensive (std::span< const uint8_t > buffer)
 Deriving "expensive" descriptors will consume useful fuzz compute. The compute is better spent on a smaller subset of descriptors, which still covers all real end-user settings.

Variables

constexpr int MAX_DEPTH {2}
 Default maximum number of derivation indexes in a single derivation path when limiting its depth.
constexpr int MAX_SUBS {1'000}
 Default maximum number of sub-fragments.
constexpr size_t MAX_NESTED_SUBS {10'000}
 Maximum number of nested sub-fragments we'll allow in a descriptor.
constexpr int MAX_WRAPPERS {100}
 Default maximum number of wrappers per fragment.
constexpr uint32_t MAX_LEAF_SIZE {200}
 Default maximum leaf size. This should be large enough to cover an extended key, including paths "/", inside and outside of "[]".

Function Documentation

◆ HasDeepDerivPath()

bool HasDeepDerivPath ( std::span< const uint8_t > buff,
int max_depth = MAX_DEPTH )

Whether the buffer, if it represents a valid descriptor, contains a derivation path deeper than a given maximum depth.

Note this may also be hit for deriv paths in origins.

Definition at line 85 of file descriptor.cpp.

Here is the caller graph for this function:

◆ HasTooLargeLeafSize()

bool HasTooLargeLeafSize ( std::span< const uint8_t > buff,
uint32_t max_leaf_size = MAX_LEAF_SIZE )

Whether the expanded buffer (after calling GetDescriptor() in MockedDescriptorConverter) has a leaf size too large.

Definition at line 155 of file descriptor.cpp.

Here is the caller graph for this function:

◆ HasTooManySubFrag()

bool HasTooManySubFrag ( std::span< const uint8_t > buff,
int max_subs = MAX_SUBS,
size_t max_nested_subs = MAX_NESTED_SUBS )

Whether the buffer, if it represents a valid descriptor, contains a fragment with more sub-fragments than the given maximum.

Definition at line 99 of file descriptor.cpp.

Here is the caller graph for this function:

◆ HasTooManyWrappers()

bool HasTooManyWrappers ( std::span< const uint8_t > buff,
int max_wrappers = MAX_WRAPPERS )

Whether the buffer, if it represents a valid descriptor, contains a fragment with more wrappers than the given maximum.

Definition at line 123 of file descriptor.cpp.

Here is the caller graph for this function:

◆ IsTooExpensive()

bool IsTooExpensive ( std::span< const uint8_t > buffer)
inline

Deriving "expensive" descriptors will consume useful fuzz compute. The compute is better spent on a smaller subset of descriptors, which still covers all real end-user settings.

Use this function after MockedDescriptorConverter::GetDescriptor()

Definition at line 94 of file descriptor.h.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ MAX_DEPTH

int MAX_DEPTH {2}
constexpr

Default maximum number of derivation indexes in a single derivation path when limiting its depth.

Definition at line 52 of file descriptor.h.

◆ MAX_LEAF_SIZE

uint32_t MAX_LEAF_SIZE {200}
constexpr

Default maximum leaf size. This should be large enough to cover an extended key, including paths "/", inside and outside of "[]".

Definition at line 83 of file descriptor.h.

◆ MAX_NESTED_SUBS

size_t MAX_NESTED_SUBS {10'000}
constexpr

Maximum number of nested sub-fragments we'll allow in a descriptor.

Definition at line 63 of file descriptor.h.

◆ MAX_SUBS

int MAX_SUBS {1'000}
constexpr

Default maximum number of sub-fragments.

Definition at line 61 of file descriptor.h.

◆ MAX_WRAPPERS

int MAX_WRAPPERS {100}
constexpr

Default maximum number of wrappers per fragment.

Definition at line 73 of file descriptor.h.