mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
Separate script/interpreter
This commit is contained in:
parent
cbd22a50c4
commit
da03e6ed7c
@ -98,6 +98,7 @@ BITCOIN_CORE_H = \
|
|||||||
rpcclient.h \
|
rpcclient.h \
|
||||||
rpcprotocol.h \
|
rpcprotocol.h \
|
||||||
rpcserver.h \
|
rpcserver.h \
|
||||||
|
script/interpreter.h \
|
||||||
script/script.h \
|
script/script.h \
|
||||||
scriptutils.h \
|
scriptutils.h \
|
||||||
serialize.h \
|
serialize.h \
|
||||||
@ -207,6 +208,7 @@ libbitcoin_common_a_SOURCES = \
|
|||||||
keystore.cpp \
|
keystore.cpp \
|
||||||
netbase.cpp \
|
netbase.cpp \
|
||||||
protocol.cpp \
|
protocol.cpp \
|
||||||
|
script/interpreter.cpp \
|
||||||
script/script.cpp \
|
script/script.cpp \
|
||||||
scriptutils.cpp \
|
scriptutils.cpp \
|
||||||
$(BITCOIN_CORE_H)
|
$(BITCOIN_CORE_H)
|
||||||
|
1048
src/script/interpreter.cpp
Normal file
1048
src/script/interpreter.cpp
Normal file
File diff suppressed because it is too large
Load Diff
45
src/script/interpreter.h
Normal file
45
src/script/interpreter.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||||
|
// Copyright (c) 2009-2013 The Bitcoin developers
|
||||||
|
// Distributed under the MIT/X11 software license, see the accompanying
|
||||||
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
#ifndef H_BITCOIN_SCRIPT_INTERPRETER
|
||||||
|
#define H_BITCOIN_SCRIPT_INTERPRETER
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class uint256;
|
||||||
|
class CScript;
|
||||||
|
class CTransaction;
|
||||||
|
|
||||||
|
/** Signature hash types/flags */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
SIGHASH_ALL = 1,
|
||||||
|
SIGHASH_NONE = 2,
|
||||||
|
SIGHASH_SINGLE = 3,
|
||||||
|
SIGHASH_ANYONECANPAY = 0x80,
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Script verification flags */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
SCRIPT_VERIFY_NONE = 0,
|
||||||
|
SCRIPT_VERIFY_P2SH = (1U << 0), // evaluate P2SH (BIP16) subscripts
|
||||||
|
SCRIPT_VERIFY_STRICTENC = (1U << 1), // enforce strict conformance to DER and SEC2 for signatures and pubkeys
|
||||||
|
SCRIPT_VERIFY_LOW_S = (1U << 2), // enforce low S values (<n/2) in signatures (depends on STRICTENC)
|
||||||
|
SCRIPT_VERIFY_NOCACHE = (1U << 3), // do not store results in signature cache (but do query it)
|
||||||
|
SCRIPT_VERIFY_NULLDUMMY = (1U << 4), // verify dummy stack item consumed by CHECKMULTISIG is of zero-length
|
||||||
|
};
|
||||||
|
|
||||||
|
bool IsCanonicalPubKey(const std::vector<unsigned char> &vchPubKey, unsigned int flags);
|
||||||
|
bool IsCanonicalSignature(const std::vector<unsigned char> &vchSig, unsigned int flags);
|
||||||
|
|
||||||
|
uint256 SignatureHash(const CScript &scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType);
|
||||||
|
bool CheckSig(std::vector<unsigned char> vchSig, const std::vector<unsigned char> &vchPubKey, const CScript &scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType, int flags);
|
||||||
|
bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript& script, const CTransaction& txTo, unsigned int nIn, unsigned int flags, int nHashType);
|
||||||
|
bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn, unsigned int flags, int nHashType);
|
||||||
|
|
||||||
|
#endif
|
1058
src/scriptutils.cpp
1058
src/scriptutils.cpp
File diff suppressed because it is too large
Load Diff
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "key.h"
|
#include "key.h"
|
||||||
#include "script/script.h"
|
#include "script/script.h"
|
||||||
|
#include "script/interpreter.h"
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@ -20,26 +21,6 @@ struct CMutableTransaction;
|
|||||||
|
|
||||||
static const unsigned int MAX_OP_RETURN_RELAY = 40; // bytes
|
static const unsigned int MAX_OP_RETURN_RELAY = 40; // bytes
|
||||||
|
|
||||||
/** Signature hash types/flags */
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
SIGHASH_ALL = 1,
|
|
||||||
SIGHASH_NONE = 2,
|
|
||||||
SIGHASH_SINGLE = 3,
|
|
||||||
SIGHASH_ANYONECANPAY = 0x80,
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Script verification flags */
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
SCRIPT_VERIFY_NONE = 0,
|
|
||||||
SCRIPT_VERIFY_P2SH = (1U << 0), // evaluate P2SH (BIP16) subscripts
|
|
||||||
SCRIPT_VERIFY_STRICTENC = (1U << 1), // enforce strict conformance to DER and SEC2 for signatures and pubkeys
|
|
||||||
SCRIPT_VERIFY_LOW_S = (1U << 2), // enforce low S values (<n/2) in signatures (depends on STRICTENC)
|
|
||||||
SCRIPT_VERIFY_NOCACHE = (1U << 3), // do not store results in signature cache (but do query it)
|
|
||||||
SCRIPT_VERIFY_NULLDUMMY = (1U << 4), // verify dummy stack item consumed by CHECKMULTISIG is of zero-length
|
|
||||||
};
|
|
||||||
|
|
||||||
/** IsMine() return codes */
|
/** IsMine() return codes */
|
||||||
enum isminetype
|
enum isminetype
|
||||||
{
|
{
|
||||||
@ -156,11 +137,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
bool IsCanonicalPubKey(const std::vector<unsigned char> &vchPubKey, unsigned int flags);
|
|
||||||
bool IsCanonicalSignature(const std::vector<unsigned char> &vchSig, unsigned int flags);
|
|
||||||
|
|
||||||
bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript& script, const CTransaction& txTo, unsigned int nIn, unsigned int flags, int nHashType);
|
|
||||||
uint256 SignatureHash(const CScript &scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType);
|
|
||||||
bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<std::vector<unsigned char> >& vSolutionsRet);
|
bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<std::vector<unsigned char> >& vSolutionsRet);
|
||||||
int ScriptSigArgsExpected(txnouttype t, const std::vector<std::vector<unsigned char> >& vSolutions);
|
int ScriptSigArgsExpected(txnouttype t, const std::vector<std::vector<unsigned char> >& vSolutions);
|
||||||
bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType);
|
bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType);
|
||||||
@ -171,7 +147,6 @@ bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet)
|
|||||||
bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<CTxDestination>& addressRet, int& nRequiredRet);
|
bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<CTxDestination>& addressRet, int& nRequiredRet);
|
||||||
bool SignSignature(const CKeyStore& keystore, const CScript& fromPubKey, CMutableTransaction& txTo, unsigned int nIn, int nHashType=SIGHASH_ALL);
|
bool SignSignature(const CKeyStore& keystore, const CScript& fromPubKey, CMutableTransaction& txTo, unsigned int nIn, int nHashType=SIGHASH_ALL);
|
||||||
bool SignSignature(const CKeyStore& keystore, const CTransaction& txFrom, CMutableTransaction& txTo, unsigned int nIn, int nHashType=SIGHASH_ALL);
|
bool SignSignature(const CKeyStore& keystore, const CTransaction& txFrom, CMutableTransaction& txTo, unsigned int nIn, int nHashType=SIGHASH_ALL);
|
||||||
bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn, unsigned int flags, int nHashType);
|
|
||||||
|
|
||||||
// Given two sets of signatures for scriptPubKey, possibly with OP_0 placeholders,
|
// Given two sets of signatures for scriptPubKey, possibly with OP_0 placeholders,
|
||||||
// combine them intelligently and return the result.
|
// combine them intelligently and return the result.
|
||||||
|
@ -8,9 +8,11 @@
|
|||||||
|
|
||||||
#include "data/sig_noncanonical.json.h"
|
#include "data/sig_noncanonical.json.h"
|
||||||
#include "data/sig_canonical.json.h"
|
#include "data/sig_canonical.json.h"
|
||||||
|
#include "key.h"
|
||||||
#include "random.h"
|
#include "random.h"
|
||||||
#include "scriptutils.h"
|
#include "script/interpreter.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "utilstrencodings.h"
|
||||||
|
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "keystore.h"
|
#include "keystore.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "script/script.h"
|
#include "script/script.h"
|
||||||
|
#include "script/interpreter.h"
|
||||||
#include "scriptutils.h"
|
#include "scriptutils.h"
|
||||||
#include "uint256.h"
|
#include "uint256.h"
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include "random.h"
|
#include "random.h"
|
||||||
#include "serialize.h"
|
#include "serialize.h"
|
||||||
#include "script/script.h"
|
#include "script/script.h"
|
||||||
#include "scriptutils.h"
|
#include "script/interpreter.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user