mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 06:43:45 +01:00
Add SCRIPT_VERIFY_SIGPUSHONLY (BIP62 rule 2)
This commit is contained in:
@@ -980,6 +980,10 @@ bool SignatureChecker::CheckSig(const vector<unsigned char>& vchSigIn, const vec
|
||||
|
||||
bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, unsigned int flags, const BaseSignatureChecker& checker)
|
||||
{
|
||||
if ((flags & SCRIPT_VERIFY_SIGPUSHONLY) != 0 && !scriptSig.IsPushOnly()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
vector<vector<unsigned char> > stack, stackCopy;
|
||||
if (!EvalScript(stack, scriptSig, flags, checker))
|
||||
return false;
|
||||
|
||||
@@ -46,6 +46,9 @@ enum
|
||||
|
||||
// verify dummy stack item consumed by CHECKMULTISIG is of zero-length (softfork safe, BIP62 rule 7).
|
||||
SCRIPT_VERIFY_NULLDUMMY = (1U << 4),
|
||||
|
||||
// Using a non-push operator in the scriptSig causes script failure (softfork safe, BIP62 rule 2).
|
||||
SCRIPT_VERIFY_SIGPUSHONLY = (1U << 5),
|
||||
};
|
||||
|
||||
uint256 SignatureHash(const CScript &scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType);
|
||||
|
||||
@@ -230,7 +230,7 @@ bool CScript::IsPushOnly() const
|
||||
return false;
|
||||
// Note that IsPushOnly() *does* consider OP_RESERVED to be a
|
||||
// push-type opcode, however execution of OP_RESERVED fails, so
|
||||
// it's not relevant to P2SH as the scriptSig would fail prior to
|
||||
// it's not relevant to P2SH/BIP62 as the scriptSig would fail prior to
|
||||
// the P2SH special validation code being executed.
|
||||
if (opcode > OP_16)
|
||||
return false;
|
||||
|
||||
@@ -551,7 +551,7 @@ public:
|
||||
|
||||
bool IsPayToScriptHash() const;
|
||||
|
||||
// Called by IsStandardTx and P2SH VerifyScript (which makes it consensus-critical).
|
||||
// Called by IsStandardTx and P2SH/BIP62 VerifyScript (which makes it consensus-critical).
|
||||
bool IsPushOnly() const;
|
||||
|
||||
// Called by IsStandardTx.
|
||||
|
||||
Reference in New Issue
Block a user