Skip to content

Commit

Permalink
Fix disassembly error with OP_X for X>1.
Browse files Browse the repository at this point in the history
  • Loading branch information
richardkiss committed Dec 13, 2021
1 parent 45e0d6b commit afe30cd
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
5 changes: 4 additions & 1 deletion pycoin/vm/annotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ def sighash_type_to_string(self, sighash_type):
def instruction_for_opcode(self, opcode, data):
if data is None or len(data) == 0:
return self._script_tools.disassemble_for_opcode_data(opcode, data)
return "[PUSH_%d] %s" % (opcode, b2h(data))
b2h_data = b2h(data)
if len(data) == 1:
return "OP_%d" % byte2int(data)
return "[PUSH_%s] %s" % (opcode, b2h_data)

def annotate_pubkey(self, blob, da):
is_compressed = is_sec_compressed(blob)
Expand Down
4 changes: 2 additions & 2 deletions tests/cmds/test_cases/tx/multisig_btg_1_of_3.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ Input:
1: 14 [PUSH_20] ba3aeafd237bc9334e5b6f627aef94d61cabc652
16: 87 OP_EQUAL
--- PUBLIC KEY SCRIPT START
0: 53 [PUSH_83] 03
0: 53 OP_3
1: 21 [PUSH_33] 025540b1be0fa622c16c35347dc8f03fb2f10bb9c08f59e39aa49d83f0b9b1fa0f
SEC for compressed GPcvCW5LCCy56KBVC4RXGP2pBntZpPCko1
23: 21 [PUSH_33] 02673717a66d62e8e9d5b7751a1107fd3990bf18cc312ff0037347b0b170462c3d
SEC for compressed GKg8aCw6jPQeMiqyeG8NBHSzJA5wXhKLhL
45: 21 [PUSH_33] 02c29794ab45b4c98896e16b191ef182a3bbf5813e362a481b621f0d5c7b559005
SEC for compressed GKq9c2ajkAYaSSASCE97TH6TdMb4Qi6rvR
67: 53 [PUSH_83] 03
67: 53 OP_3
68: ae OP_CHECKMULTISIG
Output:
0: AYkZusJAWcKQf8FWJx2THgmXav1HWLqjdu receives 49999.90000 mBTG
Expand Down
4 changes: 2 additions & 2 deletions tests/cmds/test_cases/tx/multisig_btg_2_of_3.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ Input:
1: 14 [PUSH_20] ba3aeafd237bc9334e5b6f627aef94d61cabc652
16: 87 OP_EQUAL
--- PUBLIC KEY SCRIPT START
0: 53 [PUSH_83] 03
0: 53 OP_3
1: 21 [PUSH_33] 025540b1be0fa622c16c35347dc8f03fb2f10bb9c08f59e39aa49d83f0b9b1fa0f
SEC for compressed GPcvCW5LCCy56KBVC4RXGP2pBntZpPCko1
23: 21 [PUSH_33] 02673717a66d62e8e9d5b7751a1107fd3990bf18cc312ff0037347b0b170462c3d
SEC for compressed GKg8aCw6jPQeMiqyeG8NBHSzJA5wXhKLhL
45: 21 [PUSH_33] 02c29794ab45b4c98896e16b191ef182a3bbf5813e362a481b621f0d5c7b559005
SEC for compressed GKq9c2ajkAYaSSASCE97TH6TdMb4Qi6rvR
67: 53 [PUSH_83] 03
67: 53 OP_3
68: ae OP_CHECKMULTISIG
Output:
0: AYkZusJAWcKQf8FWJx2THgmXav1HWLqjdu receives 49999.90000 mBTG
Expand Down
4 changes: 2 additions & 2 deletions tests/cmds/test_cases/tx/multisig_btg_3_of_3.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ Input:
1: 14 [PUSH_20] ba3aeafd237bc9334e5b6f627aef94d61cabc652
16: 87 OP_EQUAL
--- PUBLIC KEY SCRIPT START
0: 53 [PUSH_83] 03
0: 53 OP_3
1: 21 [PUSH_33] 025540b1be0fa622c16c35347dc8f03fb2f10bb9c08f59e39aa49d83f0b9b1fa0f
SEC for compressed GPcvCW5LCCy56KBVC4RXGP2pBntZpPCko1
23: 21 [PUSH_33] 02673717a66d62e8e9d5b7751a1107fd3990bf18cc312ff0037347b0b170462c3d
SEC for compressed GKg8aCw6jPQeMiqyeG8NBHSzJA5wXhKLhL
45: 21 [PUSH_33] 02c29794ab45b4c98896e16b191ef182a3bbf5813e362a481b621f0d5c7b559005
SEC for compressed GKq9c2ajkAYaSSASCE97TH6TdMb4Qi6rvR
67: 53 [PUSH_83] 03
67: 53 OP_3
68: ae OP_CHECKMULTISIG
Output:
0: AYkZusJAWcKQf8FWJx2THgmXav1HWLqjdu receives 49999.90000 mBTG
Expand Down
4 changes: 2 additions & 2 deletions tests/cmds/test_cases/tx/pay_to_opcode_list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Input:
Outputs:
0: ??? receives 123.00000 mBTC
--- PUBLIC KEY SCRIPT START
0: 51 [PUSH_81] 01
1: 52 [PUSH_82] 02
0: 51 OP_1
1: 52 OP_2
2: 9a OP_BOOLAND
3: 02 [PUSH_2] d007
6: 6b OP_TOALTSTACK
Expand Down

0 comments on commit afe30cd

Please sign in to comment.