[#CScript]
= CScript
:mrdocs:

Serialized script, used inside transaction inputs and outputs

== Synopsis

Declared in `&lt;script&sol;script&period;h&gt;`

[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&period;
|===

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:CScript/2constructor-0c.adoc[`CScript`]         [.small]#[constructor]#
| Constructs an empty script&period;
| xref:CScript/2constructor-0e.adoc[`CScript`]         [.small]#[constructor]#
| Constructs a script that pushes a single integer&period;
| xref:CScript/2constructor-00.adoc[`CScript`]         [.small]#[constructor]#
| Constructs a script that holds a single opcode&period;
| xref:CScript/2constructor-08.adoc[`CScript`]         [.small]#[constructor]#
| Constructs a script that pushes a single script number&period;
| xref:CScript/2constructor-0de.adoc[`CScript`]         [.small]#[constructor]# [.small]#[deleted]#
| Deleted byte&hyphen;vector constructor, to defend against future introduction e&period;g&period; via prevector&period;
| xref:CScript/2constructor-0df.adoc[`CScript`]         [.small]#[constructor]#
| Constructs a script from a range of bytes&period;
| xref:CScript/GetOp-07af.adoc[`GetOp`] 
| Reads the next opcode, ignoring any pushed data&period;
| xref:CScript/GetOp-07a4.adoc[`GetOp`] 
| Reads the next opcode and its pushed data&period;
| xref:CScript/GetSigOpCount-059.adoc[`GetSigOpCount`] 
| Counts the signature operations in this script&period;
| xref:CScript/GetSigOpCount-055.adoc[`GetSigOpCount`] 
| Accurately count sigOps, including sigOps in pay&hyphen;to&hyphen;script&hyphen;hash transactions&colon;
| xref:CScript/HasValidOps.adoc[`HasValidOps`] 
| Returns whether the script contains only valid opcodes&period;
| xref:CScript/IsPayToAnchor-01.adoc[`IsPayToAnchor`] 
| Returns whether this script is a pay&hyphen;to&hyphen;anchor (P2A) output script&period;
| xref:CScript/IsPayToScriptHash.adoc[`IsPayToScriptHash`] 
| Returns whether this script is a pay&hyphen;to&hyphen;script&hyphen;hash (P2SH) output&period;
| xref:CScript/IsPayToTaproot.adoc[`IsPayToTaproot`] 
| Returns whether this script is a pay&hyphen;to&hyphen;taproot (P2TR) output&period;
| xref:CScript/IsPayToWitnessScriptHash.adoc[`IsPayToWitnessScriptHash`] 
| Returns whether this script is a pay&hyphen;to&hyphen;witness&hyphen;script&hyphen;hash (P2WSH) output&period;
| xref:CScript/IsPushOnly-04.adoc[`IsPushOnly`] 
| Returns whether the whole script only pushes data onto the stack&period;
| xref:CScript/IsPushOnly-01.adoc[`IsPushOnly`] 
| Returns whether the script only pushes data onto the stack&period;
| xref:CScript/IsUnspendable.adoc[`IsUnspendable`] 
| Returns whether the script is guaranteed to fail at execution, regardless of the initial stack&period; This allows outputs to be pruned instantly when entering the UTXO set&period;
| xref:CScript/IsWitnessProgram.adoc[`IsWitnessProgram`] 
| Returns whether this script is a witness program and extracts its parts&period;
| xref:CScript/clear.adoc[`clear`] 
| Empties the script and releases its memory&period;
| xref:CScript/operator_lshift-062.adoc[`operator&lt;&lt;`] 
| Appends a byte span as a data push (uint8&lowbar;t overload)&period;
| xref:CScript/operator_lshift-069.adoc[`operator&lt;&lt;`] 
| Appends a byte span as a data push, including its size prefix&period;
| xref:CScript/operator_lshift-0fa.adoc[`operator&lt;&lt;`] 
| Appends a script number as pushed data&period;
| xref:CScript/operator_lshift-0b5.adoc[`operator&lt;&lt;`] 
| Appends a single opcode&period;
| xref:CScript/operator_lshift-0ff.adoc[`operator&lt;&lt;`] 
| Appends an integer using the most compact push encoding&period;
| xref:CScript/operator_lshift-0b6.adoc[`operator&lt;&lt;`]  [.small]#[deleted]#
| Delete non&hyphen;existent operator to defend against future introduction
|===


== Static Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:CScript/DecodeOP_N.adoc[`DecodeOP&lowbar;N`] 
| Decodes a small&hyphen;integer opcode to its numeric value&period;
| xref:CScript/EncodeOP_N.adoc[`EncodeOP&lowbar;N`] 
| Encodes a small integer as its push opcode&period;
| 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&lowbar;int64`] 
| Appends an integer using the most compact push encoding&period;
|===


== 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&colon;&colon;operator&lt;&lt;&period;
| xref:CompressScript.adoc[`CompressScript`]
| Compresses a script into the compact on&hyphen;disk representation&period;
| xref:CountWitnessSigOps.adoc[`CountWitnessSigOps`]
| Count the signature operations contributed by a witness spend&period;
| xref:DecompressScript.adoc[`DecompressScript`]
| Reconstructs a script from its compressed representation&period;
| xref:EvalDescriptorStringOrObject.adoc[`EvalDescriptorStringOrObject`]
| Evaluate a descriptor given as a string, or as a &lcub;&quot;desc&quot;&colon;&period;&period;&period;,&quot;range&quot;&colon;&period;&period;&period;&rcub; object, with default range of 1000&period;
| xref:ExtractDestination.adoc[`ExtractDestination`]
| Parse a scriptPubKey for the destination&period;
| xref:FindAndDelete.adoc[`FindAndDelete`]
| Remove every occurrence of a subscript from a script in place&period;
| xref:FormatScript.adoc[`FormatScript`]
| Format a script as a compact single&hyphen;line string for logging and display&period;
| xref:GetScriptForDestination.adoc[`GetScriptForDestination`]
| Generate a Bitcoin scriptPubKey for the given CTxDestination&period; Returns a P2PKH script for a CKeyID destination, a P2SH script for a CScriptID, and an empty script for CNoDestination&period;
| xref:GetScriptForMultisig.adoc[`GetScriptForMultisig`]
| Generate a multisig script&period;
| xref:GetScriptForRawPubKey.adoc[`GetScriptForRawPubKey`]
| Generate a P2PK script for the given pubkey&period;
| xref:InferDescriptor.adoc[`InferDescriptor`]
| Find a descriptor for the specified `script`, using information from `provider` where possible&period;
| xref:IsStandard.adoc[`IsStandard`]
| Determine whether a scriptPubKey uses a standard output form&period;
| xref:MatchMultiA.adoc[`MatchMultiA`]
| Determine if script is a &quot;multi&lowbar;a&quot; script&period; Returns (threshold, keyspans) if so, and nullopt otherwise&period; The keyspans refer to bytes in the passed script&period;
| xref:ParseScript.adoc[`ParseScript`]
| Parse a human&hyphen;readable script (opcodes and push data) into a CScript&period;
| xref:ScriptToAsmStr.adoc[`ScriptToAsmStr`]
| Render a script as a human&hyphen;readable assembly string&period;
| xref:ScriptToUniv.adoc[`ScriptToUniv`]
| Fill a JSON object with a human&hyphen;readable description of a script&period;
| xref:SignatureHash.adoc[`SignatureHash`]
| Compute the signature hash for one input under the selected signature version&period;
| xref:Solver.adoc[`Solver`]
| Parse a scriptPubKey and identify script type for standard scripts&period; If successful, returns script type and parsed pubkeys or hashes, depending on the type&period; For example, for a P2SH script, vSolutionsRet will contain the script hash, for P2PKH it will contain the key hash, etc&period;
| xref:VerifyScript.adoc[`VerifyScript`]
| Verify that an input&apos;s scriptSig and witness satisfy the output&apos;s scriptPubKey&period;
| xref:kernel/GetBogoSize.adoc[`kernel&colon;&colon;GetBogoSize`]
| Computes the serialization&hyphen;agnostic size measure of an output script&period;
| xref:miniscript/FromScript.adoc[`miniscript&colon;&colon;FromScript`]
| Decodes a Miniscript from a Bitcoin Script&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
