10BC0 script: return proper error for `CScriptNum` errors by brunoerg · Pull Request #34381 · bitcoin/bitcoin · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@brunoerg
Copy link
Contributor

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.

@DrahtBot
Copy link
Contributor
DrahtBot commented Jan 22, 2026

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/34381.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK w0xlt, darosior
Stale ACK billymcbip

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #29491 ([EXPERIMENTAL] Schnorr batch verification for blocks by fjahr)
  • #29247 (CAT in Tapscript (BIP-347) by arminsabouri)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@billymcbip
Copy link
Contributor

Neat. Unit tests and functional tests pass on my end. tACK 6b307a2

You can remove {SCRIPT_ERR_UNKNOWN_ERROR, "UNKNOWN_ERROR"} from static ScriptErrorDesc script_errors[].

@brunoerg brunoerg marked this pull request as draft January 22, 2026 13:58
@brunoerg brunoerg marked this pull request as ready for review January 22, 2026 14:01
@brunoerg
Copy link
Contributor Author

You can remove {SCRIPT_ERR_UNKNOWN_ERROR, "UNKNOWN_ERROR"} from static ScriptErrorDesc script_errors[].

Just removed it since it's now unused.

@billymcbip
Copy link
Contributor

tACK 3e7c250

It will be used for errors related to CScriptNum (e.g. overflow or encoding errors).
Currently, we simply return unknown error for these errors.
@brunoerg
Copy link
Contributor Author

Force-pushed addressing #34381 (comment)

Copy link
Contributor
@w0xlt w0xlt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 6f7b432

Copy link
Member
@darosior darosior left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 6f7b432


static ScriptErrorDesc script_errors[]={
{SCRIPT_ERR_OK, "OK"},
{SCRIPT_ERR_UNKNOWN_ERROR, "UNKNOWN_ERROR"},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, is this now unreachable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so. I don't see a explicit scenario for this unknown error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

0