Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

interpreter.cpp File Reference
#include <script/interpreter.h>
#include <crypto/ripemd160.h>
#include <crypto/sha1.h>
#include <crypto/sha256.h>
#include <pubkey.h>
#include <script/script.h>
#include <uint256.h>
+ Include dependency graph for interpreter.cpp:

Go to the source code of this file.

Macros

#define stacktop(i)   (stack.at(stack.size()+(i)))
 Script is a stack machine (like Forth) that evaluates a predicate returning a bool indicating valid or not. More...
 
#define altstacktop(i)   (altstack.at(altstack.size()+(i)))
 

Typedefs

typedef std::vector< unsigned char > valtype
 

Functions

bool CastToBool (const valtype &vch)
 
static void popstack (std::vector< valtype > &stack)
 
static bool IsCompressedOrUncompressedPubKey (const valtype &vchPubKey)
 
static bool IsValidSignatureEncoding (const std::vector< unsigned char > &sig)
 A canonical signature exists of: <30> <total len>=""> <02> <len r>=""> <R> <02> <len s>=""> <S> <hashtype> 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). More...
 
static bool IsLowDERSignature (const valtype &vchSig, ScriptError *serror)
 
static bool IsDefinedHashtypeSignature (const valtype &vchSig)
 
bool CheckSignatureEncoding (const std::vector< unsigned char > &vchSig, unsigned int flags, ScriptError *serror)
 
static bool CheckPubKeyEncoding (const valtype &vchSig, unsigned int flags, ScriptError *serror)
 
static bool CheckMinimalPush (const valtype &data, opcodetype opcode)
 
bool EvalScript (std::vector< std::vector< unsigned char > > &stack, const CScript &script, unsigned int flags, const BaseSignatureChecker &checker, SigVersion sigversion, ScriptError *serror)
 
uint256 SignatureHash (const CScript &scriptCode, const CTransaction &txTo, unsigned int nIn, int nHashType, const CAmount &amount, SigVersion sigversion, const PrecomputedTransactionData *cache)
 
bool VerifyScript (const CScript &scriptSig, const CScript &scriptPubKey, unsigned int flags, const BaseSignatureChecker &checker, ScriptError *serror)
 

Macro Definition Documentation

◆ altstacktop

#define altstacktop (   i)    (altstack.at(altstack.size()+(i)))

Definition at line 55 of file interpreter.cpp.

Referenced by EvalScript().

◆ stacktop

#define stacktop (   i)    (stack.at(stack.size()+(i)))

Script is a stack machine (like Forth) that evaluates a predicate returning a bool indicating valid or not.

There are no loops.

Definition at line 54 of file interpreter.cpp.

Referenced by EvalScript().

Typedef Documentation

◆ valtype

typedef std::vector<unsigned char> valtype

Definition at line 15 of file interpreter.cpp.

Function Documentation

◆ CastToBool()

bool CastToBool ( const valtype vch)

Definition at line 35 of file interpreter.cpp.

Referenced by EvalScript(), and VerifyScript().

◆ CheckMinimalPush()

static bool CheckMinimalPush ( const valtype data,
opcodetype  opcode 
)
static

Definition at line 212 of file interpreter.cpp.

References OP_0, OP_1, OP_1NEGATE, OP_PUSHDATA1, and OP_PUSHDATA2.

Referenced by EvalScript().

◆ CheckPubKeyEncoding()

static bool CheckPubKeyEncoding ( const valtype vchSig,
unsigned int  flags,
ScriptError serror 
)
static

◆ CheckSignatureEncoding()

bool CheckSignatureEncoding ( const std::vector< unsigned char > &  vchSig,
unsigned int  flags,
ScriptError serror 
)

◆ EvalScript()

bool EvalScript ( std::vector< std::vector< unsigned char > > &  stack,
const CScript script,
unsigned int  flags,
const BaseSignatureChecker checker,
SigVersion  sigversion,
ScriptError serror 
)

Definition at line 235 of file interpreter.cpp.

References altstacktop, prevector< N, T, Size, Diff >::begin(), CastToBool(), BaseSignatureChecker::CheckLockTime(), CheckMinimalPush(), CheckPubKeyEncoding(), BaseSignatureChecker::CheckSequence(), BaseSignatureChecker::CheckSig(), CheckSignatureEncoding(), count, prevector< N, T, Size, Diff >::end(), CScript::FindAndDelete(), flags, CScriptNum::getint(), CScript::GetOp(), CScriptNum::getvch(), MAX_OPS_PER_SCRIPT, MAX_PUBKEYS_PER_MULTISIG, MAX_SCRIPT_ELEMENT_SIZE, MAX_SCRIPT_SIZE, MAX_STACK_SIZE, OP_0NOTEQUAL, OP_1, OP_10, OP_11, OP_12, OP_13, OP_14, OP_15, OP_16, OP_1ADD, OP_1NEGATE, OP_1SUB, OP_2, OP_2DIV, OP_2DROP, OP_2DUP, OP_2MUL, OP_2OVER, OP_2ROT, OP_2SWAP, OP_3, OP_3DUP, OP_4, OP_5, OP_6, OP_7, OP_8, OP_9, OP_ABS, OP_ADD, OP_AND, OP_BOOLAND, OP_BOOLOR, OP_CAT, OP_CHECKLOCKTIMEVERIFY, OP_CHECKMULTISIG, OP_CHECKMULTISIGVERIFY, OP_CHECKSEQUENCEVERIFY, OP_CHECKSIG, OP_CHECKSIGVERIFY, OP_CODESEPARATOR, OP_DEPTH, OP_DIV, OP_DROP, OP_DUP, OP_ELSE, OP_ENDIF, OP_EQUAL, OP_EQUALVERIFY, OP_FROMALTSTACK, OP_GREATERTHAN, OP_GREATERTHANOREQUAL, OP_HASH160, OP_HASH256, OP_IF, OP_IFDUP, OP_INVERT, OP_LEFT, OP_LESSTHAN, OP_LESSTHANOREQUAL, OP_LSHIFT, OP_MAX, OP_MIN, OP_MOD, OP_MUL, OP_NEGATE, OP_NIP, OP_NOP, OP_NOP1, OP_NOP10, OP_NOP4, OP_NOP5, OP_NOP6, OP_NOP7, OP_NOP8, OP_NOP9, OP_NOT, OP_NOTIF, OP_NUMEQUAL, OP_NUMEQUALVERIFY, OP_NUMNOTEQUAL, OP_OR, OP_OVER, OP_PICK, OP_PUSHDATA4, OP_RETURN, OP_RIGHT, OP_RIPEMD160, OP_ROLL, OP_ROT, OP_RSHIFT, OP_SHA1, OP_SHA256, OP_SIZE, OP_SUB, OP_SUBSTR, OP_SWAP, OP_TOALTSTACK, OP_TUCK, OP_VERIFY, OP_WITHIN, OP_XOR, popstack(), SCRIPT_ERR_BAD_OPCODE, SCRIPT_ERR_CHECKMULTISIGVERIFY, SCRIPT_ERR_CHECKSIGVERIFY, SCRIPT_ERR_DISABLED_OPCODE, SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS, SCRIPT_ERR_EQUALVERIFY, SCRIPT_ERR_INVALID_ALTSTACK_OPERATION, SCRIPT_ERR_INVALID_STACK_OPERATION, SCRIPT_ERR_MINIMALDATA, SCRIPT_ERR_NEGATIVE_LOCKTIME, SCRIPT_ERR_NUMEQUALVERIFY, SCRIPT_ERR_OP_COUNT, SCRIPT_ERR_OP_RETURN, SCRIPT_ERR_PUBKEY_COUNT, SCRIPT_ERR_PUSH_SIZE, SCRIPT_ERR_SCRIPT_SIZE, SCRIPT_ERR_SIG_COUNT, SCRIPT_ERR_SIG_NULLDUMMY, SCRIPT_ERR_SIG_NULLFAIL, SCRIPT_ERR_STACK_SIZE, SCRIPT_ERR_UNBALANCED_CONDITIONAL, SCRIPT_ERR_UNKNOWN_ERROR, SCRIPT_ERR_UNSATISFIED_LOCKTIME, SCRIPT_ERR_VERIFY, SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY, SCRIPT_VERIFY_CHECKSEQUENCEVERIFY, SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS, SCRIPT_VERIFY_MINIMALDATA, SCRIPT_VERIFY_NULLDUMMY, SCRIPT_VERIFY_NULLFAIL, CTxIn::SEQUENCE_LOCKTIME_DISABLE_FLAG, SIGVERSION_BASE, prevector< N, T, Size, Diff >::size(), stacktop, CRIPEMD160::Write(), CSHA1::Write(), CSHA256::Write(), CHash256::Write(), and CHash160::Write().

Referenced by AreInputsStandard(), and VerifyScript().

◆ IsCompressedOrUncompressedPubKey()

static bool IsCompressedOrUncompressedPubKey ( const valtype vchPubKey)
static

Definition at line 63 of file interpreter.cpp.

Referenced by CheckPubKeyEncoding().

◆ IsDefinedHashtypeSignature()

static bool IsDefinedHashtypeSignature ( const valtype vchSig)
static

Definition at line 177 of file interpreter.cpp.

References SIGHASH_ANYONECANPAY, and SIGHASH_SINGLE.

Referenced by CheckSignatureEncoding().

◆ IsLowDERSignature()

static bool IsLowDERSignature ( const valtype vchSig,
ScriptError serror 
)
static

◆ IsValidSignatureEncoding()

static bool IsValidSignatureEncoding ( const std::vector< unsigned char > &  sig)
static

A canonical signature exists of: <30> <total len>=""> <02> <len r>=""> <R> <02> <len s>=""> <S> <hashtype> 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.

Definition at line 95 of file interpreter.cpp.

Referenced by CheckSignatureEncoding(), and IsLowDERSignature().

◆ popstack()

static void popstack ( std::vector< valtype > &  stack)
inlinestatic

Definition at line 56 of file interpreter.cpp.

Referenced by EvalScript(), and VerifyScript().

◆ SignatureHash()

uint256 SignatureHash ( const CScript scriptCode,
const CTransaction txTo,
unsigned int  nIn,
int  nHashType,
const CAmount amount,
SigVersion  sigversion,
const PrecomputedTransactionData cache 
)

◆ VerifyScript()

Released under the MIT license