Modules

Structs

| A data type to abstract out the condition | stack during script execution. | | Conceptually it acts like a vector of | booleans, one for each level of nested | | IF/THEN/ELSE, indicating whether | we’re in the active or inactive branch | of each. | | The elements on the stack cannot be observed | individually; we only need to expose | whether the stack is empty and whether | or not any false values are present at | all. To implement OP_ELSE, a toggle_top | modifier is added, which flips the last | value without returning it. | | This uses an optimized implementation | that does not materialize the actual | stack. Instead, it just stores the size | of the would-be stack, and the position | of the first false value in it. |
| A generic txid reference (txid or wtxid). |
| Serialized script, used inside transaction | inputs and outputs |
| A reference to a Script: the Hash160 | of its serialization (see script.h) |
| Valid signature cache, to avoid doing | expensive ECDSA signature checking | twice for every transaction (once when | accepted into memory pool, and again | when accepted into the block chain) |
| This struct contains information from | a transaction input and also contains | signatures for that input. | | The information contained here can be used to | create a signature and is also filled by | ProduceSignature in order to construct final | scriptSigs and scriptWitnesses.
| Utility class to construct Taproot | outputs from internal key and script | tree. |
| A class that deserializes a single CTransaction | one time. |
| TxDestination subtype to encode any | future Witness version |

Enums

| Enum to specify what *TransactionSignatureChecker’s | behavior should be when dealing with | missing transaction data. |
| A txout script template with a specific | destination. It is either: | | - CNoDestination: no destination set | | - PKHash: TxoutType::PUBKEYHASH destination | (P2PKH) | | - ScriptHash: TxoutType::SCRIPTHASH | destination (P2SH) | | - WitnessV0ScriptHash: TxoutType::WITNESS_V0_SCRIPTHASH | destination (P2WSH) | | - WitnessV0KeyHash: TxoutType::WITNESS_V0_KEYHASH | destination (P2WPKH) | | - WitnessV1Taproot: TxoutType::WITNESS_V1_TAPROOT | destination (P2TR) | | - WitnessUnknown: TxoutType::WITNESS_UNKNOWN | destination (P2W???) | | A TxDestination is the internal data | type encoded in a bitcoin address |

Constants

| Tag for input annex. If there are at least two | witness elements for a transaction input, and | the first byte of the last element is 0x50, | this last element is called annex, and has | meanings independent of the script
| DoS prevention: limit cache size to 32MB (over | 1000000 entries on 64-bit systems). Due to how | we count cache size, actual memory usage is | slightly more (~32.25 MB)
| Maximum nLockTime. Since a lock time indicates | the last invalid timestamp, a transaction with | this lock time will never be valid unless lock | time checking is disabled (by setting all input | sequence numbers to SEQUENCE_FINAL).
| Threshold for nLockTime: below this | value it is interpreted as block number, | otherwise as UNIX timestamp. |
| Maximum sig cache size allowed |
| Maximum value that an opcode can be |
| Maximum number of non-push operations | per script |
| Default setting for nMaxDatacarrierBytes. | 80 bytes of data, +1 for OP_RETURN, +2 | for the pushdata opcodes. |
| Maximum number of public keys per multisig |
| Maximum number of bytes pushable to | the stack |
| Maximum script length in bytes |
| Maximum number of values on script interpreter | stack |
| Taproot only; implied when sighash | byte is missing, and equivalent to SIGHASH_ALL |
| How much weight budget is added to the | witness size (Tapscript only, see BIP | 342). |
| Validation weight per passing signature | (Tapscript only, see BIP 342). |
| Signature hash sizes |

Traits

Functions

| Returns 1 if the input nIn of the serialized | transaction pointed to by txTo correctly | spends the scriptPubKey pointed to by | scriptPubKey under the additional constraints | specified by flags. | | If not nullptr, err will contain an | error/success code for the operation
| Compute the BIP341 tapleaf hash from | leaf version & script. |
| Compute the BIP341 taproot script tree | Merkle root from control block and leaf | hash. | | Requires control block to have valid | length (33 + k*32, with k in {0,1,..,128}). |
| Deserialize HD keypaths into a map |
| Helper for OP_CHECKSIG, OP_CHECKSIGVERIFY, | and (in Tapscript) OP_CHECKSIGADD. | | A return value of false means the script | fails entirely. When true is returned, | the success variable indicates whether | the signature check itself succeeded. |
| Parse a standard scriptPubKey for the | destination address. Assigns result | to the addressRet parameter and returns | true if successful. Currently only | works for P2PK, P2PKH, P2SH, P2WPKH, | and P2WSH scripts. |
| Compute the (single) SHA256 of the concatenation | of all txouts of a tx. |
| Compute the (single) SHA256 of the concatenation | of all prevouts of a tx. |
| Generate a Bitcoin scriptPubKey for the given | TxDestination. | | Returns a P2PKH script for a CKeyID | destination, a P2SH script for a CScriptID, | and an empty script for CNoDestination. |
| Generate a multisig script. |
| Generate a P2PK script for the given | pubkey. |
| Compute the (single) SHA256 of the concatenation | of all nSequences of a tx. |
| Get the name of a TxoutType as a string |
| Given a TaprootSpendData and the output | key, reconstruct its script tree. | | If the output doesn’t match the spenddata, | or if the data in spenddata is incomplete, | std::nullopt is returned. Otherwise, | a vector of (depth, script, leaf_ver) | tuples is returned, corresponding | to a depth-first traversal of the script | tree. |
| To be called once in | | AppInitMain/BasicTestingSetup to | initialize the signatureCache. |
| Test for OP_SUCCESSx opcodes as defined | by BIP342. |
| Test for “small positive integer” script | opcodes - OP_1 through OP_16. |
| Check whether a TxDestination is a | CNoDestination. |
| A canonical signature exists of: <30> | <02> <02> <len | S> | | Where R and S are not negative (their | first byte has its highest bit not set), | and not excessively padded (do not start | with a 0 byte, unless an otherwise negative | number follows, in which case a single | 0 byte is necessary and even required). | | See https://bitcointalk.org/index.php?topic=8392.msg127623#msg127623 | | This function is consensus-critical | since BIP66. |
| Serialize HD keypaths to a stream from | a map |
| Takes a stream and multiple arguments and | serializes them as if first serialized into | a vector and then into the stream | | The resulting output into the stream has the | total serialized length of all of the objects | followed by all objects concatenated with each | other.
| 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. | | ———– | @param[in] scriptPubKey | | Script to parse | ––––– | @param[out] vSolutionsRet | | Vector of parsed pubkeys and hashes | | ———– | @return | | The script type. TxoutType::NONSTANDARD | represents a failed solve. |
| Takes a stream and multiple arguments and | unserializes them first as a vector then each | object individually in the order provided in | the arguments
| Check that all specified flags are part | of the libconsensus interface. |

Type Definitions

| Script opcodes |
| We use a prevector for the script to reduce | the considerable memory overhead of | vectors in cases where they normally | contain a small number of small elements. | | Tests in October 2015 showed use of this | reduced dbcache memory usage by 23% | and made an initial sync 13% faster. |