Skip to content

BIP-119: Fix missing self. prefix on stack reference in pseudocode#2113

Open
schjonhaug wants to merge 1 commit intobitcoin:masterfrom
schjonhaug:fix/bip119-pseudocode-typo
Open

BIP-119: Fix missing self. prefix on stack reference in pseudocode#2113
schjonhaug wants to merge 1 commit intobitcoin:masterfrom
schjonhaug:fix/bip119-pseudocode-typo

Conversation

@schjonhaug
Copy link

@schjonhaug schjonhaug commented Mar 4, 2026

Summary

In the execute_bip_119 pseudocode, the hash comparison references stack[-1] instead of self.stack[-1], inconsistent with all other stack references in the function:

# Correct:
if len(self.stack) < 1:
if len(self.stack[-1]) == 32:

# Incorrect — missing self.:
if stack[-1] != self.context.tx.get_default_check_template_hash(...)

In Python, stack[-1] would reference an undefined local variable, while self.stack[-1] correctly accesses the interpreter's stack. The C++ reference implementation uses stack.back() consistently and is not affected.

The execute_bip_119 pseudocode references `stack[-1]` on line 74
instead of `self.stack[-1]`, inconsistent with all other stack
references in the function. The C++ reference implementation
correctly uses `stack.back()` throughout.
@schjonhaug schjonhaug marked this pull request as ready for review March 4, 2026 12:46
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.

2 participants