Changeset View
Changeset View
Standalone View
Standalone View
test/functional/rpc_decodescript.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2015-2016 The Bitcoin Core developers | # Copyright (c) 2015-2016 The Bitcoin Core developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.util import * | from test_framework.util import * | ||||
from test_framework.mininode import * | from test_framework.mininode import * | ||||
from io import BytesIO | |||||
class DecodeScriptTest(BitcoinTestFramework): | class DecodeScriptTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.setup_clean_chain = True | self.setup_clean_chain = True | ||||
self.num_nodes = 1 | self.num_nodes = 1 | ||||
def decodescript_script_sig(self): | def decodescript_script_sig(self): | ||||
▲ Show 20 Lines • Show All 122 Lines • ▼ Show 20 Lines | def decoderawtransaction_asm_sighashtype(self): | ||||
assert_equal( | assert_equal( | ||||
'0 3045022100ae3b4e589dfc9d48cb82d41008dc5fa6a86f94d5c54f9935531924602730ab8002202f88cf464414c4ed9fa11b773c5ee944f66e9b05cc1e51d97abc22ce098937ea[ALL] 3045022100b44883be035600e9328a01b66c7d8439b74db64187e76b99a68f7893b701d5380220225bf286493e4c4adcf928c40f785422572eb232f84a0b83b0dea823c3a19c75[ALL] 5221020743d44be989540d27b1b4bbbcfd17721c337cb6bc9af20eb8a32520b393532f2102c0120a1dda9e51a938d39ddd9fe0ebc45ea97e1d27a7cbd671d5431416d3dd87210213820eb3d5f509d7438c9eeecb4157b2f595105e7cd564b3cdbb9ead3da41eed53ae', rpc_result['vin'][0]['scriptSig']['asm']) | '0 3045022100ae3b4e589dfc9d48cb82d41008dc5fa6a86f94d5c54f9935531924602730ab8002202f88cf464414c4ed9fa11b773c5ee944f66e9b05cc1e51d97abc22ce098937ea[ALL] 3045022100b44883be035600e9328a01b66c7d8439b74db64187e76b99a68f7893b701d5380220225bf286493e4c4adcf928c40f785422572eb232f84a0b83b0dea823c3a19c75[ALL] 5221020743d44be989540d27b1b4bbbcfd17721c337cb6bc9af20eb8a32520b393532f2102c0120a1dda9e51a938d39ddd9fe0ebc45ea97e1d27a7cbd671d5431416d3dd87210213820eb3d5f509d7438c9eeecb4157b2f595105e7cd564b3cdbb9ead3da41eed53ae', rpc_result['vin'][0]['scriptSig']['asm']) | ||||
assert_equal( | assert_equal( | ||||
'OP_DUP OP_HASH160 dc863734a218bfe83ef770ee9d41a27f824a6e56 OP_EQUALVERIFY OP_CHECKSIG', | 'OP_DUP OP_HASH160 dc863734a218bfe83ef770ee9d41a27f824a6e56 OP_EQUALVERIFY OP_CHECKSIG', | ||||
rpc_result['vout'][0]['scriptPubKey']['asm']) | rpc_result['vout'][0]['scriptPubKey']['asm']) | ||||
assert_equal( | assert_equal( | ||||
'OP_HASH160 2a5edea39971049a540474c6a99edf0aa4074c58 OP_EQUAL', | 'OP_HASH160 2a5edea39971049a540474c6a99edf0aa4074c58 OP_EQUAL', | ||||
rpc_result['vout'][1]['scriptPubKey']['asm']) | rpc_result['vout'][1]['scriptPubKey']['asm']) | ||||
txSave = CTransaction() | txSave = FromHex(CTransaction(), tx) | ||||
txSave.deserialize(BytesIO(hex_str_to_bytes(tx))) | |||||
# make sure that a specifically crafted op_return value will not pass | # make sure that a specifically crafted op_return value will not pass | ||||
# all the IsDERSignature checks and then get decoded as a sighash type | # all the IsDERSignature checks and then get decoded as a sighash type | ||||
tx = '01000000015ded05872fdbda629c7d3d02b194763ce3b9b1535ea884e3c8e765d42e316724020000006b48304502204c10d4064885c42638cbff3585915b322de33762598321145ba033fc796971e2022100bb153ad3baa8b757e30a2175bd32852d2e1cb9080f84d7e32fcdfd667934ef1b012103163c0ff73511ea1743fb5b98384a2ff09dd06949488028fd819f4d83f56264efffffffff0200000000000000000b6a0930060201000201000180380100000000001976a9141cabd296e753837c086da7a45a6c2fe0d49d7b7b88ac00000000' | tx = '01000000015ded05872fdbda629c7d3d02b194763ce3b9b1535ea884e3c8e765d42e316724020000006b48304502204c10d4064885c42638cbff3585915b322de33762598321145ba033fc796971e2022100bb153ad3baa8b757e30a2175bd32852d2e1cb9080f84d7e32fcdfd667934ef1b012103163c0ff73511ea1743fb5b98384a2ff09dd06949488028fd819f4d83f56264efffffffff0200000000000000000b6a0930060201000201000180380100000000001976a9141cabd296e753837c086da7a45a6c2fe0d49d7b7b88ac00000000' | ||||
rpc_result = self.nodes[0].decoderawtransaction(tx) | rpc_result = self.nodes[0].decoderawtransaction(tx) | ||||
assert_equal('OP_RETURN 300602010002010001', | assert_equal('OP_RETURN 300602010002010001', | ||||
rpc_result['vout'][0]['scriptPubKey']['asm']) | rpc_result['vout'][0]['scriptPubKey']['asm']) | ||||
▲ Show 20 Lines • Show All 65 Lines • Show Last 20 Lines |