Bitcoin Core 31.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
solver.h File Reference
#include <attributes.h>
#include <script/script.h>
#include <span.h>
#include <string>
#include <optional>
#include <utility>
#include <vector>
Include dependency graph for solver.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum class  TxoutType {
  NONSTANDARD , ANCHOR , PUBKEY , PUBKEYHASH ,
  SCRIPTHASH , MULTISIG , NULL_DATA , WITNESS_V0_SCRIPTHASH ,
  WITNESS_V0_KEYHASH , WITNESS_V1_TAPROOT , WITNESS_UNKNOWN
}

Functions

std::string GetTxnOutputType (TxoutType t)
 Get the name of a TxoutType as a string.
constexpr bool IsPushdataOp (opcodetype opcode)
TxoutType Solver (const CScript &scriptPubKey, std::vector< std::vector< unsigned char > > &vSolutionsRet)
 Parse a scriptPubKey and identify script type for standard scripts.
CScript GetScriptForRawPubKey (const CPubKey &pubkey)
 Generate a P2PK script for the given pubkey.
std::optional< std::pair< int, std::vector< std::span< const unsigned char > > > > MatchMultiA (const CScript &script LIFETIMEBOUND)
 Determine if script is a "multi_a" script.
CScript GetScriptForMultisig (int nRequired, const std::vector< CPubKey > &keys)
 Generate a multisig script.

Enumeration Type Documentation

◆ TxoutType

enum class TxoutType
strong
Enumerator
NONSTANDARD 
ANCHOR 

anyone can spend script

PUBKEY 
PUBKEYHASH 
SCRIPTHASH 
MULTISIG 
NULL_DATA 

unspendable OP_RETURN script that carries data

WITNESS_V0_SCRIPTHASH 
WITNESS_V0_KEYHASH 
WITNESS_V1_TAPROOT 
WITNESS_UNKNOWN 

Only for Witness versions not already defined above.

Definition at line 22 of file solver.h.

Function Documentation

◆ GetScriptForMultisig()

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

Generate a multisig script.

Definition at line 218 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 213 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:

◆ IsPushdataOp()

bool IsPushdataOp ( opcodetype opcode)
constexpr

Definition at line 40 of file solver.h.

Here is the caller graph for this function:

◆ MatchMultiA()

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

Determine if script is a "multi_a" script.

Returns (threshold, keyspans) if so, and nullopt otherwise. The keyspans refer to bytes in the passed script.

◆ 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 141 of file solver.cpp.

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