1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-13 19:18:56 +00:00

Updated unit tests for BitcoinCash

This commit is contained in:
Jochen Hoenicke 2017-08-12 21:10:12 +02:00 committed by Pavol Rusnak
parent 29f29626fc
commit 600bcba69c
8 changed files with 149 additions and 114 deletions

View File

@ -18,6 +18,7 @@
import unittest
import common
import trezorlib.types_pb2 as proto_types
import trezorlib.ckd_public as bip32
@ -43,6 +44,28 @@ class TestMsgGetaddress(common.TrezorTest):
self.setup_mnemonic_nopin_nopassphrase()
self.assertEqual(self.client.get_address('Testnet', [111, 42]), 'moN6aN6NP1KWgnPSqzrrRPvx2x1UtZJssa')
def test_bch(self):
self.setup_mnemonic_allallall()
self.assertEqual(self.client.get_address('Bcash', self.client.expand_path("44'/145'/0'/0/0")), '1MH9KKcvdCTY44xVDC2k3fjBbX5Cz29N1q')
self.assertEqual(self.client.get_address('Bcash', self.client.expand_path("44'/145'/0'/0/1")), '1LRspCZNFJcbuNKQkXgHMDucctFRQya5a3')
self.assertEqual(self.client.get_address('Bcash', self.client.expand_path("44'/145'/0'/1/0")), '1HADRPJpgqBzThepERpVXNi6qRgiLQRNoE')
def test_bch_multisig(self):
self.setup_mnemonic_allallall()
xpubs = [];
for n in map(lambda index : self.client.get_public_node(self.client.expand_path("44'/145'/"+str(index)+"'")), range(1,4)):
xpubs.append(n.xpub)
def getmultisig(chain, nr, signatures=[b'',b'',b''], xpubs=xpubs):
return proto_types.MultisigRedeemScriptType(
pubkeys=map(lambda xpub : proto_types.HDNodePathType(node=bip32.deserialize(xpub), address_n=[chain,nr]), xpubs),
signatures=signatures,
m=2,
)
for nr in range(1,4):
self.assertEqual(self.client.get_address('Bcash', self.client.expand_path("44'/145'/"+str(nr)+"'/0/0"), show_display=(nr==1), multisig=getmultisig(0,0)), '33Ju286QvonBz5N1V754ZekQv4GLJqcc5R')
self.assertEqual(self.client.get_address('Bcash', self.client.expand_path("44'/145'/"+str(nr)+"'/1/0"), show_display=(nr==1), multisig=getmultisig(1,0)), '3CPtPpL5mGAPdxUeUDfm2RNdWoSN9dKpXE')
def test_public_ckd(self):
self.setup_mnemonic_nopin_nopassphrase()

View File

