mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-06 13:09:43 +01:00
Merge bitcoin/bitcoin#34381: script: return proper error for CScriptNum errors
6f7b4323cbtest: remove UNKNOWN_ERROR from script_tests (Bruno Garcia)bd31a92d67script: use SCRIPT_ERR_SCRIPTNUM for CScriptNum errors (Bruno Garcia)0ca4dcd786script: add SCRIPT_ERR_SCRIPTNUM error (Bruno Garcia) Pull request description: When evaluating a script, the current code is bad for analyzing some errors because it returns `SCRIPT_ERR_UNKNOWN_ERROR` for errors that are clearly known. `CScriptNum` has two well defined errors: number overflow and non-minimally encoded number. However, for both errors we return as unknown. This PR changes it by adding a new ScriptError that is used for any `CScriptNum` error. ACKs for top commit: achow101: ACK6f7b4323cbw0xlt: ACK6f7b4323cbdarosior: ACK6f7b4323cbTree-SHA512: e656d9992251fbc95d33966fa18ce64bf714179d51ba6a7f429e5a55bc58e7fc08827e4ab71ace0dd385dac7e1feaea621b49503387793a30eae7a7e44aa6b0f
This commit is contained in:
@@ -1223,6 +1223,10 @@ bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript&
|
||||
return set_error(serror, SCRIPT_ERR_STACK_SIZE);
|
||||
}
|
||||
}
|
||||
catch (const scriptnum_error&)
|
||||
{
|
||||
return set_error(serror, SCRIPT_ERR_SCRIPTNUM);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return set_error(serror, SCRIPT_ERR_UNKNOWN_ERROR);
|
||||
|
||||
@@ -117,6 +117,8 @@ std::string ScriptErrorString(const ScriptError serror)
|
||||
return "Using OP_CODESEPARATOR in non-witness script";
|
||||
case SCRIPT_ERR_SIG_FINDANDDELETE:
|
||||
return "Signature is found in scriptCode";
|
||||
case SCRIPT_ERR_SCRIPTNUM:
|
||||
return "Script number overflowed or is non-minimally encoded";
|
||||
case SCRIPT_ERR_UNKNOWN_ERROR:
|
||||
case SCRIPT_ERR_ERROR_COUNT:
|
||||
default: break;
|
||||
|
||||
@@ -14,6 +14,7 @@ typedef enum ScriptError_t
|
||||
SCRIPT_ERR_UNKNOWN_ERROR,
|
||||
SCRIPT_ERR_EVAL_FALSE,
|
||||
SCRIPT_ERR_OP_RETURN,
|
||||
SCRIPT_ERR_SCRIPTNUM,
|
||||
|
||||
/* Max sizes */
|
||||
SCRIPT_ERR_SCRIPT_SIZE,
|
||||
|
||||
Reference in New Issue
Block a user