 |
Bitcoin Core
22.99.0
P2P Digital Currency
|
Go to the documentation of this file.
6 #ifndef BITCOIN_SCRIPT_STANDARD_H
7 #define BITCOIN_SCRIPT_STANDARD_H
157 using CTxDestination = std::variant<CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown>;
199 bool operator()(
const std::vector<unsigned char>& a,
const std::vector<unsigned char>& b)
const
201 if (a.size() < b.size())
return true;
202 if (a.size() > b.size())
return false;
312 static bool ValidDepths(
const std::vector<int>& depths);
325 #endif // BITCOIN_SCRIPT_STANDARD_H
WitnessV0KeyHash(const uint160 &hash)
std::optional< std::vector< std::tuple< int, CScript, int > > > InferTaprootTree(const TaprootSpendData &spenddata, const XOnlyPubKey &output)
Given a TaprootSpendData and the output key, reconstruct its script tree.
CTxDestination subtype to encode any future Witness version.
WitnessV1Taproot(const XOnlyPubKey &xpk)
std::map< std::pair< CScript, int >, std::set< std::vector< unsigned char >, ShortestVectorFirstComparator > > scripts
Map from (script, leaf_version) to (sets of) control blocks.
@ WITNESS_UNKNOWN
Only for Witness versions not already defined above.
TaprootSpendData GetSpendData() const
Compute spending data (after Finalize()).
void Insert(NodeInfo &&node, int depth)
Insert information about a node at a certain depth, and propagate information up.
Information associated with a node in the Merkle tree.
unsigned nMaxDatacarrierBytes
Maximum size of TxoutType::NULL_DATA scripts that this node considers standard.
A reference to a CKey: the Hash160 of its serialized public key.
friend bool operator==(const CNoDestination &a, const CNoDestination &b)
std::string GetTxnOutputType(TxoutType t)
Get the name of a TxoutType as a string.
CKeyID ToKeyID(const PKHash &key_hash)
CScript script
The script.
CScript GetScriptForRawPubKey(const CPubKey &pubkey)
Generate a P2PK script for the given pubkey.
CScript GetScriptForMultisig(int nRequired, const std::vector< CPubKey > &keys)
Generate a multisig script.
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
WitnessV1Taproot GetOutput()
Compute scriptPubKey (after Finalize()).
friend bool operator<(const CNoDestination &a, const CNoDestination &b)
bool m_valid
Whether the builder is in a valid state so far.
std::vector< LeafInfo > leaves
Tracked leaves underneath this node (either from the node itself, or its children).
ScriptHash(const uint160 &hash)
TxoutType Solver(const CScript &scriptPubKey, std::vector< std::vector< unsigned char >> &vSolutionsRet)
Parse a scriptPubKey and identify script type for standard scripts.
uint256 merkle_root
The Merkle root of the script tree (0 if no scripts).
TaprootBuilder & Add(int depth, const CScript &script, int leaf_version, bool track=true)
Add a new script at a certain depth in the tree.
bool operator()(const std::vector< unsigned char > &a, const std::vector< unsigned char > &b) const
int leaf_version
The leaf version for that script.
uint256 hash
Merkle hash of this node.
std::vector< std::optional< NodeInfo > > m_branch
The current state of the builder.
Serialized script, used inside transaction inputs and outputs.
XOnlyPubKey m_output_key
The output key, computed when finalizing.
static bool ValidDepths(const std::vector< int > &depths)
Check if a list of depths is legal (will lead to IsComplete()).
bool IsComplete() const
Return whether there were either no leaves, or the leaves form a Huffman tree.
PKHash(const uint160 &hash)
XOnlyPubKey internal_key
The BIP341 internal key.
@ NULL_DATA
unspendable OP_RETURN script that carries data
friend bool operator<(const WitnessUnknown &w1, const WitnessUnknown &w2)
An encapsulated public key.
static const unsigned int MAX_OP_RETURN_RELAY
Default setting for nMaxDatacarrierBytes.
CScriptID(const uint160 &in)
std::vector< uint256 > merkle_branch
The hashing partners above this leaf.
XOnlyPubKey m_internal_key
The internal key, set when finalizing.
WitnessV0ScriptHash(const uint256 &hash)
Information about a tracked leaf in the Merkle tree.
bool m_parity
The tweak parity, computed when finalizing.
bool IsValid() const
Return true if so far all input was valid.
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination is a CNoDestination.
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
TaprootBuilder & Finalize(const XOnlyPubKey &internal_key)
Finalize the construction.
friend bool operator==(const WitnessUnknown &w1, const WitnessUnknown &w2)
Utility class to construct Taproot outputs from internal key and script tree.
A reference to a CScript: the Hash160 of its serialization (see script.h)
TaprootBuilder & AddOmitted(int depth, const uint256 &hash)
Like Add(), but for a Merkle node with a given hash to the tree.
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a standard scriptPubKey for the destination address.
static NodeInfo Combine(NodeInfo &&a, NodeInfo &&b)
Combine information about a parent Merkle tree node from its child nodes.
static const unsigned int MANDATORY_SCRIPT_VERIFY_FLAGS
Mandatory script verification flags that all new blocks must comply with for them to be valid.
bool fAcceptDatacarrier
A data carrying output is an unspendable output containing data.
void Merge(TaprootSpendData other)
Merge other TaprootSpendData (for the same scriptPubKey) into this.
unsigned char program[40]
static const bool DEFAULT_ACCEPT_DATACARRIER