Skip to content
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

Update evaluate method in script.py to be able to handle opcodes 177 … #172

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion code-ch13/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def serialize(self):
# encode_varint the total length of the result and prepend
return encode_varint(total) + result

def evaluate(self, z, witness):
def evaluate(self, z, witness, version=None, locktime=None, sequence=None):
# create a copy as we may need to add to this list if we have a
# RedeemScript
cmds = self.cmds[:]
Expand All @@ -180,6 +180,16 @@ def evaluate(self, z, witness):
if not operation(stack, z):
LOGGER.info('bad op: {}'.format(OP_CODE_NAMES[cmd]))
return False
elif cmd == 177:
# 177 is OP_CHECKLOCKTIMEVERIFY. Operation requires locktime and sequence.
if not operation(stack, locktime, sequence):
LOGGER.info(f"bad op: {OP_CODE_NAMES[cmd]}")
return False
elif cmd == 178:
# 178 is OP_CHECKSEQUENCEVERIFY. Operation requires sequence and version.
if not operation(stack, version, sequence):
LOGGER.info(f"bad op: {OP_CODE_NAMES[cmd]}")
return False
else:
if not operation(stack):
LOGGER.info('bad op: {}'.format(OP_CODE_NAMES[cmd]))
Expand Down