X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fscript.h;h=46f2d31bbc02f38df8d9a4e7cc9912eb7f2d2534;hb=882164196e5b1971313493f95a6d027f05e2ec92;hp=e3c6b15b6d6b31b91615d23c1ffcf77bc0051af1;hpb=21d9f36781604e4ca9fc35dc65265593423b73e9;p=novacoin.git diff --git a/src/script.h b/src/script.h index e3c6b15..46f2d31 100644 --- a/src/script.h +++ b/src/script.h @@ -1,12 +1,10 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2011 The Bitcoin developers +// Copyright (c) 2009-2012 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. #ifndef H_BITCOIN_SCRIPT #define H_BITCOIN_SCRIPT -#include - #include "base58.h" #include @@ -160,10 +158,8 @@ enum opcodetype OP_CHECKMULTISIG, OP_CHECKMULTISIGVERIFY, - // meta - OP_EVAL, // Was OP_NOP1 - // expansion + OP_NOP1, OP_NOP2, OP_NOP3, OP_NOP4, @@ -179,7 +175,6 @@ enum opcodetype // template matching params OP_SMALLINTEGER = 0xfa, OP_PUBKEYS = 0xfb, - OP_SCRIPTHASH = 0xfc, OP_PUBKEYHASH = 0xfd, OP_PUBKEY = 0xfe, @@ -221,7 +216,7 @@ inline std::string StackString(const std::vector >& v class CScript : public std::vector { protected: - CScript& push_int64(int64_t n) + CScript& push_int64(int64 n) { if (n == -1 || (n >= 1 && n <= 16)) { @@ -235,7 +230,7 @@ protected: return *this; } - CScript& push_uint64(uint64_t n) + CScript& push_uint64(uint64 n) { if (n >= 1 && n <= 16) { @@ -275,12 +270,12 @@ public: explicit CScript(short b) { operator<<(b); } explicit CScript(int b) { operator<<(b); } explicit CScript(long b) { operator<<(b); } - explicit CScript(int64_t b) { operator<<(b); } + explicit CScript(int64 b) { operator<<(b); } explicit CScript(unsigned char b) { operator<<(b); } explicit CScript(unsigned int b) { operator<<(b); } explicit CScript(unsigned short b) { operator<<(b); } explicit CScript(unsigned long b) { operator<<(b); } - explicit CScript(uint64_t b) { operator<<(b); } + explicit CScript(uint64 b) { operator<<(b); } explicit CScript(opcodetype b) { operator<<(b); } explicit CScript(const uint256& b) { operator<<(b); } @@ -292,12 +287,12 @@ public: CScript& operator<<(short b) { return push_int64(b); } CScript& operator<<(int b) { return push_int64(b); } CScript& operator<<(long b) { return push_int64(b); } - CScript& operator<<(int64_t b) { return push_int64(b); } + CScript& operator<<(int64 b) { return push_int64(b); } CScript& operator<<(unsigned char b) { return push_uint64(b); } CScript& operator<<(unsigned int b) { return push_uint64(b); } CScript& operator<<(unsigned short b) { return push_uint64(b); } CScript& operator<<(unsigned long b) { return push_uint64(b); } - CScript& operator<<(uint64_t b) { return push_uint64(b); } + CScript& operator<<(uint64 b) { return push_uint64(b); } CScript& operator<<(opcodetype opcode) { @@ -487,24 +482,18 @@ public: return nFound; } - // This method should be removed when a compatibility-breaking block chain split has passed. - // Compatibility method for old clients that count sigops differently: - int GetSigOpCount() const - { - int n = 0; - const_iterator pc = begin(); - while (pc < end()) - { - opcodetype opcode; - if (!GetOp(pc, opcode)) - break; - if (opcode == OP_CHECKSIG || opcode == OP_CHECKSIGVERIFY) - n++; - else if (opcode == OP_CHECKMULTISIG || opcode == OP_CHECKMULTISIGVERIFY) - n += 20; - } - return n; - } + // Pre-version-0.6, Bitcoin always counted CHECKMULTISIGs + // as 20 sigops. With pay-to-script-hash, that changed: + // CHECKMULTISIGs serialized in scriptSigs are + // counted more accurately, assuming they are of the form + // ... OP_N CHECKMULTISIG ... + int GetSigOpCount(bool fAccurate) const; + + // Accurately count sigOps, including sigOps in + // pay-to-script-hash transactions: + int GetSigOpCount(const CScript& scriptSig) const; + + bool IsPayToScriptHash() const; // Called by CTransaction::IsStandard bool IsPushOnly() const @@ -528,7 +517,7 @@ public: SetBitcoinAddress(CBitcoinAddress(vchPubKey)); } void SetMultisig(int nRequired, const std::vector& keys); - void SetEval(const CScript& subscript); + void SetPayToScriptHash(const CScript& subscript); void PrintHex() const @@ -569,14 +558,14 @@ public: -bool EvalScript(std::vector >& stack, const CScript& script, const CTransaction& txTo, unsigned int nIn, int nHashType, bool fStrictOpEval, int& nSigOpCountRet); - +bool EvalScript(std::vector >& stack, const CScript& script, const CTransaction& txTo, unsigned int nIn, int nHashType); bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, std::vector >& vSolutionsRet); +int ScriptSigArgsExpected(txnouttype t, const std::vector >& vSolutions); bool IsStandard(const CScript& scriptPubKey); bool IsMine(const CKeyStore& keystore, const CScript& scriptPubKey); -bool ExtractAddress(const CScript& scriptPubKey, const CKeyStore* pkeystore, CBitcoinAddress& addressRet); -bool ExtractAddresses(const CScript& scriptPubKey, const CKeyStore* pkeystore, txnouttype& typeRet, std::vector& addressRet, int& nRequiredRet); -bool SignSignature(const CKeyStore& keystore, const CTransaction& txFrom, CTransaction& txTo, unsigned int nIn, int nHashType=SIGHASH_ALL, CScript scriptPrereq=CScript()); -bool VerifySignature(const CTransaction& txFrom, const CTransaction& txTo, unsigned int nIn, int& nSigOpCountRet, int nHashType=0, bool fStrictOpEval=true); +bool ExtractAddress(const CScript& scriptPubKey, CBitcoinAddress& addressRet); +bool ExtractAddresses(const CScript& scriptPubKey, txnouttype& typeRet, std::vector& addressRet, int& nRequiredRet); +bool SignSignature(const CKeyStore& keystore, const CTransaction& txFrom, CTransaction& txTo, unsigned int nIn, int nHashType=SIGHASH_ALL); +bool VerifySignature(const CTransaction& txFrom, const CTransaction& txTo, unsigned int nIn, bool fValidatePayToScriptHash, int nHashType); #endif