Bitcoin Core 32.99.0
P2P Digital Currency
Functions
descriptor.cpp File Reference
#include <script/descriptor.h>
#include <addresstype.h>
#include <attributes.h>
#include <consensus/consensus.h>
#include <crypto/hex_base.h>
#include <crypto/sha256.h>
#include <hash.h>
#include <key.h>
#include <key_io.h>
#include <musig.h>
#include <primitives/transaction.h>
#include <pubkey.h>
#include <script/interpreter.h>
#include <script/keyorigin.h>
#include <script/miniscript.h>
#include <script/parsing.h>
#include <script/script.h>
#include <script/signingprovider.h>
#include <script/solver.h>
#include <serialize.h>
#include <tinyformat.h>
#include <uint256.h>
#include <util/bip32.h>
#include <util/check.h>
#include <util/expected.h>
#include <util/strencodings.h>
#include <util/string.h>
#include <util/vector.h>
#include <algorithm>
#include <compare>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <optional>
#include <span>
#include <stdexcept>
#include <string>
#include <tuple>
#include <unordered_set>
#include <utility>
#include <vector>
Include dependency graph for descriptor.cpp:

Go to the source code of this file.

Functions

util::Expected< void, std::string > CheckDescriptorRangeBounds (int64_t low, int64_t high)
 Validate the numeric bounds of a descriptor key-expression range [low, high] (high inclusive). More...
 
bool CheckChecksum (std::span< const char > &sp, bool require_checksum, std::string &error, std::string *out_checksum=nullptr)
 Check a descriptor checksum, and update desc to be the checksum-less part. More...
 
std::vector< std::unique_ptr< Descriptor > > Parse (std::string_view descriptor, FlatSigningProvider &out, std::string &error, bool require_checksum)
 Parse a descriptor string. More...
 
std::string GetDescriptorChecksum (const std::string &descriptor)
 Get the checksum for a descriptor. More...
 
std::unique_ptr< DescriptorInferDescriptor (const CScript &script, const SigningProvider &provider)
 Find a descriptor for the specified script, using information from provider where possible. More...
 
uint256 CompatDescriptorHash (const Descriptor &desc)
 Hash of the COMPAT string representation of the descriptor that is not supposed to change over time. More...
 

Function Documentation

◆ CheckChecksum()

bool CheckChecksum ( std::span< const char > &  sp,
bool  require_checksum,
std::string &  error,
std::string *  out_checksum = nullptr 
)

Check a descriptor checksum, and update desc to be the checksum-less part.

Definition at line 2978 of file descriptor.cpp.

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

◆ CheckDescriptorRangeBounds()

util::Expected< void, std::string > CheckDescriptorRangeBounds ( int64_t  low,
int64_t  high 
)

Validate the numeric bounds of a descriptor key-expression range [low, high] (high inclusive).

On success returns an Expected with no value; on failure returns the first violated invariant's user-facing message.

Definition at line 52 of file descriptor.cpp.

Here is the caller graph for this function:

◆ CompatDescriptorHash()

uint256 CompatDescriptorHash ( const Descriptor desc)

Hash of the COMPAT string representation of the descriptor that is not supposed to change over time.

Due to the hash's usage in previous versions, the COMPAT string is computed with some quirks.

The hash is the sha256 of the public descriptor using apostrophes as the hardened indicator, except inside of Miniscript expressions, where the public serialization is used as provided.

Definition at line 3042 of file descriptor.cpp.

Here is the call graph for this function:

◆ GetDescriptorChecksum()

std::string GetDescriptorChecksum ( const std::string &  descriptor)

Get the checksum for a descriptor.

  • If it already has one, and it is correct, return the checksum in the input.
  • If it already has one that is wrong, return "".
  • If it does not already have one, return the checksum that would need to be added.

Definition at line 3028 of file descriptor.cpp.

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

◆ InferDescriptor()

std::unique_ptr< Descriptor > InferDescriptor ( const CScript script,
const SigningProvider provider 
)

Find a descriptor for the specified script, using information from provider where possible.

A non-ranged descriptor which only generates the specified script will be returned in all circumstances.

For public keys with key origin information, this information will be preserved in the returned descriptor.

  • If all information for solving script is present in provider, a descriptor will be returned which is IsSolvable() and encapsulates said information.
  • Failing that, if script corresponds to a known address type, an "addr()" descriptor will be returned (which is not IsSolvable()).
  • Failing that, a "raw()" descriptor is returned.

Definition at line 3037 of file descriptor.cpp.

Here is the caller graph for this function:

◆ Parse()

std::vector< std::unique_ptr< Descriptor > > Parse ( std::string_view  descriptor,
FlatSigningProvider out,
std::string &  error,
bool  require_checksum = false 
)

Parse a descriptor string.

Included private keys are put in out.

If the descriptor has a checksum, it must be valid. If require_checksum is set, the checksum is mandatory - otherwise it is optional.

If a parse error occurs, or the checksum is missing/invalid, or anything else is wrong, an empty vector is returned.

Definition at line 3011 of file descriptor.cpp.

Here is the call graph for this function: