|
6 | 6 |
|
7 | 7 | import io
|
8 | 8 | from test_framework.test_framework import BitcoinTestFramework
|
9 |
| -from test_framework.messages import CTransaction |
| 9 | +from test_framework.messages import CTransaction, COIN |
10 | 10 | from test_framework.util import (
|
11 | 11 | assert_equal,
|
12 | 12 | connect_nodes,
|
13 | 13 | disconnect_nodes,
|
14 | 14 | sync_blocks,
|
15 |
| - hex_str_to_bytes, |
16 | 15 | )
|
17 | 16 |
|
18 | 17 | class TxnMallTest(BitcoinTestFramework):
|
@@ -76,13 +75,13 @@ def run_test(self):
|
76 | 75 |
|
77 | 76 | # createrawtransaction randomizes the order of its outputs, so swap them if necessary.
|
78 | 77 | clone_tx = CTransaction()
|
79 |
| - clone_tx.deserialize(io.BytesIO(hex_str_to_bytes(clone_raw))) |
80 |
| - if (rawtx1["vout"][0]["value"] == 40 and clone_tx.vout[0].nValue != 40 or rawtx1["vout"][0]["value"] != 40 and clone_tx.vout[0].nValue == 40): |
| 78 | + clone_tx.deserialize(io.BytesIO(bytes.fromhex(clone_raw))) |
| 79 | + if (rawtx1["vout"][0]["value"] == 40 and clone_tx.vout[0].nValue != 40*COIN or rawtx1["vout"][0]["value"] != 40 and clone_tx.vout[0].nValue == 40*COIN): |
81 | 80 | (clone_tx.vout[0], clone_tx.vout[1]) = (clone_tx.vout[1], clone_tx.vout[0])
|
82 | 81 |
|
83 | 82 | # Use a different signature hash type to sign. This creates an equivalent but malleated clone.
|
84 | 83 | # Don't send the clone anywhere yet
|
85 |
| - tx1_clone = self.nodes[0].signrawtransactionwithwallet(clone_raw, None, "ALL|ANYONECANPAY") |
| 84 | + tx1_clone = self.nodes[0].signrawtransactionwithwallet(clone_tx.serialize().hex(), None, "ALL|ANYONECANPAY") |
86 | 85 | assert_equal(tx1_clone["complete"], True)
|
87 | 86 |
|
88 | 87 | # Have node0 mine a block, if requested:
|
|
0 commit comments