Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

script: fix witness_version() to decode small int opcodes #314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
EricGrill wants to merge 1 commit into petertodd:master
base: master
Choose a base branch
Loading
from EricGrill:fix/witness-version-decode

Conversation

@EricGrill
Copy link

@EricGrill EricGrill commented Jan 14, 2026

Summary

Fixes CScript.witness_version() to properly return witness version integers.

Problem

The method was returning the raw opcode value instead of the decoded integer:

  • Witness v0 (OP_0 = 0x00): returned 0 ✓ (worked by coincidence)
  • Witness v1 (OP_1 = 0x51): returned 81 ✗ (should return 1)

Solution

Call decode_op_n() on the opcode to convert small integer opcodes to their values.

Closes #298

🤖 Generated with Claude Code

The witness_version() method was returning the raw opcode value instead
of the decoded integer. For witness version 0 (OP_0 = 0x00) this worked
by coincidence, but for witness version 1 (OP_1 = 0x51) it incorrectly
returned 0x51 instead of 1.
Fix by calling decode_op_n() to properly convert the small int opcode
to its integer value.
Closes petertodd#298
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

CScript.witness_version() should call CSriptOp.decode_op_n() on the value before returning

1 participant

AltStyle によって変換されたページ (->オリジナル) /