script: add SCRIPT_ERR_SCRIPTNUM error
What changed, and why it matters
This commit adds a new, more descriptive error code for problems with numbers inside Bitcoin's script language. Previously, these problems were reported as a generic 'unknown error.' The change only defines the new error label and its human-readable message; it does not yet change any code that actually raises the error. By itself, this is a small cleanup that does not fix or introduce a security vulnerability.
No immediate action required. Treat as a non-security refactor. When reviewing follow-up commits that switch CScriptNum failures to SCRIPT_ERR_SCRIPTNUM, verify that consensus-critical behavior (e.g., which scripts fail and whether they fail identically) remains unchanged.
Security signals we found
New error code for CScriptNum overflow/non-minimal encoding
Commit message frames change as replacing 'unknown error' for script-number failures
No interpreter logic changed in this commit
Evidence from the diff
The patch introduces SCRIPT_ERR_SCRIPTNUM in src/script/script_error.h and adds a corresponding descriptive string in ScriptErrorString() in src/script/script_error.cpp. The commit message states it will be used for CScriptNum-related failures such as overflow or non-minimal encoding, which currently return SCRIPT_ERR_UNKNOWN_ERROR. The diff does not modify any interpreter logic to emit this new error, so it is a preparatory refactor with no immediate behavioral change.
Changed components
src/script/script_error.hsrc/script/script_error.cppInspect captured patch +3 / −0
diff --git a/src/script/script_error.cpp b/src/script/script_error.cpp
index a6707638..b0e7a6e1 100644
--- a/src/script/script_error.cpp
+++ b/src/script/script_error.cpp
@@ -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;
diff --git a/src/script/script_error.h b/src/script/script_error.h
index 58ac7db5..23de3b17 100644
--- a/src/script/script_error.h
+++ b/src/script/script_error.h
@@ -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,
Why this scored 18/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.