Bitcoin Core  26.99.0
P2P Digital Currency
Typedefs | Functions
solver.cpp File Reference
#include <pubkey.h>
#include <script/interpreter.h>
#include <script/script.h>
#include <script/solver.h>
#include <span.h>
#include <algorithm>
#include <cassert>
#include <string>
Include dependency graph for solver.cpp:

Go to the source code of this file.

Typedefs

typedef std::vector< unsigned char > valtype
 

Functions

std::string GetTxnOutputType (TxoutType t)
 Get the name of a TxoutType as a string. More...
 
static bool MatchPayToPubkey (const CScript &script, valtype &pubkey)
 
static bool MatchPayToPubkeyHash (const CScript &script, valtype &pubkeyhash)
 
static constexpr bool IsSmallInteger (opcodetype opcode)
 Test for "small positive integer" script opcodes - OP_1 through OP_16. More...
 
static std::optional< int > GetScriptNumber (opcodetype opcode, valtype data, int min, int max)
 Retrieve a minimally-encoded number in range [min,max] from an (opcode, data) pair, whether it's OP_n or through a push. More...
 
static bool MatchMultisig (const CScript &script, int &required_sigs, std::vector< valtype > &pubkeys)
 
std::optional< std::pair< int, std::vector< Span< const unsigned char > > > > MatchMultiA (const CScript &script)
 
TxoutType Solver (const CScript &scriptPubKey, std::vector< std::vector< unsigned char >> &vSolutionsRet)
 Parse a scriptPubKey and identify script type for standard scripts. More...
 
CScript GetScriptForRawPubKey (const CPubKey &pubKey)
 Generate a P2PK script for the given pubkey. More...
 
CScript GetScriptForMultisig (int nRequired, const std::vector< CPubKey > &keys)
 Generate a multisig script. More...
 

Typedef Documentation

◆ valtype

typedef std::vector<unsigned char> valtype

Definition at line 16 of file solver.cpp.

Function Documentation

◆ GetScriptForMultisig()

CScript GetScriptForMultisig ( int  nRequired,
const std::vector< CPubKey > &  keys 
)

Generate a multisig script.

Definition at line 214 of file solver.cpp.

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

◆ GetScriptForRawPubKey()

CScript GetScriptForRawPubKey ( const CPubKey pubKey)

Generate a P2PK script for the given pubkey.

Definition at line 209 of file solver.cpp.

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

◆ GetScriptNumber()

static std::optional<int> GetScriptNumber ( opcodetype  opcode,
valtype  data,
int  min,
int  max 
)
static

Retrieve a minimally-encoded number in range [min,max] from an (opcode, data) pair, whether it's OP_n or through a push.

Definition at line 65 of file solver.cpp.

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

◆ GetTxnOutputType()

std::string GetTxnOutputType ( TxoutType  t)

Get the name of a TxoutType as a string.

Definition at line 18 of file solver.cpp.

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

◆ IsSmallInteger()

static constexpr bool IsSmallInteger ( opcodetype  opcode)
staticconstexpr

Test for "small positive integer" script opcodes - OP_1 through OP_16.

Definition at line 58 of file solver.cpp.

Here is the caller graph for this function:

◆ MatchMultiA()

std::optional<std::pair<int, std::vector<Span<const unsigned char> > > > MatchMultiA ( const CScript script)

Definition at line 106 of file solver.cpp.

Here is the call graph for this function:

◆ MatchMultisig()

static bool MatchMultisig ( const CScript script,
int &  required_sigs,
std::vector< valtype > &  pubkeys 
)
static

Definition at line 84 of file solver.cpp.

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

◆ MatchPayToPubkey()

static bool MatchPayToPubkey ( const CScript script,
valtype pubkey 
)
static

Definition at line 35 of file solver.cpp.

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

◆ MatchPayToPubkeyHash()

static bool MatchPayToPubkeyHash ( const CScript script,
valtype pubkeyhash 
)
static

Definition at line 48 of file solver.cpp.

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

◆ Solver()

TxoutType Solver ( const CScript scriptPubKey,
std::vector< std::vector< unsigned char >> &  vSolutionsRet 
)

Parse a scriptPubKey and identify script type for standard scripts.

If successful, returns script type and parsed pubkeys or hashes, depending on the type. For example, for a P2SH script, vSolutionsRet will contain the script hash, for P2PKH it will contain the key hash, etc.

Parameters
[in]scriptPubKeyScript to parse
[out]vSolutionsRetVector of parsed pubkeys and hashes
Returns
The script type. TxoutType::NONSTANDARD represents a failed solve.

Definition at line 140 of file solver.cpp.

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