Changeset View
Changeset View
Standalone View
Standalone View
src/script/interpreter.h
Show All 23 Lines | |||||
uint256 SignatureHash(const CScript &scriptCode, const CTransaction &txTo, | uint256 SignatureHash(const CScript &scriptCode, const CTransaction &txTo, | ||||
unsigned int nIn, SigHashType sigHashType, | unsigned int nIn, SigHashType sigHashType, | ||||
const Amount amount, | const Amount amount, | ||||
const PrecomputedTransactionData *cache = nullptr, | const PrecomputedTransactionData *cache = nullptr, | ||||
uint32_t flags = SCRIPT_ENABLE_SIGHASH_FORKID); | uint32_t flags = SCRIPT_ENABLE_SIGHASH_FORKID); | ||||
class BaseSignatureChecker { | class BaseSignatureChecker { | ||||
public: | public: | ||||
virtual bool VerifySignature(const std::vector<uint8_t> &vchSig, | |||||
const CPubKey &vchPubKey, | |||||
const uint256 &sighash) const; | |||||
virtual bool CheckSig(const std::vector<uint8_t> &scriptSig, | virtual bool CheckSig(const std::vector<uint8_t> &scriptSig, | ||||
const std::vector<uint8_t> &vchPubKey, | const std::vector<uint8_t> &vchPubKey, | ||||
const CScript &scriptCode, uint32_t flags) const { | const CScript &scriptCode, uint32_t flags) const { | ||||
return false; | return false; | ||||
} | } | ||||
virtual bool CheckLockTime(const CScriptNum &nLockTime) const { | virtual bool CheckLockTime(const CScriptNum &nLockTime) const { | ||||
return false; | return false; | ||||
} | } | ||||
virtual bool CheckSequence(const CScriptNum &nSequence) const { | virtual bool CheckSequence(const CScriptNum &nSequence) const { | ||||
return false; | return false; | ||||
} | } | ||||
virtual ~BaseSignatureChecker() {} | virtual ~BaseSignatureChecker() {} | ||||
}; | }; | ||||
class TransactionSignatureChecker : public BaseSignatureChecker { | class TransactionSignatureChecker : public BaseSignatureChecker { | ||||
private: | private: | ||||
const CTransaction *txTo; | const CTransaction *txTo; | ||||
unsigned int nIn; | unsigned int nIn; | ||||
const Amount amount; | const Amount amount; | ||||
const PrecomputedTransactionData *txdata; | const PrecomputedTransactionData *txdata; | ||||
protected: | |||||
virtual bool VerifySignature(const std::vector<uint8_t> &vchSig, | |||||
const CPubKey &vchPubKey, | |||||
const uint256 &sighash) const; | |||||
public: | public: | ||||
TransactionSignatureChecker(const CTransaction *txToIn, unsigned int nInIn, | TransactionSignatureChecker(const CTransaction *txToIn, unsigned int nInIn, | ||||
const Amount amountIn) | const Amount amountIn) | ||||
: txTo(txToIn), nIn(nInIn), amount(amountIn), txdata(nullptr) {} | : txTo(txToIn), nIn(nInIn), amount(amountIn), txdata(nullptr) {} | ||||
TransactionSignatureChecker(const CTransaction *txToIn, unsigned int nInIn, | TransactionSignatureChecker(const CTransaction *txToIn, unsigned int nInIn, | ||||
const Amount amountIn, | const Amount amountIn, | ||||
const PrecomputedTransactionData &txdataIn) | const PrecomputedTransactionData &txdataIn) | ||||
: txTo(txToIn), nIn(nInIn), amount(amountIn), txdata(&txdataIn) {} | : txTo(txToIn), nIn(nInIn), amount(amountIn), txdata(&txdataIn) {} | ||||
// The overriden functions are now final. | |||||
bool CheckSig(const std::vector<uint8_t> &scriptSig, | bool CheckSig(const std::vector<uint8_t> &scriptSig, | ||||
const std::vector<uint8_t> &vchPubKey, | const std::vector<uint8_t> &vchPubKey, | ||||
const CScript &scriptCode, uint32_t flags) const override; | const CScript &scriptCode, | ||||
bool CheckLockTime(const CScriptNum &nLockTime) const override; | uint32_t flags) const final override; | ||||
bool CheckSequence(const CScriptNum &nSequence) const override; | bool CheckLockTime(const CScriptNum &nLockTime) const final override; | ||||
bool CheckSequence(const CScriptNum &nSequence) const final override; | |||||
}; | }; | ||||
class MutableTransactionSignatureChecker : public TransactionSignatureChecker { | class MutableTransactionSignatureChecker : public TransactionSignatureChecker { | ||||
private: | private: | ||||
const CTransaction txTo; | const CTransaction txTo; | ||||
public: | public: | ||||
MutableTransactionSignatureChecker(const CMutableTransaction *txToIn, | MutableTransactionSignatureChecker(const CMutableTransaction *txToIn, | ||||
Show All 12 Lines |