[#CScript] = CScript :mrdocs: Serialized script, used inside transaction inputs and outputs == Synopsis Declared in `<script/script.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- class CScript : public xref:CScriptBase.adoc[CScriptBase] ---- == Base Classes [cols="1,4"] |=== | Name| Description | `xref:CScriptBase.adoc[CScriptBase]` | 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. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:CScript/2constructor-0c.adoc[`CScript`] [.small]#[constructor]# | Constructs an empty script. | xref:CScript/2constructor-0e.adoc[`CScript`] [.small]#[constructor]# | Constructs a script that pushes a single integer. | xref:CScript/2constructor-00.adoc[`CScript`] [.small]#[constructor]# | Constructs a script that holds a single opcode. | xref:CScript/2constructor-08.adoc[`CScript`] [.small]#[constructor]# | Constructs a script that pushes a single script number. | xref:CScript/2constructor-0de.adoc[`CScript`] [.small]#[constructor]# [.small]#[deleted]# | Deleted byte‐vector constructor, to defend against future introduction e.g. via prevector. | xref:CScript/2constructor-0df.adoc[`CScript`] [.small]#[constructor]# | Constructs a script from a range of bytes. | xref:CScript/GetOp-07af.adoc[`GetOp`] | Reads the next opcode, ignoring any pushed data. | xref:CScript/GetOp-07a4.adoc[`GetOp`] | Reads the next opcode and its pushed data. | xref:CScript/GetSigOpCount-059.adoc[`GetSigOpCount`] | Counts the signature operations in this script. | xref:CScript/GetSigOpCount-055.adoc[`GetSigOpCount`] | Accurately count sigOps, including sigOps in pay‐to‐script‐hash transactions: | xref:CScript/HasValidOps.adoc[`HasValidOps`] | Returns whether the script contains only valid opcodes. | xref:CScript/IsPayToAnchor-01.adoc[`IsPayToAnchor`] | Returns whether this script is a pay‐to‐anchor (P2A) output script. | xref:CScript/IsPayToScriptHash.adoc[`IsPayToScriptHash`] | Returns whether this script is a pay‐to‐script‐hash (P2SH) output. | xref:CScript/IsPayToTaproot.adoc[`IsPayToTaproot`] | Returns whether this script is a pay‐to‐taproot (P2TR) output. | xref:CScript/IsPayToWitnessScriptHash.adoc[`IsPayToWitnessScriptHash`] | Returns whether this script is a pay‐to‐witness‐script‐hash (P2WSH) output. | xref:CScript/IsPushOnly-04.adoc[`IsPushOnly`] | Returns whether the whole script only pushes data onto the stack. | xref:CScript/IsPushOnly-01.adoc[`IsPushOnly`] | Returns whether the script only pushes data onto the stack. | xref:CScript/IsUnspendable.adoc[`IsUnspendable`] | Returns whether the script is guaranteed to fail at execution, regardless of the initial stack. This allows outputs to be pruned instantly when entering the UTXO set. | xref:CScript/IsWitnessProgram.adoc[`IsWitnessProgram`] | Returns whether this script is a witness program and extracts its parts. | xref:CScript/clear.adoc[`clear`] | Empties the script and releases its memory. | xref:CScript/operator_lshift-062.adoc[`operator<<`] | Appends a byte span as a data push (uint8_t overload). | xref:CScript/operator_lshift-069.adoc[`operator<<`] | Appends a byte span as a data push, including its size prefix. | xref:CScript/operator_lshift-0fa.adoc[`operator<<`] | Appends a script number as pushed data. | xref:CScript/operator_lshift-0b5.adoc[`operator<<`] | Appends a single opcode. | xref:CScript/operator_lshift-0ff.adoc[`operator<<`] | Appends an integer using the most compact push encoding. | xref:CScript/operator_lshift-0b6.adoc[`operator<<`] [.small]#[deleted]# | Delete non‐existent operator to defend against future introduction |=== == Static Member Functions [cols="1,4"] |=== | Name| Description | xref:CScript/DecodeOP_N.adoc[`DecodeOP_N`] | Decodes a small‐integer opcode to its numeric value. | xref:CScript/EncodeOP_N.adoc[`EncodeOP_N`] | Encodes a small integer as its push opcode. | xref:CScript/IsPayToAnchor-0f.adoc[`IsPayToAnchor`] | Checks if output of IsWitnessProgram comes from a P2A output script |=== == Protected Member Functions [cols="1,4"] |=== | Name| Description | xref:CScript/push_int64.adoc[`push_int64`] | Appends an integer using the most compact push encoding. |=== == Non-Member Functions [cols="1,4"] |=== | Name| Description | xref:BuildScript.adoc[`BuildScript`] | Build a script by concatenating other scripts, or any argument accepted by CScript::operator<<. | xref:CompressScript.adoc[`CompressScript`] | Compresses a script into the compact on‐disk representation. | xref:CountWitnessSigOps.adoc[`CountWitnessSigOps`] | Count the signature operations contributed by a witness spend. | xref:DecompressScript.adoc[`DecompressScript`] | Reconstructs a script from its compressed representation. | xref:EvalDescriptorStringOrObject.adoc[`EvalDescriptorStringOrObject`] | Evaluate a descriptor given as a string, or as a {"desc":...,"range":...} object, with default range of 1000. | xref:ExtractDestination.adoc[`ExtractDestination`] | Parse a scriptPubKey for the destination. | xref:FindAndDelete.adoc[`FindAndDelete`] | Remove every occurrence of a subscript from a script in place. | xref:FormatScript.adoc[`FormatScript`] | Format a script as a compact single‐line string for logging and display. | xref:GetScriptForDestination.adoc[`GetScriptForDestination`] | 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. | xref:GetScriptForMultisig.adoc[`GetScriptForMultisig`] | Generate a multisig script. | xref:GetScriptForRawPubKey.adoc[`GetScriptForRawPubKey`] | Generate a P2PK script for the given pubkey. | xref:InferDescriptor.adoc[`InferDescriptor`] | Find a descriptor for the specified `script`, using information from `provider` where possible. | xref:IsStandard.adoc[`IsStandard`] | Determine whether a scriptPubKey uses a standard output form. | xref:MatchMultiA.adoc[`MatchMultiA`] | Determine if script is a "multi_a" script. Returns (threshold, keyspans) if so, and nullopt otherwise. The keyspans refer to bytes in the passed script. | xref:ParseScript.adoc[`ParseScript`] | Parse a human‐readable script (opcodes and push data) into a CScript. | xref:ScriptToAsmStr.adoc[`ScriptToAsmStr`] | Render a script as a human‐readable assembly string. | xref:ScriptToUniv.adoc[`ScriptToUniv`] | Fill a JSON object with a human‐readable description of a script. | xref:SignatureHash.adoc[`SignatureHash`] | Compute the signature hash for one input under the selected signature version. | xref:Solver.adoc[`Solver`] | 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. | xref:VerifyScript.adoc[`VerifyScript`] | Verify that an input's scriptSig and witness satisfy the output's scriptPubKey. | xref:kernel/GetBogoSize.adoc[`kernel::GetBogoSize`] | Computes the serialization‐agnostic size measure of an output script. | xref:miniscript/FromScript.adoc[`miniscript::FromScript`] | Decodes a Miniscript from a Bitcoin Script. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#