From f874355b566842cdf6155a59f8fe2e4cf5e6e988 Mon Sep 17 00:00:00 2001 From: Archos R&D Date: Thu, 4 Oct 2018 14:18:44 +0200 Subject: [PATCH 1/7] fixup! support for changing language --- trezorctl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trezorctl b/trezorctl index 008e868f..409f5692 100755 --- a/trezorctl +++ b/trezorctl @@ -324,7 +324,7 @@ def recovery_device(connect, words, expand, pin_protection, passphrase_protectio @click.option('-u', '--u2f-counter', default=0) @click.option('-s', '--skip-backup', is_flag=True) @click.pass_obj -def reset_device(connect, entropy, strength, passphrase_protection, pin_protection, label, u2f_counter, skip_backup): +def reset_device(connect, entropy, strength, passphrase_protection, pin_protection, label, language, u2f_counter, skip_backup): return connect().reset_device( entropy, int(strength), From 389183173cdbc0d43b8ec60a81efff29133f6e0f Mon Sep 17 00:00:00 2001 From: Tomas Susanka Date: Wed, 7 Mar 2018 16:41:16 +0100 Subject: [PATCH 2/7] tests/device: Bitcoin Gold tests --- trezorlib/coins.py | 4 +- .../test_msg_signtx_bitcoin_gold.py | 234 ++++++++++++++++++ ...27cdd5f1b3cd0b9907dd7ff1a07e14addc985.json | 1 + ...3184a98e020d9795c1b65cb7cef2551a8fb18.json | 1 + trezorlib/tx_api.py | 1 + 5 files changed, 240 insertions(+), 1 deletion(-) create mode 100644 trezorlib/tests/device_tests/test_msg_signtx_bitcoin_gold.py create mode 100644 trezorlib/tests/txcache/insight_bitcoin_gold_tx_25526bf06c76ad3082bba930cf627cdd5f1b3cd0b9907dd7ff1a07e14addc985.json create mode 100644 trezorlib/tests/txcache/insight_bitcoin_gold_tx_db77c2461b840e6edbe7f9280043184a98e020d9795c1b65cb7cef2551a8fb18.json diff --git a/trezorlib/coins.py b/trezorlib/coins.py index 77f09708..4298e0c6 100644 --- a/trezorlib/coins.py +++ b/trezorlib/coins.py @@ -1,4 +1,4 @@ -from .tx_api import TxApiBitcoin, TxApiTestnet, TxApiLitecoin, TxApiZcash, TxApiDash, TxApiBcash, TxApiDecredTestnet, TxApiDogecoin, TxApiMonacoin +from .tx_api import TxApiBitcoin, TxApiTestnet, TxApiLitecoin, TxApiZcash, TxApiDash, TxApiBcash, TxApiDecredTestnet, TxApiDogecoin, TxApiMonacoin, TxApiBitcoinGold coins_slip44 = { 'Bitcoin': 0, @@ -14,6 +14,7 @@ 'EtherClassic': 61, 'Zcash': 133, 'Bcash': 145, + 'Bitcoin Gold': 156, } coins_txapi = { @@ -26,4 +27,5 @@ 'Decred Testnet': TxApiDecredTestnet, 'Dogecoin': TxApiDogecoin, 'Monacoin': TxApiMonacoin, + 'Bitcoin Gold': TxApiBitcoinGold, } diff --git a/trezorlib/tests/device_tests/test_msg_signtx_bitcoin_gold.py b/trezorlib/tests/device_tests/test_msg_signtx_bitcoin_gold.py new file mode 100644 index 00000000..9907d1a2 --- /dev/null +++ b/trezorlib/tests/device_tests/test_msg_signtx_bitcoin_gold.py @@ -0,0 +1,234 @@ +# This file is part of the TREZOR project. +# +# Copyright (C) 2012-2016 Marek Palatinus +# Copyright (C) 2012-2016 Pavol Rusnak +# +# This library is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this library. If not, see . + +from .common import * +from trezorlib import messages as proto +from trezorlib.tx_api import TxApiBitcoinGold +from trezorlib.ckd_public import deserialize +from trezorlib.client import CallException + + +# All data taken from T1 +class TestMsgSigntxBitcoinGold(TrezorTest): + + def test_send_bitcoin_gold_change(self): + self.setup_mnemonic_allallall() + self.client.set_tx_api(TxApiBitcoinGold) + inp1 = proto.TxInputType( + address_n=self.client.expand_path("44'/156'/0'/0/0"), + amount=1995344, + prev_hash=unhexlify('25526bf06c76ad3082bba930cf627cdd5f1b3cd0b9907dd7ff1a07e14addc985'), + prev_index=0, + script_type=proto.InputScriptType.SPENDADDRESS, + ) + out1 = proto.TxOutputType( + address_n=self.client.expand_path("44'/156'/0'/1/0"), + amount=1896050, + script_type=proto.OutputScriptType.PAYTOADDRESS, + ) + out2 = proto.TxOutputType( + address='GfDB1tvjfm3bukeoBTtfNqrJVFohS2kCTe', + amount=73452, + script_type=proto.OutputScriptType.PAYTOADDRESS, + ) + with self.client: + self.client.set_expected_responses([ + proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)), + proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)), + proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)), + proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput), + proto.ButtonRequest(code=proto.ButtonRequestType.SignTx), + proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)), + proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)), + proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)), + proto.TxRequest(request_type=proto.RequestType.TXFINISHED), + ]) + (signatures, serialized_tx) = self.client.sign_tx('Bitcoin Gold', [inp1], [out1, out2]) + + assert hexlify(serialized_tx) == b'010000000185c9dd4ae1071affd77d90b9d03c1b5fdd7c62cf30a9bb8230ad766cf06b5225000000006b483045022100963904da0731b71ce468afd45366dd80fbff566ec0d39c1161ab85d17459c7ca02202f5c24a7a7272d98b14a3f5bc000c7cde8ac0eb773f20f4c3131518186cc98854121023bd0ec4022d12d0106c5b7308a25572953ba1951f576f691354a7b147ee0cc1fffffffff0272ee1c00000000001976a9141c82b9c11f193ad82413caadc0955730572b50ae88acec1e0100000000001976a914ea5f904d195079a350b534db4446433b3cec222e88ac00000000' + + def test_send_bitcoin_gold_nochange(self): + self.setup_mnemonic_allallall() + self.client.set_tx_api(TxApiBitcoinGold) + inp1 = proto.TxInputType( + address_n=self.client.expand_path("44'/156'/0'/1/0"), + amount=1896050, + prev_hash=unhexlify('25526bf06c76ad3082bba930cf627cdd5f1b3cd0b9907dd7ff1a07e14addc985'), + prev_index=0, + script_type=proto.InputScriptType.SPENDADDRESS, + ) + inp2 = proto.TxInputType( + address_n=self.client.expand_path("44'/156'/0'/0/1"), + # 1LRspCZNFJcbuNKQkXgHMDucctFRQya5a3 + amount=73452, + prev_hash=unhexlify('db77c2461b840e6edbe7f9280043184a98e020d9795c1b65cb7cef2551a8fb18'), + prev_index=1, + script_type=proto.InputScriptType.SPENDADDRESS, + ) + out1 = proto.TxOutputType( + address='GfDB1tvjfm3bukeoBTtfNqrJVFohS2kCTe', + amount=1934960, + script_type=proto.OutputScriptType.PAYTOADDRESS, + ) + with self.client: + self.client.set_expected_responses([ + proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)), + proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=1)), + proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)), + proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput), + proto.ButtonRequest(code=proto.ButtonRequestType.SignTx), + proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)), + proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=1)), + proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)), + proto.TxRequest(request_type=proto.RequestType.TXFINISHED), + ]) + (signatures, serialized_tx) = self.client.sign_tx('Bitcoin Gold', [inp1, inp2], [out1]) + + assert hexlify(serialized_tx) == b'010000000285c9dd4ae1071affd77d90b9d03c1b5fdd7c62cf30a9bb8230ad766cf06b5225000000006b483045022100928852076c9fab160c07564cd54691af1cbc37fb28f0b7bee7299c7925ef62f0022058856387afecc6508f2f04ecdfd292a13026a5b2107ebdd2cc789bdf8820d552412102a6c3998d0d4e5197ff41aab5c53580253b3b91f583f4c31f7624be7dc83ce15fffffffff18fba85125ef7ccb651b5c79d920e0984a18430028f9e7db6e0e841b46c277db010000006b483045022100faa2f4f01cc95e680349a093923aae0aa2ea01429873555aa8a84bf630ef33a002204c3f4bf567e2d20540c0f71dc278481d6ccb6b95acda2a2f87ce521c79d6b872412102d54a7e5733b1635e5e9442943f48179b1700206b2d1925250ba10f1c86878be8ffffffff0170861d00000000001976a914ea5f904d195079a350b534db4446433b3cec222e88ac00000000' + + def test_attack_change_input(self): + self.setup_mnemonic_allallall() + self.client.set_tx_api(TxApiBitcoinGold) + inp1 = proto.TxInputType( + address_n=self.client.expand_path("44'/156'/1000'/0/0"), + # 1MH9KKcvdCTY44xVDC2k3fjBbX5Cz29N1q + amount=1995344, + prev_hash=unhexlify('25526bf06c76ad3082bba930cf627cdd5f1b3cd0b9907dd7ff1a07e14addc985'), + prev_index=0, + script_type=proto.InputScriptType.SPENDADDRESS, + ) + out1 = proto.TxOutputType( + address_n=self.client.expand_path("44'/156'/1000'/1/0"), + amount=1896050, + script_type=proto.OutputScriptType.PAYTOADDRESS, + ) + out2 = proto.TxOutputType( + address='GfDB1tvjfm3bukeoBTtfNqrJVFohS2kCTe', + amount=73452, + script_type=proto.OutputScriptType.PAYTOADDRESS, + ) + + global attack_ctr + attack_ctr = 0 + + def attack_processor(req, msg): + import sys + global attack_ctr + + if req.details.tx_hash is not None: + return msg + + if req.request_type != proto.RequestType.TXINPUT: + return msg + + attack_ctr += 1 + if attack_ctr <= 1: + return msg + + msg.inputs[0].address_n[2] = 1 + 0x80000000 + return msg + + with self.client: + self.client.set_expected_responses([ + proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)), + proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)), + proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)), + proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput), + proto.ButtonRequest(code=proto.ButtonRequestType.SignTx), + proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)), + proto.Failure(code=proto.FailureType.ProcessError), + ]) + with pytest.raises(CallException): + self.client.sign_tx('Bitcoin Gold', [inp1], [out1, out2], debug_processor=attack_processor) + + def test_send_bch_multisig_change(self): + self.setup_mnemonic_allallall() + self.client.set_tx_api(TxApiBitcoinGold) + xpubs = [] + for n in map(lambda index: self.client.get_public_node(self.client.expand_path("44'/156'/" + str(index) + "'")), range(1, 4)): + xpubs.append(n.xpub) + + def getmultisig(chain, nr, signatures=[b'', b'', b''], xpubs=xpubs): + return proto.MultisigRedeemScriptType( + pubkeys=list(map(lambda xpub: proto.HDNodePathType(node=deserialize(xpub), address_n=[chain, nr]), xpubs)), + signatures=signatures, + m=2, + ) + inp1 = proto.TxInputType( + address_n=self.client.expand_path("44'/156'/3'/0/0"), + multisig=getmultisig(0, 0), + # 33Ju286QvonBz5N1V754ZekQv4GLJqcc5R + amount=48490, + prev_hash=unhexlify('25526bf06c76ad3082bba930cf627cdd5f1b3cd0b9907dd7ff1a07e14addc985'), + prev_index=0, + script_type=proto.InputScriptType.SPENDMULTISIG, + ) + out1 = proto.TxOutputType( + address='GfDB1tvjfm3bukeoBTtfNqrJVFohS2kCTe', + amount=24000, + script_type=proto.OutputScriptType.PAYTOADDRESS, + ) + out2 = proto.TxOutputType( + address_n=self.client.expand_path("44'/156'/3'/1/0"), + multisig=getmultisig(1, 0), + script_type=proto.OutputScriptType.PAYTOMULTISIG, + amount=24000 + ) + with self.client: + self.client.set_expected_responses([ + proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)), + proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)), + proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput), + proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)), + proto.ButtonRequest(code=proto.ButtonRequestType.SignTx), + proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)), + proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)), + proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)), + proto.TxRequest(request_type=proto.RequestType.TXFINISHED), + ]) + (signatures1, serialized_tx) = self.client.sign_tx('Bitcoin Gold', [inp1], [out1, out2]) + + assert hexlify(signatures1[0]) == b'3045022100b1594f3b186d0dedbf61e53a1c407b1e0747098b7375941df85af045040f578e022013ba1893eb9e2fd854dd07073a83b261cf4beba76f66b07742e462b4088a7e4a' + + inp1 = proto.TxInputType( + address_n=self.client.expand_path("44'/156'/1'/0/0"), + multisig=getmultisig(0, 0, [b'', b'', signatures1[0]]), + # 33Ju286QvonBz5N1V754ZekQv4GLJqcc5R + amount=48490, + prev_hash=unhexlify('25526bf06c76ad3082bba930cf627cdd5f1b3cd0b9907dd7ff1a07e14addc985'), + prev_index=0, + script_type=proto.InputScriptType.SPENDMULTISIG, + ) + out2.address_n[2] = 1 + 0x80000000 + + with self.client: + self.client.set_expected_responses([ + proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)), + proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)), + proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput), + proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)), + proto.ButtonRequest(code=proto.ButtonRequestType.SignTx), + proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)), + proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)), + proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)), + proto.TxRequest(request_type=proto.RequestType.TXFINISHED), + ]) + (signatures1, serialized_tx) = self.client.sign_tx('Bitcoin Gold', [inp1], [out1, out2]) + + assert hexlify(signatures1[0]) == b'3044022006da8dbd14e6656ac8dcb956f4c0498574e88680eaeceb2cbafd8d2b2329d8cc02200972d076d444c5ff8f2ab18e14d8249ab661cb9c53335039bedcde037a40d747' + assert hexlify(serialized_tx) == b'010000000185c9dd4ae1071affd77d90b9d03c1b5fdd7c62cf30a9bb8230ad766cf06b522500000000fdfd0000473044022006da8dbd14e6656ac8dcb956f4c0498574e88680eaeceb2cbafd8d2b2329d8cc02200972d076d444c5ff8f2ab18e14d8249ab661cb9c53335039bedcde037a40d74741483045022100b1594f3b186d0dedbf61e53a1c407b1e0747098b7375941df85af045040f578e022013ba1893eb9e2fd854dd07073a83b261cf4beba76f66b07742e462b4088a7e4a414c69522102290e6649574d17938c1ecb959ae92954f9ee48e1bd5b73f35ea931a3ab8a6087210379e0107b173e2c143426760627128c5eea3f862e8df92f3c2558eeeae4e347842103ff1746ca7dcf9e5c2eea9a73779b7c5bafed549f45cf3638a94cdf1e89c7f28f53aeffffffff02c05d0000000000001976a914ea5f904d195079a350b534db4446433b3cec222e88acc05d00000000000017a91445e917e46815d2b38d3f1cf072e63dd4f3b7a7e38700000000' diff --git a/trezorlib/tests/txcache/insight_bitcoin_gold_tx_25526bf06c76ad3082bba930cf627cdd5f1b3cd0b9907dd7ff1a07e14addc985.json b/trezorlib/tests/txcache/insight_bitcoin_gold_tx_25526bf06c76ad3082bba930cf627cdd5f1b3cd0b9907dd7ff1a07e14addc985.json new file mode 100644 index 00000000..758ec183 --- /dev/null +++ b/trezorlib/tests/txcache/insight_bitcoin_gold_tx_25526bf06c76ad3082bba930cf627cdd5f1b3cd0b9907dd7ff1a07e14addc985.json @@ -0,0 +1 @@ +{"txid": "25526bf06c76ad3082bba930cf627cdd5f1b3cd0b9907dd7ff1a07e14addc985", "version": 1, "locktime": 0, "vin": [{"coinbase": "03b4e407005a2d4e4f4d50212068747470733a2f2f6769746875622e636f6d2f6a6f7368756179616275742f7a2d6e6f6d70", "sequence": 4294967295, "n": 0}], "vout": [{"value": "12.52382934", "n": 0, "scriptPubKey": {"hex": "76a9140cb60a52559620e5de9a297612d49f55f7fd14ea88ac", "asm": "OP_DUP OP_HASH160 0cb60a52559620e5de9a297612d49f55f7fd14ea OP_EQUALVERIFY OP_CHECKSIG", "addresses": ["GK18bp4UzC6wqYKKNLkaJ3hzQazTc3TWBw"], "type": "pubkeyhash"}, "spentTxId": null, "spentIndex": null, "spentHeight": null}, {"value": "0.00000000", "n": 1, "scriptPubKey": {"hex": "6a24aa21a9eddb3ac2bba12721c8db157ba6b522196093d3a27a8083591a2b785a230a1d254f", "asm": "OP_RETURN aa21a9eddb3ac2bba12721c8db157ba6b522196093d3a27a8083591a2b785a230a1d254f"}, "spentTxId": null, "spentIndex": null, "spentHeight": null}], "blockhash": "000000000b9f4d15e03603463f536b7b9da695580ae8b8bcdac5970195b586f4", "blockheight": 517300, "confirmations": 3, "time": 1520433267, "blocktime": 1520433267, "isCoinBase": true, "valueOut": "12.52382934", "size": 191} \ No newline at end of file diff --git a/trezorlib/tests/txcache/insight_bitcoin_gold_tx_db77c2461b840e6edbe7f9280043184a98e020d9795c1b65cb7cef2551a8fb18.json b/trezorlib/tests/txcache/insight_bitcoin_gold_tx_db77c2461b840e6edbe7f9280043184a98e020d9795c1b65cb7cef2551a8fb18.json new file mode 100644 index 00000000..9201b58c --- /dev/null +++ b/trezorlib/tests/txcache/insight_bitcoin_gold_tx_db77c2461b840e6edbe7f9280043184a98e020d9795c1b65cb7cef2551a8fb18.json @@ -0,0 +1 @@ +{"txid": "db77c2461b840e6edbe7f9280043184a98e020d9795c1b65cb7cef2551a8fb18", "version": 1, "locktime": 0, "vin": [{"txid": "52fb172f86926a89a16edf55bc9baec3929149b7cd2d2389be3c7d08d744d300", "vout": 1, "sequence": 4294967295, "n": 0, "scriptSig": {"hex": "4830450221008bff524a092086372a19b924f41fa7fa2a5523bf42a4801b9503fcdfff2094e8022000f223a032bd0d7fee31d5663cd5cf86b82533bda6871366d519a68deae1042341210222c6760cc54de6fd7f2a40207a13137d497c7cdb472376523700d8ea88275a96", "asm": "30450221008bff524a092086372a19b924f41fa7fa2a5523bf42a4801b9503fcdfff2094e8022000f223a032bd0d7fee31d5663cd5cf86b82533bda6871366d519a68deae10423[ALL|FORKID] 0222c6760cc54de6fd7f2a40207a13137d497c7cdb472376523700d8ea88275a96"}, "addr": "GgdFx96JSR3nbyhtgxqsUessZLarxLWA3J", "valueSat": 2128176, "value": "0.02128176", "doubleSpentTxID": null}, {"txid": "371eb4feaa4085b378bb825f3c1b457867c24211ee838584b1adac226bba654b", "vout": 0, "sequence": 4294967295, "n": 1, "scriptSig": {"hex": "47304402206aee1d853479782029755dd3c360dbd963e6390da12ddf2c2c38314692510385022040c9c01253a77bc33ac11ce0e8c187ab4f2d78346c0b222a87b1f00fea6b212941210222c6760cc54de6fd7f2a40207a13137d497c7cdb472376523700d8ea88275a96", "asm": "304402206aee1d853479782029755dd3c360dbd963e6390da12ddf2c2c38314692510385022040c9c01253a77bc33ac11ce0e8c187ab4f2d78346c0b222a87b1f00fea6b2129[ALL|FORKID] 0222c6760cc54de6fd7f2a40207a13137d497c7cdb472376523700d8ea88275a96"}, "addr": "GgdFx96JSR3nbyhtgxqsUessZLarxLWA3J", "valueSat": 36323851, "value": "0.36323851", "doubleSpentTxID": null}], "vout": [{"value": "0.38448607", "n": 0, "scriptPubKey": {"hex": "76a914b79bbff2766286a99129642d70912c6a4223c62b88ac", "asm": "OP_DUP OP_HASH160 b79bbff2766286a99129642d70912c6a4223c62b OP_EQUALVERIFY OP_CHECKSIG", "addresses": ["GaakevAd8FJuJQootpkdcS2ocizaXMnFdt"], "type": "pubkeyhash"}, "spentTxId": null, "spentIndex": null, "spentHeight": null}], "blockhash": "000000000b9f4d15e03603463f536b7b9da695580ae8b8bcdac5970195b586f4", "blockheight": 517300, "confirmations": 3, "time": 1520433267, "blocktime": 1520433267, "valueOut": "0.38448607", "size": 339, "valueIn": "0.38452027", "fees": "0.0000342"} \ No newline at end of file diff --git a/trezorlib/tx_api.py b/trezorlib/tx_api.py index 223356fd..b06e9e77 100644 --- a/trezorlib/tx_api.py +++ b/trezorlib/tx_api.py @@ -190,6 +190,7 @@ def get_tx(self, txhash): TxApiDash = TxApiInsight(network='insight_dash', url='https://dash-bitcore1.trezor.io/api/') TxApiZcash = TxApiInsight(network='insight_zcash', url='https://zec-bitcore1.trezor.io/api/', zcash=True) TxApiBcash = TxApiInsight(network='insight_bcash', url='https://bch-bitcore2.trezor.io/api/') +TxApiBitcoinGold = TxApiInsight(network='insight_bitcoin_gold', url='https://btg-bitcore2.trezor.io/api/') TxApiDecredTestnet = TxApiInsight(network='insight_decred_testnet', url='https://testnet.decred.org/api/') TxApiDogecoin = TxApiBlockCypher(network='blockcypher_dogecoin', url='https://api.blockcypher.com/v1/doge/main/') TxApiSegnet = TxApiSmartbit(network='smartbit_segnet', url='https://segnet-api.smartbit.com.au/v1/blockchain/') From b0bcdf2ff433f8707ce6e48b033d904580709926 Mon Sep 17 00:00:00 2001 From: Yura Pakhuchiy Date: Wed, 21 Mar 2018 19:27:30 +0700 Subject: [PATCH 3/7] Add Groestlcoin support --- trezorlib/coins.py | 4 +++- trezorlib/tx_api.py | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/trezorlib/coins.py b/trezorlib/coins.py index 4298e0c6..789d607e 100644 --- a/trezorlib/coins.py +++ b/trezorlib/coins.py @@ -1,4 +1,4 @@ -from .tx_api import TxApiBitcoin, TxApiTestnet, TxApiLitecoin, TxApiZcash, TxApiDash, TxApiBcash, TxApiDecredTestnet, TxApiDogecoin, TxApiMonacoin, TxApiBitcoinGold +from .tx_api import TxApiBitcoin, TxApiTestnet, TxApiLitecoin, TxApiZcash, TxApiDash, TxApiBcash, TxApiDecredTestnet, TxApiDogecoin, TxApiMonacoin, TxApiBitcoinGold, TxApiGroestlcoin coins_slip44 = { 'Bitcoin': 0, @@ -8,6 +8,7 @@ 'Dogecoin': 3, 'Dash': 5, 'Namecoin': 7, + 'Groestlcoin': 17, 'Monacoin': 22, 'Decred': 42, 'Ether': 60, @@ -28,4 +29,5 @@ 'Dogecoin': TxApiDogecoin, 'Monacoin': TxApiMonacoin, 'Bitcoin Gold': TxApiBitcoinGold, + 'Groestlcoin': TxApiGroestlcoin, } diff --git a/trezorlib/tx_api.py b/trezorlib/tx_api.py index b06e9e77..1ceec83b 100644 --- a/trezorlib/tx_api.py +++ b/trezorlib/tx_api.py @@ -195,3 +195,4 @@ def get_tx(self, txhash): TxApiDogecoin = TxApiBlockCypher(network='blockcypher_dogecoin', url='https://api.blockcypher.com/v1/doge/main/') TxApiSegnet = TxApiSmartbit(network='smartbit_segnet', url='https://segnet-api.smartbit.com.au/v1/blockchain/') TxApiMonacoin = TxApiInsight(network='insight_monacoin', url='https://mona.insight.monaco-ex.org/insight-api-monacoin/') +TxApiGroestlcoin = TxApiInsight(network='insight_groestlcoin', url='https://groestlsight.groestlcoin.org/api/') From b3930f2378c6b425948e08031f6669792dedf602 Mon Sep 17 00:00:00 2001 From: dArkjON Date: Wed, 24 Oct 2018 16:33:08 +0200 Subject: [PATCH 4/7] added Bitcore BTX Adding BitCore (BTX) Website: bitcore.cc SLIP44=160 COIN_P2PKH_VERSION=3 COIN_P2SH_VERSION=125 --- trezorlib/coins.py | 4 +++- trezorlib/tx_api.py | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/trezorlib/coins.py b/trezorlib/coins.py index 789d607e..0402a7b8 100644 --- a/trezorlib/coins.py +++ b/trezorlib/coins.py @@ -1,4 +1,4 @@ -from .tx_api import TxApiBitcoin, TxApiTestnet, TxApiLitecoin, TxApiZcash, TxApiDash, TxApiBcash, TxApiDecredTestnet, TxApiDogecoin, TxApiMonacoin, TxApiBitcoinGold, TxApiGroestlcoin +from .tx_api import TxApiBitcoin, TxApiTestnet, TxApiLitecoin, TxApiZcash, TxApiDash, TxApiBcash, TxApiDecredTestnet, TxApiDogecoin, TxApiMonacoin, TxApiBitcoinGold, TxApiGroestlcoin, TxApiBitcore coins_slip44 = { 'Bitcoin': 0, @@ -16,6 +16,7 @@ 'Zcash': 133, 'Bcash': 145, 'Bitcoin Gold': 156, + 'Bitcore': 160, } coins_txapi = { @@ -29,5 +30,6 @@ 'Dogecoin': TxApiDogecoin, 'Monacoin': TxApiMonacoin, 'Bitcoin Gold': TxApiBitcoinGold, + 'Bitcore': TxApiBitcore, 'Groestlcoin': TxApiGroestlcoin, } diff --git a/trezorlib/tx_api.py b/trezorlib/tx_api.py index 1ceec83b..c7b09116 100644 --- a/trezorlib/tx_api.py +++ b/trezorlib/tx_api.py @@ -196,3 +196,4 @@ def get_tx(self, txhash): TxApiSegnet = TxApiSmartbit(network='smartbit_segnet', url='https://segnet-api.smartbit.com.au/v1/blockchain/') TxApiMonacoin = TxApiInsight(network='insight_monacoin', url='https://mona.insight.monaco-ex.org/insight-api-monacoin/') TxApiGroestlcoin = TxApiInsight(network='insight_groestlcoin', url='https://groestlsight.groestlcoin.org/api/') +TxApiBitcore = TxApiInsight(network='insight_bitcore', url='https://insight.bitcore.cc/api/') From b1eab3dba4c04fdfc1fcf17b66662c28c5f2380e Mon Sep 17 00:00:00 2001 From: ghost43 Date: Wed, 26 Dec 2018 04:12:11 +0100 Subject: [PATCH 5/7] qt: don't import PyQt5.Qt follow trezor/python-trezor@8c644cc03e34c2aeedcc80210e0409ee5c403a1a --- trezorlib/qt/pinmatrix.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/trezorlib/qt/pinmatrix.py b/trezorlib/qt/pinmatrix.py index 115d339d..c339fa96 100644 --- a/trezorlib/qt/pinmatrix.py +++ b/trezorlib/qt/pinmatrix.py @@ -10,8 +10,7 @@ from PyQt5.QtWidgets import (QPushButton, QLineEdit, QSizePolicy, QLabel, QApplication, QWidget, QGridLayout, QVBoxLayout, QHBoxLayout) from PyQt5.QtGui import QRegExpValidator - from PyQt5.QtCore import QRegExp, Qt - from PyQt5.Qt import QT_VERSION_STR + from PyQt5.QtCore import QRegExp, Qt, QT_VERSION_STR class PinButton(QPushButton): From 1080a26f538ca6a3a22a3d1cc3ea0af907d72b91 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Fri, 10 Jan 2020 18:20:55 +0100 Subject: [PATCH 6/7] use blake2 from python stdlib if available (py3.6+) --- requirements.txt | 2 +- setup.py | 2 +- trezorlib/client.py | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/requirements.txt b/requirements.txt index a3e66d31..1d8b1fd8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,6 +2,6 @@ ecdsa>=0.9 mnemonic>=0.17 requests>=2.4.0 click>=6.2 -pyblake2>=0.9.3 hidapi>=0.7.99.post20 libusb1>=1.6.4 +pyblake2>=0.9.3 ; python_version<'3.6' diff --git a/setup.py b/setup.py index 6663d2f8..77aec5f2 100755 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ 'mnemonic>=0.17', 'requests>=2.4.0', 'click>=6.2', - 'pyblake2>=0.9.3', + "pyblake2>=0.9.3 ; python_version<'3.6'", ] import sys diff --git a/trezorlib/client.py b/trezorlib/client.py index b18adedc..c6c680a4 100644 --- a/trezorlib/client.py +++ b/trezorlib/client.py @@ -1193,10 +1193,13 @@ def firmware_update(self, fp): # TREZORv2 method if isinstance(resp, proto.FirmwareRequest): - import pyblake2 + try: + from hashlib import blake2s + except ImportError: + from pyblake2 import blake2s while True: payload = data[resp.offset:resp.offset + resp.length] - digest = pyblake2.blake2s(payload).digest() + digest = blake2s(payload).digest() resp = self.call(proto.FirmwareUpload(payload=payload, hash=digest)) if isinstance(resp, proto.FirmwareRequest): continue From 87b0081eb6be6249e465d69ad3a8bac7a23d0dbe Mon Sep 17 00:00:00 2001 From: Sebastian Stark Date: Fri, 21 Feb 2020 17:02:56 +0100 Subject: [PATCH 7/7] Update version to 0.1.5 --- CHANGELOG.md | 6 ++++++ trezorlib/__init__.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03b8cff0..08d5e50b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,10 @@ The changelog format is bound to change as we figure out a way to autogenerate it. +## version 0.1.5 +cleanup imports, improve Python 3.6+ support +add Bitcore BTX support +add Groestlcoin support +fix changing language + ## version 0.1.4 Add preblock_hash in transaction message for BCD support diff --git a/trezorlib/__init__.py b/trezorlib/__init__.py index 7525d199..66a87bb6 100644 --- a/trezorlib/__init__.py +++ b/trezorlib/__init__.py @@ -1 +1 @@ -__version__ = '0.1.4' +__version__ = '0.1.5'