diff --git a/src/script/interpreter.h b/src/script/interpreter.h --- a/src/script/interpreter.h +++ b/src/script/interpreter.h @@ -29,6 +29,10 @@ class BaseSignatureChecker { public: + virtual bool VerifySignature(const std::vector &vchSig, + const CPubKey &vchPubKey, + const uint256 &sighash) const; + virtual bool CheckSig(const std::vector &scriptSig, const std::vector &vchPubKey, const CScript &scriptCode, uint32_t flags) const { @@ -53,11 +57,6 @@ const Amount amount; const PrecomputedTransactionData *txdata; -protected: - virtual bool VerifySignature(const std::vector &vchSig, - const CPubKey &vchPubKey, - const uint256 &sighash) const; - public: TransactionSignatureChecker(const CTransaction *txToIn, unsigned int nInIn, const Amount amountIn) @@ -66,11 +65,14 @@ const Amount amountIn, const PrecomputedTransactionData &txdataIn) : txTo(txToIn), nIn(nInIn), amount(amountIn), txdata(&txdataIn) {} + + // The overriden functions are now final. bool CheckSig(const std::vector &scriptSig, const std::vector &vchPubKey, - const CScript &scriptCode, uint32_t flags) const override; - bool CheckLockTime(const CScriptNum &nLockTime) const override; - bool CheckSequence(const CScriptNum &nSequence) const override; + const CScript &scriptCode, + uint32_t flags) const final override; + bool CheckLockTime(const CScriptNum &nLockTime) const final override; + bool CheckSequence(const CScriptNum &nSequence) const final override; }; class MutableTransactionSignatureChecker : public TransactionSignatureChecker { diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp --- a/src/script/interpreter.cpp +++ b/src/script/interpreter.cpp @@ -941,9 +941,8 @@ CSHA256() .Write(vchMessage.data(), vchMessage.size()) .Finalize(vchHash.data()); - uint256 message(vchHash); - CPubKey pubkey(vchPubKey); - fSuccess = pubkey.Verify(message, vchSig); + fSuccess = checker.VerifySignature( + vchSig, CPubKey(vchPubKey), uint256(vchHash)); } if (!fSuccess && (flags & SCRIPT_VERIFY_NULLFAIL) && @@ -1463,9 +1462,9 @@ return ss.GetHash(); } -bool TransactionSignatureChecker::VerifySignature( - const std::vector &vchSig, const CPubKey &pubkey, - const uint256 &sighash) const { +bool BaseSignatureChecker::VerifySignature(const std::vector &vchSig, + const CPubKey &pubkey, + const uint256 &sighash) const { return pubkey.Verify(sighash, vchSig); }