Skip to content

script: add OP_TRUE and OP_FALSE aliases to OPCODES_BY_NAME#317

Open
Bortlesboat wants to merge 2 commits into
petertodd:masterfrom
Bortlesboat:add-op-true-false-to-opcodes-by-name
Open

script: add OP_TRUE and OP_FALSE aliases to OPCODES_BY_NAME#317
Bortlesboat wants to merge 2 commits into
petertodd:masterfrom
Bortlesboat:add-op-true-false-to-opcodes-by-name

Conversation

@Bortlesboat

@Bortlesboat Bortlesboat commented Apr 6, 2026

Copy link
Copy Markdown

Summary

OP_TRUE and OP_FALSE already exist as aliases for OP_1 and OP_0, but they are absent from OPCODES_BY_NAME. Code that parses textual script tokens therefore cannot resolve these standard boolean names.

Add both aliases to the lookup table, as requested by a repository collaborator in issue #225, and cover their exact singleton mappings.

Fixes #225.

Verification

  • python -m unittest bitcoin.tests.test_script -v — 19 passed.
  • Touched files compile successfully and the diff whitespace check passes.

These aliases are already defined as module-level constants (OP_FALSE = OP_0,
OP_TRUE = OP_1) but were missing from the OPCODES_BY_NAME lookup dict,
making it impossible to parse script strings containing these common aliases.

Fixes petertodd#225
@Bortlesboat

Copy link
Copy Markdown
Author

Added focused coverage asserting the name table maps OP_FALSE to the OP_0 singleton and OP_TRUE to OP_1. All 19 script tests pass.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OPCODES_BY_NAME missing OP_TRUE and OP_FALSE

1 participant