Bitcoin ABC  0.22.13
P2P Digital Currency
Classes | Typedefs | Enumerations | Functions | Variables
standard.h File Reference
#include <amount.h>
#include <pubkey.h>
#include <script/script_flags.h>
#include <uint256.h>
#include <boost/variant.hpp>
Include dependency graph for standard.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  CScriptID
 A reference to a CScript: the Hash160 of its serialization (see script.h) More...
 
class  CNoDestination
 
struct  PKHash
 
struct  ScriptHash
 

Typedefs

typedef boost::variant< CNoDestination, PKHash, ScriptHashCTxDestination
 A txout script template with a specific destination. More...
 

Enumerations

enum  txnouttype {
  TX_NONSTANDARD, TX_PUBKEY, TX_PUBKEYHASH, TX_SCRIPTHASH,
  TX_MULTISIG, TX_NULL_DATA
}
 

Functions

bool IsValidDestination (const CTxDestination &dest)
 Check whether a CTxDestination is a CNoDestination. More...
 
const char * GetTxnOutputType (txnouttype t)
 Get the name of a txnouttype as a C string, or nullptr if unknown. More...
 
txnouttype 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, txnouttype &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...
 

Variables

static const bool DEFAULT_ACCEPT_DATACARRIER = true
 
static const unsigned int MAX_OP_RETURN_RELAY = 223
 Default setting for nMaxDatacarrierBytes. More...
 
bool fAcceptDatacarrier
 A data carrying output is an unspendable output containing data. More...
 

Typedef Documentation

◆ CTxDestination

typedef boost::variant<CNoDestination, PKHash, ScriptHash> CTxDestination

A txout script template with a specific destination.

It is either:

  • CNoDestination: no destination set
  • PKHash: TX_PUBKEYHASH destination (P2PKH)
  • ScriptHash: TX_SCRIPTHASH destination (P2SH) A CTxDestination is the internal data type encoded in a bitcoin address

Definition at line 87 of file standard.h.

Enumeration Type Documentation

◆ txnouttype

enum txnouttype
Enumerator
TX_NONSTANDARD 
TX_PUBKEY 
TX_PUBKEYHASH 
TX_SCRIPTHASH 
TX_MULTISIG 
TX_NULL_DATA 

Definition at line 41 of file standard.h.

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 152 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,
txnouttype 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 178 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 246 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 258 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 253 of file standard.cpp.

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

◆ GetTxnOutputType()

const char* GetTxnOutputType ( txnouttype  t)

Get the name of a txnouttype as a C string, or nullptr if unknown.

Definition at line 23 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 269 of file standard.cpp.

Here is the caller graph for this function:

◆ Solver()

txnouttype 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. TX_NONSTANDARD represents a failed solve.

Definition at line 102 of file standard.cpp.

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

Variable Documentation

◆ DEFAULT_ACCEPT_DATACARRIER

const bool DEFAULT_ACCEPT_DATACARRIER = true
static

Definition at line 16 of file standard.h.

◆ fAcceptDatacarrier

bool fAcceptDatacarrier

A data carrying output is an unspendable output containing data.

The script type is designated as TX_NULL_DATA.

Definition at line 13 of file standard.cpp.

◆ MAX_OP_RETURN_RELAY

const unsigned int MAX_OP_RETURN_RELAY = 223
static

Default setting for nMaxDatacarrierBytes.

220 bytes of data, +1 for OP_RETURN, +2 for the pushdata opcodes.

Definition at line 33 of file standard.h.