Bitcoin ABC  0.24.10
P2P Digital Currency
Typedefs | Functions | Variables
standard.cpp File Reference
#include <script/standard.h>
#include <crypto/sha256.h>
#include <script/script.h>
#include <string>
Include dependency graph for standard.cpp:

Go to the source code of this file.

Typedefs

typedef std::vector< uint8_t > valtype
 

Functions

CKeyID ToKeyID (const PKHash &key_hash)
 
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 bool MatchMultisig (const CScript &script, unsigned int &required, std::vector< valtype > &pubkeys)
 
TxoutType Solver (const CScript &scriptPubKey, std::vector< std::vector< uint8_t >> &vSolutionsRet)
 Parse a scriptPubKey and identify script type for standard scripts. More...
 
bool ExtractDestination (const CScript &scriptPubKey, CTxDestination &addressRet)
 Parse a standard scriptPubKey for the destination address. More...
 
bool ExtractDestinations (const CScript &scriptPubKey, TxoutType &typeRet, std::vector< CTxDestination > &addressRet, int &nRequiredRet)
 Parse a standard scriptPubKey with one or more destination addresses. More...
 
CScript GetScriptForDestination (const CTxDestination &dest)
 Generate a Bitcoin scriptPubKey for the given CTxDestination. 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...
 
bool IsValidDestination (const CTxDestination &dest)
 Check whether a CTxDestination is a CNoDestination. More...
 

Variables

bool fAcceptDatacarrier = DEFAULT_ACCEPT_DATACARRIER
 A data carrying output is an unspendable output containing data. More...
 

Typedef Documentation

◆ valtype

typedef std::vector<uint8_t> valtype

Definition at line 13 of file standard.cpp.

Function Documentation

◆ ExtractDestination()

bool ExtractDestination ( const CScript scriptPubKey,
CTxDestination addressRet 
)

Parse a standard scriptPubKey for the destination address.

Assigns result to the addressRet parameter and returns true if successful. For multisig scripts, instead use ExtractDestinations. Currently only works for P2PK, P2PKH, and P2SH scripts.

Definition at line 161 of file standard.cpp.

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

◆ ExtractDestinations()

bool ExtractDestinations ( const CScript scriptPubKey,
TxoutType typeRet,
std::vector< CTxDestination > &  addressRet,
int &  nRequiredRet 
)

Parse a standard scriptPubKey with one or more destination addresses.

For multisig scripts, this populates the addressRet vector with the pubkey IDs and nRequiredRet with the n required to spend. For other destinations, addressRet is populated with a single value and nRequiredRet is set to 1. Returns true if successful.

Note: this function confuses destinations (a subset of CScripts that are encodable as an address) with key identifiers (of keys involved in a CScript), and its use should be phased out.

Definition at line 187 of file standard.cpp.

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

◆ GetScriptForDestination()

CScript GetScriptForDestination ( const CTxDestination dest)

Generate a Bitcoin scriptPubKey for the given CTxDestination.

Returns a P2PKH script for a CKeyID destination, a P2SH script for a CScriptID, and an empty script for CNoDestination.

Definition at line 243 of file standard.cpp.

Here is the caller graph for this function:

◆ GetScriptForMultisig()

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

Generate a multisig script.

Definition at line 252 of file standard.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 247 of file standard.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 32 of file standard.cpp.

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 77 of file standard.cpp.

Here is the caller graph for this function:

◆ IsValidDestination()

bool IsValidDestination ( const CTxDestination dest)

Check whether a CTxDestination is a CNoDestination.

Definition at line 263 of file standard.cpp.

Here is the caller graph for this function:

◆ MatchMultisig()

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

Definition at line 81 of file standard.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 50 of file standard.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 66 of file standard.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< uint8_t >> &  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 111 of file standard.cpp.

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

◆ ToKeyID()

CKeyID ToKeyID ( const PKHash key_hash)

Definition at line 28 of file standard.cpp.

Here is the caller graph for this function:

Variable Documentation

◆ fAcceptDatacarrier

bool fAcceptDatacarrier = DEFAULT_ACCEPT_DATACARRIER

A data carrying output is an unspendable output containing data.

The script type is designated as TxoutType::NULL_DATA.

Definition at line 15 of file standard.cpp.