From ce1122aca3f24b3a3bf4d485694c9bfcc1f7d435 Mon Sep 17 00:00:00 2001 From: Ademir Villena Date: Sat, 9 Jan 2021 08:41:32 -0500 Subject: [PATCH 1/2] Fixed op_2rot implementation. According to https://en.bitcoin.it/wiki/Script#Stack the OP_2ROT operation should move the 5th and 6th last elements to the top of the stack, not duplicate them. --- code-ch06/op.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code-ch06/op.py b/code-ch06/op.py index 7c17be32..6e4ff523 100644 --- a/code-ch06/op.py +++ b/code-ch06/op.py @@ -278,7 +278,7 @@ def op_2over(stack): def op_2rot(stack): if len(stack) < 6: return False - stack.extend(stack[-6:-4]) + stack = stack[:-6] + stack[-4:] + stack[-6:-4] return True From 2d6dde247d183ae44b19017ff4f6d3a076b59166 Mon Sep 17 00:00:00 2001 From: Ademir Villena Date: Sat, 9 Jan 2021 08:45:55 -0500 Subject: [PATCH 2/2] Modified op_2rot stack assignment To update the stack instead of losing its reference. --- code-ch06/op.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code-ch06/op.py b/code-ch06/op.py index 6e4ff523..4e563de9 100644 --- a/code-ch06/op.py +++ b/code-ch06/op.py @@ -278,7 +278,7 @@ def op_2over(stack): def op_2rot(stack): if len(stack) < 6: return False - stack = stack[:-6] + stack[-4:] + stack[-6:-4] + stack[:] = stack[:-6] + stack[-4:] + stack[-6:-4] return True