Skip to content

Commit

Permalink
cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
conradoplg committed May 24, 2024
1 parent 5443ed2 commit ae20f14
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
8 changes: 4 additions & 4 deletions depend/zcash/src/script/interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1549,9 +1549,9 @@ bool VerifyScript(
// serror is set
return false;
if (stack.empty())
return set_error(serror, (ScriptError_t)(SCRIPT_ERR_EVAL_FALSE + 101));
return set_error(serror, SCRIPT_ERR_EVAL_FALSE);
if (CastToBool(stack.back()) == false)
return set_error(serror, (ScriptError_t)(SCRIPT_ERR_EVAL_FALSE + 102));
return set_error(serror, SCRIPT_ERR_EVAL_FALSE);

// Additional validation for spend-to-script-hash transactions:
if ((flags & SCRIPT_VERIFY_P2SH) && scriptPubKey.IsPayToScriptHash())
Expand All @@ -1576,9 +1576,9 @@ bool VerifyScript(
// serror is set
return false;
if (stack.empty())
return set_error(serror, (ScriptError_t)(SCRIPT_ERR_EVAL_FALSE + 103));
return set_error(serror, SCRIPT_ERR_EVAL_FALSE);
if (!CastToBool(stack.back()))
return set_error(serror, (ScriptError_t)(SCRIPT_ERR_EVAL_FALSE + 104));
return set_error(serror, SCRIPT_ERR_EVAL_FALSE);
}

// The CLEANSTACK check is only performed after potential P2SH evaluation,
Expand Down
14 changes: 5 additions & 9 deletions depend/zcash/src/script/zcash_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ unsigned int zcash_script_legacy_sigop_count_script(
}

int zcash_script_verify_callback(
const void* tx,
void (*sighash)(unsigned char* sighash, const void* tx, const unsigned char* scriptCode, unsigned int scriptCodeLen, int hashType),
const void* ctx,
void (*sighash)(unsigned char* sighash, const void* ctx, const unsigned char* scriptCode, unsigned int scriptCodeLen, int hashType),
int64_t nLockTime,
uint8_t isFinal,
const unsigned char* scriptPubKey,
Expand All @@ -316,18 +316,14 @@ int zcash_script_verify_callback(
set_error(err, zcash_script_ERR_OK);
CScriptNum nLockTimeNum = CScriptNum(nLockTime);
ScriptError script_err = SCRIPT_ERR_OK;
bool r = VerifyScript(
return VerifyScript(
CScript(scriptSig, scriptSig + scriptSigLen),
CScript(scriptPubKey, scriptPubKey + scriptPubKeyLen),
flags,
CallbackTransactionSignatureChecker(tx, sighash, nLockTimeNum, isFinal != 0, nIn, amount),
CallbackTransactionSignatureChecker(ctx, sighash, nLockTimeNum, isFinal != 0, nIn, amount),
consensusBranchId,
&script_err);
if (!r) {
return set_error(err, (zcash_script_error_t)((zcash_script_error_t)1000 + (zcash_script_error_t)script_err));
}
return r;
} catch (const std::exception&) {
return set_error(err, zcash_script_ERR_VERIFY_SCRIPT); // Error deserializing
return set_error(err, zcash_script_ERR_VERIFY_SCRIPT);
}
}
4 changes: 2 additions & 2 deletions depend/zcash/src/script/zcash_script.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ EXPORT_SYMBOL unsigned int zcash_script_legacy_sigop_count_script(
unsigned int scriptLen);

EXPORT_SYMBOL int zcash_script_verify_callback(
const void* tx,
void (*sighash)(unsigned char* sighash, const void* tx, const unsigned char* scriptCode, unsigned int scriptCodeLen, int hashType),
const void* ctx,
void (*sighash)(unsigned char* sighash, const void* ctx, const unsigned char* scriptCode, unsigned int scriptCodeLen, int hashType),
int64_t nLockTime,
uint8_t isFinal,
const unsigned char* scriptPubKey,
Expand Down

0 comments on commit ae20f14

Please sign in to comment.