@ -21,89 +21,115 @@ import binascii
import trezorlib.messages_pb2 as proto
import trezorlib.types_pb2 as proto_types
from trezorlib.tx_api import TxApiTestnet
from trezorlib.tx_api import TxApiInsight
from trezorlib.ckd_public import deserialize
from trezorlib.client import CallException
TxApiBitcoinCash = TxApiInsight(network='insight_bch', url='https://bch-bitcore2.trezor.io/api/')
class TestMsgSigntxSegwit(common.TrezorTest):
def test_send_bcc_change(self):
def test_send_bch_change(self):
self.setup_mnemonic_allallall()
self.client.set_tx_api(TxApiTestnet)
self.client.set_tx_api(TxApiBitcoinCash)
inp1 = proto_types.TxInputType(
address_n=self.client.expand_path("44'/1'/4'/0/0"),
# moUJnmge8SRXuediK7bW6t4YfrPqbE6hD7
amount=123400000,
prev_hash=binascii.unhexlify('d2dcdaf547ea7f57a713c607f15e883ddc4a98167ee2c43ed953c53cb5153e24'),
prev_index=1,
address_n=self.client.expand_path("44'/145'/0'/0/0"),
# 1MH9KKcvdCTY44xVDC2k3fjBbX5Cz29N1q
amount=1995344,
prev_hash=binascii.unhexlify('bc37c28dfb467d2ecb50261387bf752a3977d7e5337915071bb4151e6b711a78'),
prev_index=0,
script_type=proto_types.SPENDADDRESS,
)
out1 = proto_types.TxOutputType(
address_n=self.client.expand_path("44'/145'/0'/1/0"),
amount=1896050,
script_type=proto_types.PAYTOADDRESS,
)
out2 = proto_types.TxOutputType(
address='1LRspCZNFJcbuNKQkXgHMDucctFRQya5a3',
amount=73452,
script_type=proto_types.PAYTOADDRESS,
)
with self.client:
self.client.set_expected_responses([
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
proto.TxRequest(request_type=proto_types.TXFINISHED),
])
(signatures, serialized_tx) = self.client.sign_tx('Bcash', [inp1], [out1, out2])
self.assertEqual(binascii.hexlify(serialized_tx), b'0100000001781a716b1e15b41b07157933e5d777392a75bf87132650cb2e7d46fb8dc237bc000000006a473044022061aee4f17abe044d5df8c52c9ffd3b84e5a29743517e488b20ecf1ae0b3e4d3a02206bb84c55e407f3b684ff8d9bea0a3409cfd865795a19d10b3d3c31f12795c34a412103a020b36130021a0f037c1d1a02042e325c0cb666d6478c1afdcd9d913b9ef080ffffffff0272ee1c00000000001976a914b1401fce7e8bf123c88a0467e0ed11e3b9fbef5488acec1e0100000000001976a914d51eca49695cdf47e7f4b55507893e3ad53fe9d888ac00000000')
def test_send_bch_nochange(self):
self.setup_mnemonic_allallall()
self.client.set_tx_api(TxApiBitcoinCash)
inp1 = proto_types.TxInputType(
address_n=self.client.expand_path("44'/145'/0'/1/0"),
# 1HADRPJpgqBzThepERpVXNi6qRgiLQRNoE
amount=1896050,
prev_hash=binascii.unhexlify('502e8577b237b0152843a416f8f1ab0c63321b1be7a8cad7bf5c5c216fcf062c'),
prev_index=0,
script_type=proto_types.SPENDADDRESS,
)
inp2 = proto_types.TxInputType(
address_n=self.client.expand_path("44'/1'/4'/0/1"),
# mhSeXqbaojGkaezxgwobgMxGHzv79x7rhK
amount=43210000,
prev_hash=binascii.unhexlify('fe26bc077de27b72ffc5ce77a7e296c7c855b7deb3dec72a3f82c0c07c722bb0'),
address_n=self.client.expand_path("44'/145'/0'/0/1"),
# 1LRspCZNFJcbuNKQkXgHMDucctFRQya5a3
amount=73452,
prev_hash=binascii.unhexlify('502e8577b237b0152843a416f8f1ab0c63321b1be7a8cad7bf5c5c216fcf062c'),
prev_index=1,
script_type=proto_types.SPENDADDRESS,
)
out1 = proto_types.TxOutputType(
address='mwue7mokpBRAsJtHqEMcRPanYBmsSmYKvY',
amount=100000000,
address='15pnEDZJo3ycPUamqP3tEDnEju1oW5fBCz',
amount=1934960,
script_type=proto_types.PAYTOADDRESS,
)
out2 = proto_types.TxOutputType(
address_n=self.client.expand_path("44'/1'/4'/1/0"),
script_type=proto_types.PAYTOADDRESS,
amount=23400000 + 43210000 - 5000
)
with self.client:
self.client.set_expected_responses([
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
proto.TxRequest(request_type=proto_types.TXFINISHED),
])
(signatures, serialized_tx) = self.client.sign_tx('Bcash Testnet', [inp1, inp2], [out1, out2])
(signatures, serialized_tx) = self.client.sign_tx('Bcash', [inp1, inp2], [out1])
self.assertEqual(binascii.hexlify(serialized_tx), b'0100000002243e15b53cc553d93ec4e27e16984adc3d885ef107c613a7577fea47f5dadcd2010000006b483045022100ebcce894cac5d1750f4b1abc7d8c0a5d25944c12a02942b0cc1c89c397acc09602207335077bd698cefc1694d5817abdb3b7aecfcd110ca07729d893577ada71d35441210364430c9122948e525e2f1c6d88f00f47679274f0810fd8c63754954f310995c1ffffffffb02b727cc0c0823f2ac7deb3deb755c8c796e2a777cec5ff727be27d07bc26fe010000006b4830450221008a140434b3f105686c6c4a704c9f2d09b2faf633b81b9ec2304b81f2fd617a9c0220497279b656c4034fd30c41c6f1d0e2ad2aa1b867575aa8f4c13218cb8c114140412103749e3f0a7b01f73427ed67c1cedbb4ecd2315ad6b7c2513355393b95d1ba6137ffffffff0200e1f505000000001976a914b3cc67f3349974d0f1b50e9bb5dfdf226f888fa088acc84ff803000000001976a914f80fb232a1e54b1fa732bc120cae72eabd7fcf6888ac00000000')
self.assertEqual(binascii.hexlify(serialized_tx), b'01000000022c06cf6f215c5cbfd7caa8e71b1b32630cabf1f816a4432815b037b277852e50000000006a47304402207a2a955f1cb3dc5f03f2c82934f55654882af4e852e5159639f6349e9386ec4002205fb8419dce4e648eae8f67bc4e369adfb130a87d2ea2d668f8144213b12bb457412103174c61e9c5362507e8061e28d2c0ce3d4df4e73f3535ae0b12f37809e0f92d2dffffffff2c06cf6f215c5cbfd7caa8e71b1b32630cabf1f816a4432815b037b277852e50010000006a473044022062151cf960b71823bbe68c7ed2c2a93ad1b9706a30255fddb02fcbe056d8c26102207bad1f0872bc5f0cfaf22e45c925c35d6c1466e303163b75cb7688038f1a5541412102595caf9aeb6ffdd0e82b150739a83297358b9a77564de382671056ad9e5b8c58ffffffff0170861d00000000001976a91434e9cec317896e818619ab7dc99d2305216ff4af88ac00000000')
def test_attack_amount(self):
self.setup_mnemonic_allallall()
self.client.set_tx_api(TxApiTestnet)
self.client.set_tx_api(TxApiBitcoinCash)
inp1 = proto_types.TxInputType(
address_n=self.client.expand_path("44'/1'/4'/0/0"),
# moUJnmge8SRXuediK7bW6t4YfrPqbE6hD7
amount=123399999,
prev_hash=binascii.unhexlify('d2dcdaf547ea7f57a713c607f15e883ddc4a98167ee2c43ed953c53cb5153e24'),
prev_index=1,
address_n=self.client.expand_path("44'/145'/0'/1/0"),
# 1HADRPJpgqBzThepERpVXNi6qRgiLQRNoE
amount=1896050 - 1,
prev_hash=binascii.unhexlify('502e8577b237b0152843a416f8f1ab0c63321b1be7a8cad7bf5c5c216fcf062c'),
prev_index=0,
script_type=proto_types.SPENDADDRESS,
)
inp2 = proto_types.TxInputType(
address_n=self.client.expand_path("44'/1'/4'/0/1"),
# mhSeXqbaojGkaezxgwobgMxGHzv79x7rhK
amount=43210000,
prev_hash=binascii.unhexlify('fe26bc077de27b72ffc5ce77a7e296c7c855b7deb3dec72a3f82c0c07c722bb0'),
address_n=self.client.expand_path("44'/145'/0'/0/1"),
# 1LRspCZNFJcbuNKQkXgHMDucctFRQya5a3
amount=73452,
prev_hash=binascii.unhexlify('502e8577b237b0152843a416f8f1ab0c63321b1be7a8cad7bf5c5c216fcf062c'),
prev_index=1,
script_type=proto_types.SPENDADDRESS,
)
out1 = proto_types.TxOutputType(
address='mwue7mokpBRAsJtHqEMcRPanYBmsSmYKvY',
amount=100000000,
address='15pnEDZJo3ycPUamqP3tEDnEju1oW5fBCz',
amount=1934960,
script_type=proto_types.PAYTOADDRESS,
)
out2 = proto_types.TxOutputType(
address_n=self.client.expand_path("44'/1'/4'/1/0"),
script_type=proto_types.PAYTOADDRESS,
amount=23399999 + 43210000 - 5000
)
global run_attack
run_attack = True
@ -124,7 +150,7 @@ class TestMsgSigntxSegwit(common.TrezorTest):
if not run_attack:
return msg
msg.inputs[0].amount = 123400000
msg.inputs[0].amount = 1896050
run_attack = False
return msg
@ -134,41 +160,32 @@ class TestMsgSigntxSegwit(common.TrezorTest):
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
proto.Failure(code=proto_types.Failure_ProcessError),
])
self.assertRaises(CallException, self.client.sign_tx, 'Bcash Testnet', [inp1, inp2], [out1, out2], debug_processor=attack_processor)
self.assertRaises(CallException, self.client.sign_tx, 'Bcash', [inp1, inp2], [out1], debug_processor=attack_processor)
def test_attack_change_input(self):
self.setup_mnemonic_allallall()
self.client.set_tx_api(TxApiTestnet)
self.client.set_tx_api(TxApiBitcoinCash)
inp1 = proto_types.TxInputType(
address_n=self.client.expand_path("44'/1'/4'/0/0"),
# moUJnmge8SRXuediK7bW6t4YfrPqbE6hD7
amount=123400000,
prev_hash=binascii.unhexlify('d2dcdaf547ea7f57a713c607f15e883ddc4a98167ee2c43ed953c53cb5153e24'),
prev_index=1,
script_type=proto_types.SPENDADDRESS,
)
inp2 = proto_types.TxInputType(
address_n=self.client.expand_path("44'/1'/4'/0/1"),
# mhSeXqbaojGkaezxgwobgMxGHzv79x7rhK
amount=43210000,
prev_hash=binascii.unhexlify('fe26bc077de27b72ffc5ce77a7e296c7c855b7deb3dec72a3f82c0c07c722bb0'),
prev_index=1,
address_n=self.client.expand_path("44'/145'/1000'/0/0"),
# 1MH9KKcvdCTY44xVDC2k3fjBbX5Cz29N1q
amount=1995344,
prev_hash=binascii.unhexlify('bc37c28dfb467d2ecb50261387bf752a3977d7e5337915071bb4151e6b711a78'),
prev_index=0,
script_type=proto_types.SPENDADDRESS,
)
out1 = proto_types.TxOutputType(
address='mwue7mokpBRAsJtHqEMcRPanYBmsSmYKvY',
amount=100000000,
address_n=self.client.expand_path("44'/145'/1000'/1/0"),
amount=1896050,
script_type=proto_types.PAYTOADDRESS,
)
out2 = proto_types.TxOutputType(
address_n=self.client.expand_path("44'/1'/1'/1/0"),
address='1LRspCZNFJcbuNKQkXgHMDucctFRQya5a3',
amount=73452,
script_type=proto_types.PAYTOADDRESS,
amount=23400000 + 43210000 - 5000
)
global attack_ctr
@ -185,7 +202,7 @@ class TestMsgSigntxSegwit(common.TrezorTest):
return msg
attack_ctr += 1
if attack_ctr > 2:
if attack_ctr <= 1:
return msg
msg.inputs[0].address_n[2] = 1 + 0x80000000
@ -194,21 +211,20 @@ class TestMsgSigntxSegwit(common.TrezorTest):
with self.client:
self.client.set_expected_responses([
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
proto.Failure(code=proto_types.Failure_ProcessError),
])
self.assertRaises(CallException, self.client.sign_tx, 'Bcash Testnet', [inp1, inp2], [out1, out2], debug_processor=attack_processor)
self.assertRaises(CallException, self.client.sign_tx, 'Bcash', [inp1], [out1, out2], debug_processor=attack_processor)
def test_send_bcc_multisig_wrongchange(self):
def test_send_bch_multisig_wrongchange(self):
self.setup_mnemonic_allallall()
self.client.set_tx_api(TxApiTestnet)
self.client.set_tx_api(TxApiBitcoinCash)
xpubs = [];
for n in map(lambda index : self.client.get_public_node(self.client.expand_path("44'/1'/"+str(index)+"'")), range(1,4)):
for n in map(lambda index : self.client.get_public_node(self.client.expand_path("44'/145'/"+str(index)+"'")), range(1,4)):
xpubs.append(n.xpub)
def getmultisig(chain, nr, signatures=[b'',b'',b''], xpubs=xpubs):
@ -221,53 +237,47 @@ class TestMsgSigntxSegwit(common.TrezorTest):
depth=1,fingerprint=0,child_num=0,
chain_code=binascii.unhexlify('0000000000000000000000000000000000000000000000000000000000000000'),
public_key=binascii.unhexlify('0378d430274f8c5ec1321338151e9f27f4c676a008bdf8638d07c0b6be9ab35c71'))
sig = binascii.unhexlify(b'304402207274b5a4d15e75f3df7319a375557b0efba9b27bc63f9f183a17da95a6125c94022000efac57629f1522e2d3958430e2ef073b0706cfac06cce492651b79858f09ae')
inp1 = proto_types.TxInputType(
address_n=self.client.expand_path("44'/1'/1'/0/0"),
multisig=getmultisig(0,0),
# moUJnmge8SRXuediK7bW6t4YfrPqbE6hD7
amount=50000000,
prev_hash=binascii.unhexlify('5473e99f750a44de54c6bdaf2de393768e386b34545d2497f9cc6f28d2440289'),
prev_index=0,
address_n=self.client.expand_path("44'/145'/1'/1/0"),
multisig=getmultisig(1,0,[b'',sig, b'']),
# 3CPtPpL5mGAPdxUeUDfm2RNdWoSN9dKpXE
amount=24000,
prev_hash=binascii.unhexlify('f68caf10df12d5b07a34601d88fa6856c6edcbf4d05ebef3486510ae1c293d5f'),
prev_index=1,
script_type=proto_types.SPENDMULTISIG,
)
out1 = proto_types.TxOutputType(
address='2NFpzHCzpzhqhfFJxqpdNSj7zyAZARGa8BE',
amount=10000000,
script_type=proto_types.PAYTOADDRESS,
)
out2 = proto_types.TxOutputType(
address_n=self.client.expand_path("44'/1'/1'/1/0"),
address_n=self.client.expand_path("44'/145'/1'/1/1"),
multisig=proto_types.MultisigRedeemScriptType(
pubkeys=[proto_types.HDNodePathType(node=deserialize(xpubs[0]), address_n=[1,0]),
pubkeys=[proto_types.HDNodePathType(node=deserialize(xpubs[0]), address_n=[1,1]),
proto_types.HDNodePathType(node=correcthorse, address_n=[]),
proto_types.HDNodePathType(node=correcthorse, address_n=[])],
signatures=[b'',b'',b''],
m=2,
),
script_type=proto_types.PAYTOMULTISIG,
amount=50000000 - 10000000 - 5000,
amount=23000
)
with self.client:
self.client.set_expected_responses([
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
proto.TxRequest(request_type=proto_types.TXFINISHED),
])
(signatures1, serialized_tx) = self.client.sign_tx('Bcash Testnet', [inp1], [out1, out2])
self.assertEqual(binascii.hexlify(signatures1[0]), b'3044022053acc56aea1d26d84c9a24dae82f2d47f0383ceec57425264f8246d4d6fa49e80220100e65ea7a62df317adf4fb61a24da6d6236a5c688fb309afd11c4262f9b4e43')
(signatures1, serialized_tx) = self.client.sign_tx('Bcash', [inp1], [out1])
self.assertEqual(binascii.hexlify(signatures1[0]), b'3044022052ccf022b3684ecce9f961ce8828387b97267c86bedf0ce16a24bf014e62e42c022035d315ddbeeef7ab3456bd09aed8b625ea58852216b60e4b84ba9f85827d305c')
self.assertEqual(binascii.hexlify(serialized_tx), b'01000000015f3d291cae106548f3be5ed0f4cbedc65668fa881d60347ab0d512df10af8cf601000000fc00473044022052ccf022b3684ecce9f961ce8828387b97267c86bedf0ce16a24bf014e62e42c022035d315ddbeeef7ab3456bd09aed8b625ea58852216b60e4b84ba9f85827d305c4147304402207274b5a4d15e75f3df7319a375557b0efba9b27bc63f9f183a17da95a6125c94022000efac57629f1522e2d3958430e2ef073b0706cfac06cce492651b79858f09ae414c69522103d62b2af2272bbd67cbe30eeaf4226c7f2d57d2a0ed1aab5ab736fb40bb2f5ffe21036d5e0d7ca3589465711eec91436249d7234d3a994c219024fc75cec98fc02ae221024f58378a69b68e89301a6ff882116e0fa35446ec9bfd86532eeb05941ec1f8c853aeffffffff01d85900000000000017a9140bb11de6558871f49fc241341992ece9986f7c5c8700000000')
def test_send_bcc_multisig_change(self):
def test_send_bch_multisig_change(self):
self.setup_mnemonic_allallall()
self.client.set_tx_api(TxApiTestnet)
self.client.set_tx_api(TxApiBitcoinCash)
xpubs = [];
for n in map(lambda index : self.client.get_public_node(self.client.expand_path("44'/1'/"+str(index)+"'")), range(1,4)):
for n in map(lambda index : self.client.get_public_node(self.client.expand_path("44'/145'/"+str(index)+"'")), range(1,4)):
xpubs.append(n.xpub)
def getmultisig(chain, nr, signatures=[b'',b'',b''], xpubs=xpubs):
@ -277,24 +287,24 @@ class TestMsgSigntxSegwit(common.TrezorTest):
m=2,
)
inp1 = proto_types.TxInputType(
address_n=self.client.expand_path("44'/1'/1'/0/0"),
address_n=self.client.expand_path("44'/145'/3'/0/0"),
multisig=getmultisig(0,0),
# moUJnmge8SRXuediK7bW6t4YfrPqbE6hD7
amount=50000000,
prev_hash=binascii.unhexlify('5473e99f750a44de54c6bdaf2de393768e386b34545d2497f9cc6f28d2440289'),
# 33Ju286QvonBz5N1V754ZekQv4GLJqcc5R
amount=48490,
prev_hash=binascii.unhexlify('8b6db9b8ba24235d86b053ea2ccb484fc32b96f89c3c39f98d86f90db16076a0'),
prev_index=0,
script_type=proto_types.SPENDMULTISIG,
)
out1 = proto_types.TxOutputType(
address='2NFpzHCzpzhqhfFJxqpdNSj7zyAZARGa8BE',
amount=10000000,
address='113Q5hHQNQ3bc1RpPX6UNw4GAXstyeA3Dk',
amount=24000,
script_type=proto_types.PAYTOADDRESS,
)
out2 = proto_types.TxOutputType(
address_n=self.client.expand_path("44'/1'/1'/1/0"),
address_n=self.client.expand_path("44'/145'/3'/1/0"),
multisig=getmultisig(1,0),
script_type=proto_types.PAYTOMULTISIG,
amount=50000000 - 10000000 - 5000,
amount=24000
)
with self.client:
self.client.set_expected_responses([
@ -308,22 +318,20 @@ class TestMsgSigntxSegwit(common.TrezorTest):
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
proto.TxRequest(request_type=proto_types.TXFINISHED),
])
(signatures1, serialized_tx) = self.client.sign_tx('Bcash Testnet', [inp1], [out1, out2])
(signatures1, serialized_tx) = self.client.sign_tx('Bcash', [inp1], [out1, out2])
self.assertEqual(binascii.hexlify(signatures1[0]), b'3045022100c5d9dac04f7843ab4832f4e743ffd2f9c1a839f9c350c89613536ca04994a511022025c33450e54230e0e9dc26cdeb9de928049f03e9e74f7e3385b76af1af819b34')
self.assertEqual(binascii.hexlify(signatures1[0]), b'3045022100bcb1a7134a13025a06052546ee1c6ac3640a0abd2d130190ed13ed7fcb43e9cd02207c381478e2ee123c850425bfbf6d3c691230eb37e333832cb32a1ed3f2cd9e85')
signatures1.append(b'')
signatures1.append(b'')
inp1b = proto_types.TxInputType(
address_n=self.client.expand_path("44'/1'/3'/0/0"),
multisig=getmultisig(0,0,signatures1),
# moUJnmge8SRXuediK7bW6t4YfrPqbE6hD7
amount=50000000,
prev_hash=binascii.unhexlify('5473e99f750a44de54c6bdaf2de393768e386b34545d2497f9cc6f28d2440289'),
inp1 = proto_types.TxInputType(
address_n=self.client.expand_path("44'/145'/1'/0/0"),
multisig=getmultisig(0,0,[b'', b'', signatures1[0]]),
# 33Ju286QvonBz5N1V754ZekQv4GLJqcc5R
amount=48490,
prev_hash=binascii.unhexlify('8b6db9b8ba24235d86b053ea2ccb484fc32b96f89c3c39f98d86f90db16076a0'),
prev_index=0,
script_type=proto_types.SPENDMULTISIG,
)
out2.address_n[2] = 3 + 0x80000000
out2.address_n[2] = 1 + 0x80000000
with self.client:
self.client.set_expected_responses([
@ -337,7 +345,9 @@ class TestMsgSigntxSegwit(common.TrezorTest):
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
proto.TxRequest(request_type=proto_types.TXFINISHED),
])
(signatures1, serialized_tx) = self.client.sign_tx('Bcash Testnet', [inp1b], [out1, out2])
(signatures1, serialized_tx) = self.client.sign_tx('Bcash', [inp1], [out1, out2])
self.assertEqual(binascii.hexlify(signatures1[0]), b'3045022100f1153636371ba1f84389460e1265a8fa296569bc18e117c31f4e8f0fc0650c01022022932cc84766ff0c0f65ed9633ad311ae90d4c8fe71f5e1890b1e8f74dd516fa')
self.assertEqual(binascii.hexlify(serialized_tx), b'0100000001a07660b10df9868df9393c9cf8962bc34f48cb2cea53b0865d2324bab8b96d8b00000000fdfe0000483045022100f1153636371ba1f84389460e1265a8fa296569bc18e117c31f4e8f0fc0650c01022022932cc84766ff0c0f65ed9633ad311ae90d4c8fe71f5e1890b1e8f74dd516fa41483045022100bcb1a7134a13025a06052546ee1c6ac3640a0abd2d130190ed13ed7fcb43e9cd02207c381478e2ee123c850425bfbf6d3c691230eb37e333832cb32a1ed3f2cd9e85414c69522102fcf63419c319ce1a42d69120a3599d6da8c5dd4caf2888220eccde5a1ff7c5d021036d7d5ef79370b7fabe2c058698a20219e97fc70868e65ecdd6b37cc18e8a88bd2103505dc649dab8cd1655a4c0daf0ec5f955881c9d7011478ea881fac11cab1e49953aeffffffff02c05d0000000000001976a91400741952f6a6eab5394f366db5cc5a54b0c2429f88acc05d00000000000017a914756c06d7e77de3950a6124f026d8e1a2464b3ecf8700000000')
self.assertEqual(binascii.hexlify(signatures1[0]), b'30450221009907e496658ae839a683b12d740669daba56d68039ba618d51ae8af359d2e67f022071d8b903dbdf8d1a9618cd3e4b056601ec5e67b070b22e19d5e6aad9092f6fae')
self.assertEqual(binascii.hexlify(serialized_tx), b'0100000001890244d2286fccf997245d54346b388e7693e32dafbdc654de440a759fe9735400000000fdfe0000483045022100c5d9dac04f7843ab4832f4e743ffd2f9c1a839f9c350c89613536ca04994a511022025c33450e54230e0e9dc26cdeb9de928049f03e9e74f7e3385b76af1af819b34414830450221009907e496658ae839a683b12d740669daba56d68039ba618d51ae8af359d2e67f022071d8b903dbdf8d1a9618cd3e4b056601ec5e67b070b22e19d5e6aad9092f6fae414c69522103bae960983f83e28fcb8f0e5f3dc1f1297b9f9636612fd0835b768e1b7275fb9d2102fda9c8db4c874fd898256a4524310fa4f66c7dccbb3dca2ded179dcae233c6c121026b27cc8adf7982277d923a5039d90236af0f8e3b27ddfcbc6da4fcc4a88b6b4753aeffffffff02809698000000000017a914f7b5778714965b2b66cbc373b739b4ab5749057d87784662020000000017a9147708c4321dd802870439fa7563716bbccabb5ba68700000000')

View File

@ -0,0 +1 @@
{"vout": [{"scriptPubKey": {"type": "pubkeyhash", "asm": "OP_DUP OP_HASH160 b1401fce7e8bf123c88a0467e0ed11e3b9fbef54 OP_EQUALVERIFY OP_CHECKSIG", "addresses": ["1HADRPJpgqBzThepERpVXNi6qRgiLQRNoE"], "hex": "76a914b1401fce7e8bf123c88a0467e0ed11e3b9fbef5488ac"}, "n": 0, "spentHeight": 478743, "value": "0.01896050", "spentTxId": "5594fd9e5e26dcb4437cbbbba517401720849159bac4e2158e1e6401ffd5fdb7", "spentIndex": 0}, {"scriptPubKey": {"type": "pubkeyhash", "asm": "OP_DUP OP_HASH160 d51eca49695cdf47e7f4b55507893e3ad53fe9d8 OP_EQUALVERIFY OP_CHECKSIG", "addresses": ["1LRspCZNFJcbuNKQkXgHMDucctFRQya5a3"], "hex": "76a914d51eca49695cdf47e7f4b55507893e3ad53fe9d888ac"}, "n": 1, "spentHeight": 478743, "value": "0.00073452", "spentTxId": "5594fd9e5e26dcb4437cbbbba517401720849159bac4e2158e1e6401ffd5fdb7", "spentIndex": 1}], "fees": 0.00025842, "size": 225, "confirmations": 383, "blockheight": 478743, "txid": "502e8577b237b0152843a416f8f1ab0c63321b1be7a8cad7bf5c5c216fcf062c", "blockhash": "0000000000000000012cee10849bd06d2adb6917b08911be7d20371c2da25199", "blocktime": 1502111191, "valueOut": 0.01969502, "vin": [{"vout": 0, "n": 0, "valueSat": 1995344, "doubleSpentTxID": null, "addr": "1MH9KKcvdCTY44xVDC2k3fjBbX5Cz29N1q", "value": 0.01995344, "sequence": 4294967295, "txid": "bc37c28dfb467d2ecb50261387bf752a3977d7e5337915071bb4151e6b711a78", "scriptSig": {"asm": "3044022061aee4f17abe044d5df8c52c9ffd3b84e5a29743517e488b20ecf1ae0b3e4d3a02206bb84c55e407f3b684ff8d9bea0a3409cfd865795a19d10b3d3c31f12795c34a[ALL|FORKID] 03a020b36130021a0f037c1d1a02042e325c0cb666d6478c1afdcd9d913b9ef080", "hex": "473044022061aee4f17abe044d5df8c52c9ffd3b84e5a29743517e488b20ecf1ae0b3e4d3a02206bb84c55e407f3b684ff8d9bea0a3409cfd865795a19d10b3d3c31f12795c34a412103a020b36130021a0f037c1d1a02042e325c0cb666d6478c1afdcd9d913b9ef080"}}], "version": 1, "time": 1502111191, "valueIn": 0.01995344, "locktime": 0}

View File

@ -0,0 +1 @@
{"vout": [{"scriptPubKey": {"type": "scripthash", "asm": "OP_HASH160 11c1566006ab2b8e8c8d981055b090ecdefa9771 OP_EQUAL", "addresses": ["33Ju286QvonBz5N1V754ZekQv4GLJqcc5R"], "hex": "a91411c1566006ab2b8e8c8d981055b090ecdefa977187"}, "n": 0, "spentHeight": -1, "value": "0.00048490", "spentTxId": "f68caf10df12d5b07a34601d88fa6856c6edcbf4d05ebef3486510ae1c293d5f", "spentIndex": 0}], "fees": 1.51e-05, "size": 338, "confirmations": 5, "blockheight": 479121, "txid": "8b6db9b8ba24235d86b053ea2ccb484fc32b96f89c3c39f98d86f90db16076a0", "blockhash": "000000000000000004d736cdc6be7912951849d6a96e8118a5009373d51aa422", "blocktime": 1502563143, "valueOut": 0.0004849, "vin": [{"vout": 0, "n": 0, "valueSat": 50000, "doubleSpentTxID": null, "addr": "3LJVbFT3mKw46FMwQuDvUt5xFQBFsLkknn", "value": 0.0005, "sequence": 4294967294, "txid": "5f72ec264d961dfdd460a9cc22743c795127b129d40be8087244d93b3f7eee11", "scriptSig": {"asm": "0 3045022100e87e3ae6ac22ccbaa8a5800b2bbd81aad9ff56e0fc6993953635fd9ee85e49f102204922bebd2ebdb4f80099c22dd9cb8f99961df8b768cc3cb834cffe1cf11777d1[ALL|FORKID] 304402206d134d84bbb865b48b901eb22dc1b653a0c2a1614035a6fe30885620edca4f280220256aeaa7efdc7449faaebf4f022a281b8c1ac8335e2292e13e9244baeb04787f[ALL|FORKID] 522102c5b28669799aba9cd3b6e3fadd9f15009c82a00b3bbf070741de4666b898ee0c21033b8b5f77354be75eba4c98cf4a32d471a827261228aa2ed7d32c67eec7e150562103cfe16448d9d112d5b965dbe338eec6221006a386727512c3a1f704d4604c494653ae", "hex": "00483045022100e87e3ae6ac22ccbaa8a5800b2bbd81aad9ff56e0fc6993953635fd9ee85e49f102204922bebd2ebdb4f80099c22dd9cb8f99961df8b768cc3cb834cffe1cf11777d14147304402206d134d84bbb865b48b901eb22dc1b653a0c2a1614035a6fe30885620edca4f280220256aeaa7efdc7449faaebf4f022a281b8c1ac8335e2292e13e9244baeb04787f414c69522102c5b28669799aba9cd3b6e3fadd9f15009c82a00b3bbf070741de4666b898ee0c21033b8b5f77354be75eba4c98cf4a32d471a827261228aa2ed7d32c67eec7e150562103cfe16448d9d112d5b965dbe338eec6221006a386727512c3a1f704d4604c494653ae"}}], "version": 1, "time": 1502563143, "valueIn": 0.0005, "locktime": 0}

View File

@ -0,0 +1 @@
{"vout": [{"scriptPubKey": {"type": "pubkeyhash", "asm": "OP_DUP OP_HASH160 de701ce12e576395c863e9377c76dd7efe0c55c1 OP_EQUALVERIFY OP_CHECKSIG", "addresses": ["1MH9KKcvdCTY44xVDC2k3fjBbX5Cz29N1q"], "hex": "76a914de701ce12e576395c863e9377c76dd7efe0c55c188ac"}, "n": 0, "spentHeight": 478743, "value": "0.01995344", "spentTxId": "502e8577b237b0152843a416f8f1ab0c63321b1be7a8cad7bf5c5c216fcf062c", "spentIndex": 0}], "fees": 4.656e-05, "size": 192, "confirmations": 503, "blockheight": 478623, "txid": "bc37c28dfb467d2ecb50261387bf752a3977d7e5337915071bb4151e6b711a78", "blockhash": "000000000000000004cc670aab354e9593d789ec091d571f99fb4ad67ec865a2", "blocktime": 1501857558, "valueOut": 0.01995344, "vin": [{"vout": 1, "n": 0, "valueSat": 2000000, "doubleSpentTxID": null, "addr": "1DS6LVgFWZBGVin3y5B9emUxHtnuQetp9L", "value": 0.02, "sequence": 4294967295, "txid": "8d566ad80d5f1d3887d3acddb35b980641919e6efa7c3a3a78413e56f95ea516", "scriptSig": {"asm": "3045022100860b4c43649f86ee603c13791646af4736c50b532e1fc905c53d73ddd3754f3902206a301113f27b0d10622b333eb914751eed8af7f5534e0e4ee01176668674f259[ALL|FORKID] 02e227a30cc2aa732090af6667086b1665cbe6dbde71aab95ada5a518a4c2fdb6e", "hex": "483045022100860b4c43649f86ee603c13791646af4736c50b532e1fc905c53d73ddd3754f3902206a301113f27b0d10622b333eb914751eed8af7f5534e0e4ee01176668674f259412102e227a30cc2aa732090af6667086b1665cbe6dbde71aab95ada5a518a4c2fdb6e"}}], "version": 1, "time": 1501857558, "valueIn": 0.02, "locktime": 0}

View File

@ -0,0 +1 @@
{"version": 1, "fees": 4.9e-06, "valueIn": 0.0004849, "valueOut": 0.00048, "locktime": 0, "txid": "f68caf10df12d5b07a34601d88fa6856c6edcbf4d05ebef3486510ae1c293d5f", "size": 373, "time": 1502564873, "confirmations": 0, "blockheight": -1, "vout": [{"spentIndex": null, "n": 0, "spentHeight": null, "value": "0.00024000", "scriptPubKey": {"hex": "76a91400741952f6a6eab5394f366db5cc5a54b0c2429f88ac", "type": "pubkeyhash", "asm": "OP_DUP OP_HASH160 00741952f6a6eab5394f366db5cc5a54b0c2429f OP_EQUALVERIFY OP_CHECKSIG", "addresses": ["113Q5hHQNQ3bc1RpPX6UNw4GAXstyeA3Dk"]}, "spentTxId": null}, {"spentIndex": 0, "n": 1, "spentHeight": -1, "value": "0.00024000", "scriptPubKey": {"hex": "a914756c06d7e77de3950a6124f026d8e1a2464b3ecf87", "type": "scripthash", "asm": "OP_HASH160 756c06d7e77de3950a6124f026d8e1a2464b3ecf OP_EQUAL", "addresses": ["3CPtPpL5mGAPdxUeUDfm2RNdWoSN9dKpXE"]}, "spentTxId": "db845018e2049b0d81fca81cfec585cde9a50bae81ae095d53ee86ffd5f8c99b"}], "vin": [{"sequence": 4294967295, "valueSat": 48490, "scriptSig": {"hex": "00483045022100f1153636371ba1f84389460e1265a8fa296569bc18e117c31f4e8f0fc0650c01022022932cc84766ff0c0f65ed9633ad311ae90d4c8fe71f5e1890b1e8f74dd516fa41483045022100bcb1a7134a13025a06052546ee1c6ac3640a0abd2d130190ed13ed7fcb43e9cd02207c381478e2ee123c850425bfbf6d3c691230eb37e333832cb32a1ed3f2cd9e85414c69522102fcf63419c319ce1a42d69120a3599d6da8c5dd4caf2888220eccde5a1ff7c5d021036d7d5ef79370b7fabe2c058698a20219e97fc70868e65ecdd6b37cc18e8a88bd2103505dc649dab8cd1655a4c0daf0ec5f955881c9d7011478ea881fac11cab1e49953ae", "asm": "0 3045022100f1153636371ba1f84389460e1265a8fa296569bc18e117c31f4e8f0fc0650c01022022932cc84766ff0c0f65ed9633ad311ae90d4c8fe71f5e1890b1e8f74dd516fa[ALL|FORKID] 3045022100bcb1a7134a13025a06052546ee1c6ac3640a0abd2d130190ed13ed7fcb43e9cd02207c381478e2ee123c850425bfbf6d3c691230eb37e333832cb32a1ed3f2cd9e85[ALL|FORKID] 522102fcf63419c319ce1a42d69120a3599d6da8c5dd4caf2888220eccde5a1ff7c5d021036d7d5ef79370b7fabe2c058698a20219e97fc70868e65ecdd6b37cc18e8a88bd2103505dc649dab8cd1655a4c0daf0ec5f955881c9d7011478ea881fac11cab1e49953ae"}, "n": 0, "addr": "33Ju286QvonBz5N1V754ZekQv4GLJqcc5R", "vout": 0, "value": 0.0004849, "doubleSpentTxID": null, "txid": "8b6db9b8ba24235d86b053ea2ccb484fc32b96f89c3c39f98d86f90db16076a0"}]}

View File

@ -1 +0,0 @@
{"txid": "d2dcdaf547ea7f57a713c607f15e883ddc4a98167ee2c43ed953c53cb5153e24", "version": 1, "locktime": 0, "vin": [{"txid": "4e686d9815219fc2e57baae29c3b44567693b96fbe150550c269786fbbc6d653", "vout": 0, "sequence": 4294967295, "n": 0, "scriptSig": {"hex": "160014e31581ae69eca39192917940e6604fe6546441c0", "asm": "0014e31581ae69eca39192917940e6604fe6546441c0"}, "addr": "2N2Bw4ofaXx79bEdmG556FMGqa2EWmzJKr8", "valueSat": 2870562139, "value": 28.70562139, "doubleSpentTxID": null}], "vout": [{"value": "27.47158341", "n": 0, "scriptPubKey": {"hex": "a914f96f26251d4edd4c915aa76885dc0a91ec83df1087", "asm": "OP_HASH160 f96f26251d4edd4c915aa76885dc0a91ec83df10 OP_EQUAL", "addresses": ["2NFz7PpPg58HExT4stQDFoqpqduKaiwApqu"], "type": "scripthash"}, "spentTxId": "fe26bc077de27b72ffc5ce77a7e296c7c855b7deb3dec72a3f82c0c07c722bb0", "spentIndex": 0, "spentHeight": 1155197}, {"value": "1.23400000", "n": 1, "scriptPubKey": {"hex": "76a9145740ddea127387c6650ab531994fe6a29b0cec3388ac", "asm": "OP_DUP OP_HASH160 5740ddea127387c6650ab531994fe6a29b0cec33 OP_EQUALVERIFY OP_CHECKSIG", "addresses": ["moUJnmge8SRXuediK7bW6t4YfrPqbE6hD7"], "type": "pubkeyhash"}, "spentTxId": null, "spentIndex": null, "spentHeight": null}], "blockhash": "000000000000061da5f05a6cfbe100b95895e42878d479c30b0f7c1ebfe786ed", "blockheight": 1155197, "confirmations": 148, "time": 1501158191, "blocktime": 1501158191, "valueOut": 28.70558341, "size": 140, "valueIn": 28.70562139, "fees": 3.798e-05}

View File

@ -1 +0,0 @@
{"txid": "fe26bc077de27b72ffc5ce77a7e296c7c855b7deb3dec72a3f82c0c07c722bb0", "version": 1, "locktime": 0, "vin": [{"txid": "d2dcdaf547ea7f57a713c607f15e883ddc4a98167ee2c43ed953c53cb5153e24", "vout": 0, "sequence": 4294967295, "n": 0, "scriptSig": {"hex": "160014d3b73f29a0acf580b6310ab8a6cb7a3328c082e5", "asm": "0014d3b73f29a0acf580b6310ab8a6cb7a3328c082e5"}, "addr": "2NFz7PpPg58HExT4stQDFoqpqduKaiwApqu", "valueSat": 2747158341, "value": 27.47158341, "doubleSpentTxID": null}], "vout": [{"value": "27.03944543", "n": 0, "scriptPubKey": {"hex": "a9144684ab712fd939e2c8f16dc8d466ceeacd968ab987", "asm": "OP_HASH160 4684ab712fd939e2c8f16dc8d466ceeacd968ab9 OP_EQUAL", "addresses": ["2Myg6DmGrwnkuFaXEtYgi1dsTHTy62Pg4hE"], "type": "scripthash"}, "spentTxId": null, "spentIndex": null, "spentHeight": null}, {"value": "0.43210000", "n": 1, "scriptPubKey": {"hex": "76a914151fc2ae3cee358d808d5656ed1e9f18b2cffaef88ac", "asm": "OP_DUP OP_HASH160 151fc2ae3cee358d808d5656ed1e9f18b2cffaef OP_EQUALVERIFY OP_CHECKSIG", "addresses": ["mhSeXqbaojGkaezxgwobgMxGHzv79x7rhK"], "type": "pubkeyhash"}, "spentTxId": null, "spentIndex": null, "spentHeight": null}], "blockhash": "000000000000061da5f05a6cfbe100b95895e42878d479c30b0f7c1ebfe786ed", "blockheight": 1155197, "confirmations": 148, "time": 1501158191, "blocktime": 1501158191, "valueOut": 27.47154543, "size": 140, "valueIn": 27.47158341, "fees": 3.798e-05}