Dash Core  0.12.2.1
P2P Digital Currency
interpreter.cpp File Reference
#include "interpreter.h"
#include "primitives/transaction.h"
#include "crypto/ripemd160.h"
#include "crypto/sha1.h"
#include "crypto/sha256.h"
#include "pubkey.h"
#include "script/script.h"
#include "uint256.h"

Go to the source code of this file.

Macros

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

Typedefs

typedef vector< unsigned char > valtype
 

Functions

bool CastToBool (const valtype &vch)
 
static void popstack (vector< valtype > &stack)
 
static bool IsCompressedOrUncompressedPubKey (const valtype &vchPubKey)
 
static bool IsValidSignatureEncoding (const std::vector< unsigned char > &sig)
 
static bool IsLowDERSignature (const valtype &vchSig, ScriptError *serror)
 
static bool IsDefinedHashtypeSignature (const valtype &vchSig)
 
bool CheckSignatureEncoding (const 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 (vector< vector< unsigned char > > &stack, const CScript &script, unsigned int flags, const BaseSignatureChecker &checker, ScriptError *serror)
 
uint256 SignatureHash (const CScript &scriptCode, const CTransaction &txTo, unsigned int nIn, int nHashType)
 
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 58 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 57 of file interpreter.cpp.

Referenced by EvalScript().

Typedef Documentation

◆ valtype

typedef vector<unsigned char> valtype

Definition at line 18 of file interpreter.cpp.

Function Documentation

◆ CastToBool()

bool CastToBool ( const valtype vch)

Definition at line 38 of file interpreter.cpp.

Referenced by EvalScript(), and VerifyScript().

◆ CheckMinimalPush()

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

Definition at line 209 of file interpreter.cpp.

Referenced by EvalScript().

◆ CheckPubKeyEncoding()

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

Definition at line 202 of file interpreter.cpp.

Referenced by EvalScript().

◆ CheckSignatureEncoding()

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

Definition at line 185 of file interpreter.cpp.

Referenced by EvalScript(), and ScriptToAsmStr().

◆ EvalScript()

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

Definition at line 232 of file interpreter.cpp.

Referenced by AreInputsStandard(), CombineSignatures(), and VerifyScript().

◆ IsCompressedOrUncompressedPubKey()

static bool IsCompressedOrUncompressedPubKey ( const valtype vchPubKey)
static

Definition at line 66 of file interpreter.cpp.

Referenced by CheckPubKeyEncoding().

◆ IsDefinedHashtypeSignature()

static bool IsDefinedHashtypeSignature ( const valtype vchSig)
static

Definition at line 174 of file interpreter.cpp.

Referenced by CheckSignatureEncoding().

◆ IsLowDERSignature()

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

Definition at line 163 of file interpreter.cpp.

Referenced by CheckSignatureEncoding().

◆ 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 98 of file interpreter.cpp.

Referenced by CheckSignatureEncoding(), and IsLowDERSignature().

◆ popstack()

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

Definition at line 59 of file interpreter.cpp.

Referenced by EvalScript(), and VerifyScript().

◆ SignatureHash()

uint256 SignatureHash ( const CScript scriptCode,
const CTransaction txTo,
unsigned int  nIn,
int  nHashType 
)

Definition at line 1109 of file interpreter.cpp.

Referenced by TransactionSignatureChecker::CheckSig().

◆ VerifyScript()

bool VerifyScript ( const CScript scriptSig,
const CScript scriptPubKey,
unsigned int  flags,
const BaseSignatureChecker checker,
ScriptError serror 
)