Bitcoin Core  27.99.0
P2P Digital Currency
Classes | Typedefs | Functions
addresstype.h File Reference
#include <attributes.h>
#include <pubkey.h>
#include <script/script.h>
#include <uint256.h>
#include <util/hash_type.h>
#include <algorithm>
#include <variant>
#include <vector>
Include dependency graph for addresstype.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  CNoDestination
 
struct  PubKeyDestination
 
struct  PKHash
 
struct  ScriptHash
 
struct  WitnessV0ScriptHash
 
struct  WitnessV0KeyHash
 
struct  WitnessV1Taproot
 
struct  WitnessUnknown
 CTxDestination subtype to encode any future Witness version. More...
 

Typedefs

using CTxDestination = std::variant< CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown >
 A txout script categorized into standard templates. More...
 

Functions

CKeyID ToKeyID (const PKHash &key_hash)
 
CScriptID ToScriptID (const ScriptHash &script_hash)
 
CKeyID ToKeyID (const WitnessV0KeyHash &key_hash)
 
bool IsValidDestination (const CTxDestination &dest)
 Check whether a CTxDestination corresponds to one with an address. More...
 
bool ExtractDestination (const CScript &scriptPubKey, CTxDestination &addressRet)
 Parse a scriptPubKey for the destination. More...
 
CScript GetScriptForDestination (const CTxDestination &dest)
 Generate a Bitcoin scriptPubKey for the given CTxDestination. More...
 

Typedef Documentation

◆ CTxDestination

A txout script categorized into standard templates.

Definition at line 131 of file addresstype.h.

Function Documentation

◆ ExtractDestination()

bool ExtractDestination ( const CScript scriptPubKey,
CTxDestination addressRet 
)

Parse a scriptPubKey for the destination.

For standard scripts that have addresses (and P2PK as an exception), a corresponding CTxDestination is assigned to addressRet. For all other scripts. addressRet is assigned as a CNoDestination containing the scriptPubKey.

Returns true for standard destinations with addresses - P2PKH, P2SH, P2WPKH, P2WSH, P2TR and P2W??? scripts. Returns false for non-standard destinations and those without addresses - P2PK, bare multisig, null data, and nonstandard scripts.

Definition at line 49 of file addresstype.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 162 of file addresstype.cpp.

◆ IsValidDestination()

bool IsValidDestination ( const CTxDestination dest)

Check whether a CTxDestination corresponds to one with an address.

Definition at line 167 of file addresstype.cpp.

Here is the caller graph for this function:

◆ ToKeyID() [1/2]

CKeyID ToKeyID ( const PKHash key_hash)

Definition at line 29 of file addresstype.cpp.

Here is the caller graph for this function:

◆ ToKeyID() [2/2]

CKeyID ToKeyID ( const WitnessV0KeyHash key_hash)

Definition at line 34 of file addresstype.cpp.

◆ ToScriptID()

CScriptID ToScriptID ( const ScriptHash script_hash)

Definition at line 39 of file addresstype.cpp.

Here is the caller graph for this function: