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. | ||||
"""Test decoding scripts via decodescript RPC command.""" | """Test decoding scripts via decodescript RPC command.""" | ||||
from test_framework.messages import CTransaction, FromHex, ToHex | from test_framework.messages import CTransaction, FromHex, ToHex | ||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.util import assert_equal, bytes_to_hex_str, hex_str_to_bytes | from test_framework.util import assert_equal, hex_str_to_bytes | ||||
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 146 Lines • ▼ Show 20 Lines | def decoderawtransaction_asm_sighashtype(self): | ||||
rpc_result['vout'][0]['scriptPubKey']['asm']) | rpc_result['vout'][0]['scriptPubKey']['asm']) | ||||
assert_equal( | assert_equal( | ||||
'OP_HASH160 3011020701010101010101020601010101010101 OP_EQUAL', | 'OP_HASH160 3011020701010101010101020601010101010101 OP_EQUAL', | ||||
rpc_result['vout'][1]['scriptPubKey']['asm']) | rpc_result['vout'][1]['scriptPubKey']['asm']) | ||||
# some more full transaction tests of varying specific scriptSigs. used instead of | # some more full transaction tests of varying specific scriptSigs. used instead of | ||||
# tests in decodescript_script_sig because the decodescript RPC is specifically | # tests in decodescript_script_sig because the decodescript RPC is specifically | ||||
# for working on scriptPubKeys (argh!). | # for working on scriptPubKeys (argh!). | ||||
push_signature = bytes_to_hex_str( | push_signature = txSave.vin[0].scriptSig.hex()[2:(0x48 * 2 + 4)] | ||||
txSave.vin[0].scriptSig)[2:(0x48 * 2 + 4)] | |||||
signature = push_signature[2:] | signature = push_signature[2:] | ||||
der_signature = signature[:-2] | der_signature = signature[:-2] | ||||
signature_sighash_decoded = der_signature + '[ALL]' | signature_sighash_decoded = der_signature + '[ALL]' | ||||
signature_2 = der_signature + '82' | signature_2 = der_signature + '82' | ||||
push_signature_2 = '48' + signature_2 | push_signature_2 = '48' + signature_2 | ||||
signature_2_sighash_decoded = der_signature + '[NONE|ANYONECANPAY]' | signature_2_sighash_decoded = der_signature + '[NONE|ANYONECANPAY]' | ||||
# 1) P2PK scriptSig | # 1) P2PK scriptSig | ||||
Show All 36 Lines |