diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp index a87a11d6..1348a0f3 100644 --- a/src/script/interpreter.cpp +++ b/src/script/interpreter.cpp @@ -205,7 +205,7 @@ bool CheckBlockIndex(int &txBlockIndex, int blockIndex) if (blockDelta > 0) return false; // blockDelta must be greater than 100 but lesser than 262144 - if ((blockDelta > -101) || (blockDelta < -262144)) + if ((blockDelta > -101) || (blockDelta < -262144) && (blockDelta != 0)) return false; // check if txBlockIndex refers to an actual block if (txBlockIndex > blockIndex) @@ -417,10 +417,23 @@ bool EvalScript(vector >& stack, const CScript& script, un break; } -#ifdef BITCOIN_TX // zen-tx can't process OP_CHECKBLOCKATHEIGHT because it requires an active chain +#ifndef BITCOIN_ZCASHCONSENSUS_H // zen-tx can't process OP_CHECKBLOCKATHEIGHT because it requires an active chain case OP_CHECKBLOCKATHEIGHT: { - return set_error(serror, SCRIPT_ERR_CHECKBLOCKATHEIGHT_UNVERIFIED); + // we need two objects on the stack + if (stack.size() < 2) + return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); + + valtype vchBlockHash(stacktop(-2)); + valtype vchBlockIndex(stacktop(-1)); + + if ((vchBlockIndex.size() > sizeof(int)) || (vchBlockHash.size() > 32)) + return set_error(serror, SCRIPT_ERR_CHECKBLOCKATHEIGHT); + + // since we can't access chain data then we treat OP_CHECKBLOCKATHEIGHT as a NOP + popstack(stack); + popstack(stack); + stack.push_back(vchTrue); } break; #else diff --git a/src/script/standard.cpp b/src/script/standard.cpp index f9e4649e..24544b0f 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -12,7 +12,9 @@ #include +#if defined(BITCOIN_ZCASHCONSENSUS_H) #include "main.h" +#endif using namespace std; @@ -307,7 +309,7 @@ public: return false; } -#ifdef BITCOIN_TX // zen-tx does not have access to chain state so no replay protection is possible +#ifndef BITCOIN_ZCASHCONSENSUS_H // zen-tx does not have access to chain state so no replay protection is possible bool operator()(const CKeyID &keyID) const { script->clear(); *script << OP_DUP << OP_HASH160 << ToByteVector(keyID) << OP_EQUALVERIFY << OP_CHECKSIG;