← Back to Bitcoin Improvement Proposals
BIPinformational

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

## 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: ```python # 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. Th

No reviews
schjonhaug·Updated Mar 12, 2026·0 reviews·0 attestations·View source
Collections:BIPs — Open

Specification

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.

Discussion (0 threads)

No discussion yet. Be the first to comment.