Bitcoin
Classes | Namespaces | Typedefs | Enumerations | Functions
descriptor.cpp File Reference
#include <script/descriptor.h>
#include <key_io.h>
#include <pubkey.h>
#include <script/script.h>
#include <script/standard.h>
#include <span.h>
#include <util/bip32.h>
#include <util/system.h>
#include <util/strencodings.h>
#include <memory>
#include <string>
#include <vector>

Classes

struct  anonymous_namespace{descriptor.cpp}::PubkeyProvider
 
class  anonymous_namespace{descriptor.cpp}::OriginPubkeyProvider
 
class  anonymous_namespace{descriptor.cpp}::ConstPubkeyProvider
 
class  anonymous_namespace{descriptor.cpp}::BIP32PubkeyProvider
 
class  anonymous_namespace{descriptor.cpp}::DescriptorImpl
 
class  anonymous_namespace{descriptor.cpp}::AddressDescriptor
 
class  anonymous_namespace{descriptor.cpp}::RawDescriptor
 
class  anonymous_namespace{descriptor.cpp}::PKDescriptor
 
class  anonymous_namespace{descriptor.cpp}::PKHDescriptor
 
class  anonymous_namespace{descriptor.cpp}::WPKHDescriptor
 
class  anonymous_namespace{descriptor.cpp}::ComboDescriptor
 
class  anonymous_namespace{descriptor.cpp}::MultisigDescriptor
 
class  anonymous_namespace{descriptor.cpp}::SHDescriptor
 
class  anonymous_namespace{descriptor.cpp}::WSHDescriptor
 

Namespaces

 anonymous_namespace{descriptor.cpp}
 

Typedefs

typedef std::vector< uint32_tanonymous_namespace{descriptor.cpp}::KeyPath
 

Enumerations

enum  anonymous_namespace{descriptor.cpp}::DeriveType { anonymous_namespace{descriptor.cpp}::DeriveType::NO, anonymous_namespace{descriptor.cpp}::DeriveType::UNHARDENED, anonymous_namespace{descriptor.cpp}::DeriveType::HARDENED }
 
enum  anonymous_namespace{descriptor.cpp}::ParseScriptContext { anonymous_namespace{descriptor.cpp}::ParseScriptContext::TOP, anonymous_namespace{descriptor.cpp}::ParseScriptContext::P2SH, anonymous_namespace{descriptor.cpp}::ParseScriptContext::P2WSH }
 

Functions

uint64_t anonymous_namespace{descriptor.cpp}::PolyMod (uint64_t c, int val)
 
std::string anonymous_namespace{descriptor.cpp}::DescriptorChecksum (const Span< const char > &span)
 
std::string anonymous_namespace{descriptor.cpp}::AddChecksum (const std::string &str)
 
template<typename T >
std::vector< T > anonymous_namespace{descriptor.cpp}::Singleton (T elem)
 
bool anonymous_namespace{descriptor.cpp}::Const (const std::string &str, Span< const char > &sp)
 
bool anonymous_namespace{descriptor.cpp}::Func (const std::string &str, Span< const char > &sp)
 
Span< const char > anonymous_namespace{descriptor.cpp}::Expr (Span< const char > &sp)
 
std::vector< Span< const char > > anonymous_namespace{descriptor.cpp}::Split (const Span< const char > &sp, char sep)
 
NODISCARD bool anonymous_namespace{descriptor.cpp}::ParseKeyPath (const std::vector< Span< const char >> &split, KeyPath &out)
 
std::unique_ptr< PubkeyProvider > anonymous_namespace{descriptor.cpp}::ParsePubkeyInner (const Span< const char > &sp, bool permit_uncompressed, FlatSigningProvider &out)
 
std::unique_ptr< PubkeyProvider > anonymous_namespace{descriptor.cpp}::ParsePubkey (const Span< const char > &sp, bool permit_uncompressed, FlatSigningProvider &out)
 
std::unique_ptr< DescriptorImpl > anonymous_namespace{descriptor.cpp}::ParseScript (Span< const char > &sp, ParseScriptContext ctx, FlatSigningProvider &out)
 
std::unique_ptr< PubkeyProvider > anonymous_namespace{descriptor.cpp}::InferPubkey (const CPubKey &pubkey, ParseScriptContext, const SigningProvider &provider)
 
std::unique_ptr< DescriptorImpl > anonymous_namespace{descriptor.cpp}::InferScript (const CScript &script, ParseScriptContext ctx, const SigningProvider &provider)
 
std::unique_ptr< DescriptorParse (const std::string &descriptor, FlatSigningProvider &out, bool require_checksum)
 
std::unique_ptr< DescriptorInferDescriptor (const CScript &script, const SigningProvider &provider)
 

Function Documentation

◆ 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.

◆ Parse()

std::unique_ptr<Descriptor> Parse ( const std::string &  descriptor,
FlatSigningProvider out,
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, nullptr is returned.