Rework from Google's protobuf to pure-python protobuf implementation
This commit is contained in:
parent
1193b0ee85
commit
a27217811b
2
.flake8
2
.flake8
|
@ -14,6 +14,8 @@ ignore =
|
||||||
F841,
|
F841,
|
||||||
# F401: module imported but unused
|
# F401: module imported but unused
|
||||||
F401,
|
F401,
|
||||||
|
# F403: used import *
|
||||||
|
F403,
|
||||||
# E241: multiple spaces after ':'
|
# E241: multiple spaces after ':'
|
||||||
E241,
|
E241,
|
||||||
# E402: module level import not at top of file
|
# E402: module level import not at top of file
|
||||||
|
|
16
build_pb.sh
16
build_pb.sh
|
@ -1,16 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
CURDIR=$(pwd)
|
|
||||||
|
|
||||||
cd $CURDIR/../trezor-common/protob
|
|
||||||
|
|
||||||
for i in messages types ; do
|
|
||||||
protoc --python_out=$CURDIR/trezorlib/ -I/usr/include -I. $i.proto
|
|
||||||
done
|
|
||||||
|
|
||||||
# hack to make output python 3 compatible
|
|
||||||
sed -i 's/^import types_pb2/from . import types_pb2/g' $CURDIR/trezorlib/messages_pb2.py
|
|
||||||
|
|
||||||
# add version
|
|
||||||
PROTOC_VER=$(protoc --version)
|
|
||||||
PROTOB_REV=$(git rev-parse HEAD)
|
|
||||||
sed -i "3i# $PROTOC_VER\n# trezor-common $PROTOB_REV" $CURDIR/trezorlib/*_pb2.py
|
|
|
@ -1,5 +1,4 @@
|
||||||
ecdsa>=0.9
|
ecdsa>=0.9
|
||||||
protobuf>=3.0.0
|
|
||||||
mnemonic>=0.17
|
mnemonic>=0.17
|
||||||
hidapi>=0.7.99.post20
|
hidapi>=0.7.99.post20
|
||||||
requests>=2.4.0
|
requests>=2.4.0
|
||||||
|
|
5
setup.py
5
setup.py
|
@ -3,7 +3,6 @@ from setuptools import setup
|
||||||
|
|
||||||
install_requires = [
|
install_requires = [
|
||||||
'ecdsa>=0.9',
|
'ecdsa>=0.9',
|
||||||
'protobuf>=3.0.0',
|
|
||||||
'mnemonic>=0.17',
|
'mnemonic>=0.17',
|
||||||
'setuptools>=19.0',
|
'setuptools>=19.0',
|
||||||
'requests>=2.4.0',
|
'requests>=2.4.0',
|
||||||
|
@ -34,7 +33,8 @@ setup(
|
||||||
'trezorlib.ed25519cosi',
|
'trezorlib.ed25519cosi',
|
||||||
'trezorlib.ed25519raw',
|
'trezorlib.ed25519raw',
|
||||||
'trezorlib.mapping',
|
'trezorlib.mapping',
|
||||||
'trezorlib.messages_pb2',
|
'trezorlib.messages',
|
||||||
|
'trezorlib.protobuf',
|
||||||
'trezorlib.protocol_v1',
|
'trezorlib.protocol_v1',
|
||||||
'trezorlib.protocol_v2',
|
'trezorlib.protocol_v2',
|
||||||
'trezorlib.qt.pinmatrix',
|
'trezorlib.qt.pinmatrix',
|
||||||
|
@ -46,7 +46,6 @@ setup(
|
||||||
'trezorlib.transport',
|
'trezorlib.transport',
|
||||||
'trezorlib.transport_udp',
|
'trezorlib.transport_udp',
|
||||||
'trezorlib.tx_api',
|
'trezorlib.tx_api',
|
||||||
'trezorlib.types_pb2',
|
|
||||||
],
|
],
|
||||||
scripts=['trezorctl'],
|
scripts=['trezorctl'],
|
||||||
install_requires=install_requires,
|
install_requires=install_requires,
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
import unittest
|
import unittest
|
||||||
import common
|
import common
|
||||||
|
|
||||||
from trezorlib import messages_pb2 as messages
|
from trezorlib import messages
|
||||||
|
|
||||||
|
|
||||||
class TestBasic(common.TrezorTest):
|
class TestBasic(common.TrezorTest):
|
||||||
|
|
|
@ -20,7 +20,6 @@ import unittest
|
||||||
import common
|
import common
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
from trezorlib import messages_pb2 as proto
|
|
||||||
from trezorlib import ed25519raw, ed25519cosi
|
from trezorlib import ed25519raw, ed25519cosi
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
import unittest
|
import unittest
|
||||||
import common
|
import common
|
||||||
|
|
||||||
from trezorlib import messages_pb2 as proto
|
from trezorlib import messages as proto
|
||||||
|
|
||||||
|
|
||||||
class TestDebugLink(common.TrezorTest):
|
class TestDebugLink(common.TrezorTest):
|
||||||
|
@ -33,11 +33,6 @@ class TestDebugLink(common.TrezorTest):
|
||||||
mnemonic = self.client.debug.read_mnemonic()
|
mnemonic = self.client.debug.read_mnemonic()
|
||||||
self.assertEqual(mnemonic, self.mnemonic12)
|
self.assertEqual(mnemonic, self.mnemonic12)
|
||||||
|
|
||||||
def test_node(self):
|
|
||||||
self.setup_mnemonic_nopin_nopassphrase()
|
|
||||||
node = self.client.debug.read_node()
|
|
||||||
self.assertIsNotNone(node)
|
|
||||||
|
|
||||||
def test_pin(self):
|
def test_pin(self):
|
||||||
self.setup_mnemonic_pin_passphrase()
|
self.setup_mnemonic_pin_passphrase()
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
import unittest
|
import unittest
|
||||||
import common
|
import common
|
||||||
|
|
||||||
from trezorlib import messages_pb2 as proto
|
from trezorlib import messages as proto
|
||||||
|
|
||||||
|
|
||||||
class TestMsgApplysettings(common.TrezorTest):
|
class TestMsgApplysettings(common.TrezorTest):
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
import unittest
|
import unittest
|
||||||
import common
|
import common
|
||||||
|
|
||||||
from trezorlib import messages_pb2 as proto
|
from trezorlib import messages as proto
|
||||||
|
|
||||||
|
|
||||||
class TestMsgChangepin(common.TrezorTest):
|
class TestMsgChangepin(common.TrezorTest):
|
||||||
|
|
|
@ -19,8 +19,7 @@
|
||||||
import unittest
|
import unittest
|
||||||
import common
|
import common
|
||||||
|
|
||||||
from trezorlib import messages_pb2 as proto
|
from trezorlib import messages as proto
|
||||||
from trezorlib import types_pb2 as proto_types
|
|
||||||
|
|
||||||
|
|
||||||
class TestMsgClearsession(common.TrezorTest):
|
class TestMsgClearsession(common.TrezorTest):
|
||||||
|
@ -29,13 +28,13 @@ class TestMsgClearsession(common.TrezorTest):
|
||||||
self.setup_mnemonic_pin_passphrase()
|
self.setup_mnemonic_pin_passphrase()
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([proto.ButtonRequest(code=proto_types.ButtonRequest_ProtectCall), proto.PinMatrixRequest(), proto.PassphraseRequest(), proto.Success()])
|
self.client.set_expected_responses([proto.ButtonRequest(code=proto.ButtonRequestType.ProtectCall), proto.PinMatrixRequest(), proto.PassphraseRequest(), proto.Success()])
|
||||||
res = self.client.ping('random data', button_protection=True, pin_protection=True, passphrase_protection=True)
|
res = self.client.ping('random data', button_protection=True, pin_protection=True, passphrase_protection=True)
|
||||||
self.assertEqual(res, 'random data')
|
self.assertEqual(res, 'random data')
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
# pin and passphrase are cached
|
# pin and passphrase are cached
|
||||||
self.client.set_expected_responses([proto.ButtonRequest(code=proto_types.ButtonRequest_ProtectCall), proto.Success()])
|
self.client.set_expected_responses([proto.ButtonRequest(code=proto.ButtonRequestType.ProtectCall), proto.Success()])
|
||||||
res = self.client.ping('random data', button_protection=True, pin_protection=True, passphrase_protection=True)
|
res = self.client.ping('random data', button_protection=True, pin_protection=True, passphrase_protection=True)
|
||||||
self.assertEqual(res, 'random data')
|
self.assertEqual(res, 'random data')
|
||||||
|
|
||||||
|
@ -43,12 +42,12 @@ class TestMsgClearsession(common.TrezorTest):
|
||||||
|
|
||||||
# session cache is cleared
|
# session cache is cleared
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([proto.ButtonRequest(code=proto_types.ButtonRequest_ProtectCall), proto.PinMatrixRequest(), proto.PassphraseRequest(), proto.Success()])
|
self.client.set_expected_responses([proto.ButtonRequest(code=proto.ButtonRequestType.ProtectCall), proto.PinMatrixRequest(), proto.PassphraseRequest(), proto.Success()])
|
||||||
res = self.client.ping('random data', button_protection=True, pin_protection=True, passphrase_protection=True)
|
res = self.client.ping('random data', button_protection=True, pin_protection=True, passphrase_protection=True)
|
||||||
self.assertEqual(res, 'random data')
|
self.assertEqual(res, 'random data')
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
# pin and passphrase are cached
|
# pin and passphrase are cached
|
||||||
self.client.set_expected_responses([proto.ButtonRequest(code=proto_types.ButtonRequest_ProtectCall), proto.Success()])
|
self.client.set_expected_responses([proto.ButtonRequest(code=proto.ButtonRequestType.ProtectCall), proto.Success()])
|
||||||
res = self.client.ping('random data', button_protection=True, pin_protection=True, passphrase_protection=True)
|
res = self.client.ping('random data', button_protection=True, pin_protection=True, passphrase_protection=True)
|
||||||
self.assertEqual(res, 'random data')
|
self.assertEqual(res, 'random data')
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
import pytest
|
import pytest
|
||||||
import unittest
|
import unittest
|
||||||
import common
|
import common
|
||||||
import trezorlib.types_pb2 as proto_types
|
from trezorlib import messages as proto
|
||||||
import trezorlib.ckd_public as bip32
|
import trezorlib.ckd_public as bip32
|
||||||
|
|
||||||
|
|
||||||
|
@ -59,8 +59,8 @@ class TestMsgGetaddress(common.TrezorTest):
|
||||||
xpubs.append(n.xpub)
|
xpubs.append(n.xpub)
|
||||||
|
|
||||||
def getmultisig(chain, nr, signatures=[b'', b'', b''], xpubs=xpubs):
|
def getmultisig(chain, nr, signatures=[b'', b'', b''], xpubs=xpubs):
|
||||||
return proto_types.MultisigRedeemScriptType(
|
return proto.MultisigRedeemScriptType(
|
||||||
pubkeys=map(lambda xpub: proto_types.HDNodePathType(node=bip32.deserialize(xpub), address_n=[chain, nr]), xpubs),
|
pubkeys=list(map(lambda xpub: proto.HDNodePathType(node=bip32.deserialize(xpub), address_n=[chain, nr]), xpubs)),
|
||||||
signatures=signatures,
|
signatures=signatures,
|
||||||
m=2,
|
m=2,
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import unittest
|
import unittest
|
||||||
import common
|
import common
|
||||||
import trezorlib.ckd_public as bip32
|
import trezorlib.ckd_public as bip32
|
||||||
import trezorlib.types_pb2 as proto_types
|
from trezorlib import messages as proto
|
||||||
|
|
||||||
|
|
||||||
class TestMsgGetaddressSegwit(common.TrezorTest):
|
class TestMsgGetaddressSegwit(common.TrezorTest):
|
||||||
|
@ -9,32 +9,32 @@ class TestMsgGetaddressSegwit(common.TrezorTest):
|
||||||
def test_show_segwit(self):
|
def test_show_segwit(self):
|
||||||
self.setup_mnemonic_allallall()
|
self.setup_mnemonic_allallall()
|
||||||
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("49'/1'/0'/1/0"),
|
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("49'/1'/0'/1/0"),
|
||||||
True, None, script_type=proto_types.SPENDP2SHWITNESS),
|
True, None, script_type=proto.InputScriptType.SPENDP2SHWITNESS),
|
||||||
'2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX')
|
'2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX')
|
||||||
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("49'/1'/0'/0/0"),
|
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("49'/1'/0'/0/0"),
|
||||||
False, None, script_type=proto_types.SPENDP2SHWITNESS),
|
False, None, script_type=proto.InputScriptType.SPENDP2SHWITNESS),
|
||||||
'2N4Q5FhU2497BryFfUgbqkAJE87aKHUhXMp')
|
'2N4Q5FhU2497BryFfUgbqkAJE87aKHUhXMp')
|
||||||
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("44'/1'/0'/0/0"),
|
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("44'/1'/0'/0/0"),
|
||||||
False, None, script_type=proto_types.SPENDP2SHWITNESS),
|
False, None, script_type=proto.InputScriptType.SPENDP2SHWITNESS),
|
||||||
'2N6UeBoqYEEnybg4cReFYDammpsyDw8R2Mc')
|
'2N6UeBoqYEEnybg4cReFYDammpsyDw8R2Mc')
|
||||||
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("44'/1'/0'/0/0"),
|
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("44'/1'/0'/0/0"),
|
||||||
False, None, script_type=proto_types.SPENDADDRESS),
|
False, None, script_type=proto.InputScriptType.SPENDADDRESS),
|
||||||
'mvbu1Gdy8SUjTenqerxUaZyYjmveZvt33q')
|
'mvbu1Gdy8SUjTenqerxUaZyYjmveZvt33q')
|
||||||
|
|
||||||
def test_show_multisig_3(self):
|
def test_show_multisig_3(self):
|
||||||
self.setup_mnemonic_allallall()
|
self.setup_mnemonic_allallall()
|
||||||
nodes = map(lambda index: self.client.get_public_node(self.client.expand_path("999'/1'/%d'" % index)), range(1, 4))
|
nodes = map(lambda index: self.client.get_public_node(self.client.expand_path("999'/1'/%d'" % index)), range(1, 4))
|
||||||
multisig1 = proto_types.MultisigRedeemScriptType(
|
multisig1 = proto.MultisigRedeemScriptType(
|
||||||
pubkeys=map(lambda n: proto_types.HDNodePathType(node=bip32.deserialize(n.xpub), address_n=[2, 0]), nodes),
|
pubkeys=list(map(lambda n: proto.HDNodePathType(node=bip32.deserialize(n.xpub), address_n=[2, 0]), nodes)),
|
||||||
signatures=[b'', b'', b''],
|
signatures=[b'', b'', b''],
|
||||||
m=2,
|
m=2,
|
||||||
)
|
)
|
||||||
# multisig2 = proto_types.MultisigRedeemScriptType(
|
# multisig2 = proto.MultisigRedeemScriptType(
|
||||||
# pubkeys=map(lambda n: proto_types.HDNodePathType(node=bip32.deserialize(n.xpub), address_n=[2, 1]), nodes),
|
# pubkeys=map(lambda n: proto.HDNodePathType(node=bip32.deserialize(n.xpub), address_n=[2, 1]), nodes),
|
||||||
# signatures=[b'', b'', b''],
|
# signatures=[b'', b'', b''],
|
||||||
# m=2,
|
# m=2,
|
||||||
# )
|
# )
|
||||||
for i in [1, 2, 3]:
|
for i in [1, 2, 3]:
|
||||||
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("999'/1'/%d'/2/0" % i),
|
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("999'/1'/%d'/2/0" % i),
|
||||||
False, multisig1, script_type=proto_types.SPENDP2SHWITNESS),
|
False, multisig1, script_type=proto.InputScriptType.SPENDP2SHWITNESS),
|
||||||
'2N2MxyAfifVhb3AMagisxaj3uij8bfXqf4Y')
|
'2N2MxyAfifVhb3AMagisxaj3uij8bfXqf4Y')
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import unittest
|
import unittest
|
||||||
import common
|
import common
|
||||||
import trezorlib.ckd_public as bip32
|
import trezorlib.ckd_public as bip32
|
||||||
import trezorlib.types_pb2 as proto_types
|
from trezorlib import messages as proto
|
||||||
|
|
||||||
|
|
||||||
class TestMsgGetaddressSegwitNative(common.TrezorTest):
|
class TestMsgGetaddressSegwitNative(common.TrezorTest):
|
||||||
|
@ -9,35 +9,35 @@ class TestMsgGetaddressSegwitNative(common.TrezorTest):
|
||||||
def test_show_segwit(self):
|
def test_show_segwit(self):
|
||||||
self.setup_mnemonic_allallall()
|
self.setup_mnemonic_allallall()
|
||||||
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("49'/1'/0'/0/0"),
|
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("49'/1'/0'/0/0"),
|
||||||
True, None, script_type=proto_types.SPENDWITNESS),
|
True, None, script_type=proto.InputScriptType.SPENDWITNESS),
|
||||||
'tb1qqzv60m9ajw8drqulta4ld4gfx0rdh82un5s65s')
|
'tb1qqzv60m9ajw8drqulta4ld4gfx0rdh82un5s65s')
|
||||||
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("49'/1'/0'/1/0"),
|
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("49'/1'/0'/1/0"),
|
||||||
False, None, script_type=proto_types.SPENDWITNESS),
|
False, None, script_type=proto.InputScriptType.SPENDWITNESS),
|
||||||
'tb1q694ccp5qcc0udmfwgp692u2s2hjpq5h407urtu')
|
'tb1q694ccp5qcc0udmfwgp692u2s2hjpq5h407urtu')
|
||||||
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("44'/1'/0'/0/0"),
|
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("44'/1'/0'/0/0"),
|
||||||
False, None, script_type=proto_types.SPENDWITNESS),
|
False, None, script_type=proto.InputScriptType.SPENDWITNESS),
|
||||||
'tb1q54un3q39sf7e7tlfq99d6ezys7qgc62a6rxllc')
|
'tb1q54un3q39sf7e7tlfq99d6ezys7qgc62a6rxllc')
|
||||||
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("44'/1'/0'/0/0"),
|
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("44'/1'/0'/0/0"),
|
||||||
False, None, script_type=proto_types.SPENDADDRESS),
|
False, None, script_type=proto.InputScriptType.SPENDADDRESS),
|
||||||
'mvbu1Gdy8SUjTenqerxUaZyYjmveZvt33q')
|
'mvbu1Gdy8SUjTenqerxUaZyYjmveZvt33q')
|
||||||
|
|
||||||
def test_show_multisig_3(self):
|
def test_show_multisig_3(self):
|
||||||
self.setup_mnemonic_allallall()
|
self.setup_mnemonic_allallall()
|
||||||
nodes = [self.client.get_public_node(self.client.expand_path("999'/1'/%d'" % index)) for index in range(1, 4)]
|
nodes = [self.client.get_public_node(self.client.expand_path("999'/1'/%d'" % index)) for index in range(1, 4)]
|
||||||
multisig1 = proto_types.MultisigRedeemScriptType(
|
multisig1 = proto.MultisigRedeemScriptType(
|
||||||
pubkeys=map(lambda n: proto_types.HDNodePathType(node=bip32.deserialize(n.xpub), address_n=[2, 0]), nodes),
|
pubkeys=list(map(lambda n: proto.HDNodePathType(node=bip32.deserialize(n.xpub), address_n=[2, 0]), nodes)),
|
||||||
signatures=[b'', b'', b''],
|
signatures=[b'', b'', b''],
|
||||||
m=2,
|
m=2,
|
||||||
)
|
)
|
||||||
multisig2 = proto_types.MultisigRedeemScriptType(
|
multisig2 = proto.MultisigRedeemScriptType(
|
||||||
pubkeys=map(lambda n: proto_types.HDNodePathType(node=bip32.deserialize(n.xpub), address_n=[2, 1]), nodes),
|
pubkeys=list(map(lambda n: proto.HDNodePathType(node=bip32.deserialize(n.xpub), address_n=[2, 1]), nodes)),
|
||||||
signatures=[b'', b'', b''],
|
signatures=[b'', b'', b''],
|
||||||
m=2,
|
m=2,
|
||||||
)
|
)
|
||||||
for i in [1, 2, 3]:
|
for i in [1, 2, 3]:
|
||||||
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("999'/1'/%d'/2/1" % i),
|
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("999'/1'/%d'/2/1" % i),
|
||||||
False, multisig2, script_type=proto_types.SPENDWITNESS),
|
False, multisig2, script_type=proto.InputScriptType.SPENDWITNESS),
|
||||||
'tb1qch62pf820spe9mlq49ns5uexfnl6jzcezp7d328fw58lj0rhlhasge9hzy')
|
'tb1qch62pf820spe9mlq49ns5uexfnl6jzcezp7d328fw58lj0rhlhasge9hzy')
|
||||||
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("999'/1'/%d'/2/0" % i),
|
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("999'/1'/%d'/2/0" % i),
|
||||||
False, multisig1, script_type=proto_types.SPENDWITNESS),
|
False, multisig1, script_type=proto.InputScriptType.SPENDWITNESS),
|
||||||
'tb1qr6xa5v60zyt3ry9nmfew2fk5g9y3gerkjeu6xxdz7qga5kknz2ssld9z2z')
|
'tb1qr6xa5v60zyt3ry9nmfew2fk5g9y3gerkjeu6xxdz7qga5kknz2ssld9z2z')
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
import unittest
|
import unittest
|
||||||
import common
|
import common
|
||||||
import trezorlib.ckd_public as bip32
|
import trezorlib.ckd_public as bip32
|
||||||
import trezorlib.types_pb2 as proto_types
|
from trezorlib import messages as proto
|
||||||
|
|
||||||
|
|
||||||
class TestMsgGetaddress(common.TrezorTest):
|
class TestMsgGetaddress(common.TrezorTest):
|
||||||
|
@ -34,11 +34,11 @@ class TestMsgGetaddress(common.TrezorTest):
|
||||||
self.setup_mnemonic_nopin_nopassphrase()
|
self.setup_mnemonic_nopin_nopassphrase()
|
||||||
|
|
||||||
node = bip32.deserialize('xpub661MyMwAqRbcF1zGijBb2K6x9YiJPh58xpcCeLvTxMX6spkY3PcpJ4ABcCyWfskq5DDxM3e6Ez5ePCqG5bnPUXR4wL8TZWyoDaUdiWW7bKy')
|
node = bip32.deserialize('xpub661MyMwAqRbcF1zGijBb2K6x9YiJPh58xpcCeLvTxMX6spkY3PcpJ4ABcCyWfskq5DDxM3e6Ez5ePCqG5bnPUXR4wL8TZWyoDaUdiWW7bKy')
|
||||||
multisig = proto_types.MultisigRedeemScriptType(
|
multisig = proto.MultisigRedeemScriptType(
|
||||||
pubkeys=[
|
pubkeys=[
|
||||||
proto_types.HDNodePathType(node=node, address_n=[1]),
|
proto.HDNodePathType(node=node, address_n=[1]),
|
||||||
proto_types.HDNodePathType(node=node, address_n=[2]),
|
proto.HDNodePathType(node=node, address_n=[2]),
|
||||||
proto_types.HDNodePathType(node=node, address_n=[3])
|
proto.HDNodePathType(node=node, address_n=[3])
|
||||||
],
|
],
|
||||||
signatures=[b'', b'', b''],
|
signatures=[b'', b'', b''],
|
||||||
m=2,
|
m=2,
|
||||||
|
@ -54,9 +54,9 @@ class TestMsgGetaddress(common.TrezorTest):
|
||||||
|
|
||||||
pubs = []
|
pubs = []
|
||||||
for x in range(15):
|
for x in range(15):
|
||||||
pubs.append(proto_types.HDNodePathType(node=node, address_n=[x]))
|
pubs.append(proto.HDNodePathType(node=node, address_n=[x]))
|
||||||
|
|
||||||
multisig = proto_types.MultisigRedeemScriptType(
|
multisig = proto.MultisigRedeemScriptType(
|
||||||
pubkeys=pubs,
|
pubkeys=pubs,
|
||||||
signatures=[b''] * 15,
|
signatures=[b''] * 15,
|
||||||
m=15,
|
m=15,
|
||||||
|
|
|
@ -22,8 +22,7 @@ import unittest
|
||||||
import math
|
import math
|
||||||
import common
|
import common
|
||||||
|
|
||||||
import trezorlib.messages_pb2 as proto
|
import trezorlib.messages as proto
|
||||||
import trezorlib.types_pb2 as proto_types
|
|
||||||
|
|
||||||
|
|
||||||
def entropy(data):
|
def entropy(data):
|
||||||
|
@ -45,7 +44,7 @@ class TestMsgGetentropy(common.TrezorTest):
|
||||||
def test_entropy(self):
|
def test_entropy(self):
|
||||||
for l in [0, 1, 2, 3, 4, 5, 8, 9, 16, 17, 32, 33, 64, 65, 128, 129, 256, 257, 512, 513, 1024]:
|
for l in [0, 1, 2, 3, 4, 5, 8, 9, 16, 17, 32, 33, 64, 65, 128, 129, 256, 257, 512, 513, 1024]:
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([proto.ButtonRequest(code=proto_types.ButtonRequest_ProtectCall), proto.Entropy()])
|
self.client.set_expected_responses([proto.ButtonRequest(code=proto.ButtonRequestType.ProtectCall), proto.Entropy()])
|
||||||
ent = self.client.get_entropy(l)
|
ent = self.client.get_entropy(l)
|
||||||
self.assertTrue(len(ent) == l)
|
self.assertTrue(len(ent) == l)
|
||||||
print('entropy = ', entropy(ent))
|
print('entropy = ', entropy(ent))
|
||||||
|
|
|
@ -21,7 +21,6 @@ import common
|
||||||
|
|
||||||
|
|
||||||
class TestDeviceLoad(common.TrezorTest):
|
class TestDeviceLoad(common.TrezorTest):
|
||||||
|
|
||||||
def test_load_device_1(self):
|
def test_load_device_1(self):
|
||||||
self.setup_mnemonic_nopin_nopassphrase()
|
self.setup_mnemonic_nopin_nopassphrase()
|
||||||
|
|
||||||
|
@ -29,7 +28,7 @@ class TestDeviceLoad(common.TrezorTest):
|
||||||
self.assertEqual(mnemonic, self.mnemonic12)
|
self.assertEqual(mnemonic, self.mnemonic12)
|
||||||
|
|
||||||
pin = self.client.debug.read_pin()[0]
|
pin = self.client.debug.read_pin()[0]
|
||||||
self.assertEqual(pin, '')
|
self.assertEqual(pin, None)
|
||||||
|
|
||||||
passphrase_protection = self.client.debug.read_passphrase_protection()
|
passphrase_protection = self.client.debug.read_passphrase_protection()
|
||||||
self.assertEqual(passphrase_protection, False)
|
self.assertEqual(passphrase_protection, False)
|
||||||
|
|
|
@ -19,8 +19,7 @@ import unittest
|
||||||
import common
|
import common
|
||||||
import binascii
|
import binascii
|
||||||
|
|
||||||
from trezorlib import messages_pb2 as proto
|
from trezorlib import messages as proto
|
||||||
from trezorlib import types_pb2 as proto_types
|
|
||||||
|
|
||||||
# tx hash: 209368053ac61969b6838ceb7e31badeb622ed6aa42d6c58365c42ad1a11e19d
|
# tx hash: 209368053ac61969b6838ceb7e31badeb622ed6aa42d6c58365c42ad1a11e19d
|
||||||
SIGNATURE_TESTNET_SIMPLE = binascii.unhexlify(
|
SIGNATURE_TESTNET_SIMPLE = binascii.unhexlify(
|
||||||
|
@ -41,11 +40,11 @@ class TestMsgNEMSigntx(common.TrezorTest):
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
# Confirm transfer and network fee
|
# Confirm transfer and network fee
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
# Unencrypted message
|
# Unencrypted message
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
# Confirm recipient
|
# Confirm recipient
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.NEMSignedTx(signature=SIGNATURE_TESTNET_SIMPLE),
|
proto.NEMSignedTx(signature=SIGNATURE_TESTNET_SIMPLE),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
@ -69,9 +68,9 @@ class TestMsgNEMSigntx(common.TrezorTest):
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
# Confirm transfer and network fee
|
# Confirm transfer and network fee
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
# Confirm recipient
|
# Confirm recipient
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.NEMSignedTx(signature=SIGNATURE_TESTNET_XEM_AS_MOSAIC),
|
proto.NEMSignedTx(signature=SIGNATURE_TESTNET_XEM_AS_MOSAIC),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,7 @@
|
||||||
import unittest
|
import unittest
|
||||||
import common
|
import common
|
||||||
|
|
||||||
from trezorlib import messages_pb2 as proto
|
from trezorlib import messages as proto
|
||||||
from trezorlib import types_pb2 as proto_types
|
|
||||||
|
|
||||||
|
|
||||||
class TestPing(common.TrezorTest):
|
class TestPing(common.TrezorTest):
|
||||||
|
@ -34,7 +33,7 @@ class TestPing(common.TrezorTest):
|
||||||
self.assertEqual(res, 'random data')
|
self.assertEqual(res, 'random data')
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([proto.ButtonRequest(code=proto_types.ButtonRequest_ProtectCall), proto.Success()])
|
self.client.set_expected_responses([proto.ButtonRequest(code=proto.ButtonRequestType.ProtectCall), proto.Success()])
|
||||||
res = self.client.ping('random data', button_protection=True)
|
res = self.client.ping('random data', button_protection=True)
|
||||||
self.assertEqual(res, 'random data')
|
self.assertEqual(res, 'random data')
|
||||||
|
|
||||||
|
@ -52,12 +51,12 @@ class TestPing(common.TrezorTest):
|
||||||
self.setup_mnemonic_pin_passphrase()
|
self.setup_mnemonic_pin_passphrase()
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([proto.ButtonRequest(code=proto_types.ButtonRequest_ProtectCall), proto.PinMatrixRequest(), proto.PassphraseRequest(), proto.Success()])
|
self.client.set_expected_responses([proto.ButtonRequest(code=proto.ButtonRequestType.ProtectCall), proto.PinMatrixRequest(), proto.PassphraseRequest(), proto.Success()])
|
||||||
res = self.client.ping('random data', button_protection=True, pin_protection=True, passphrase_protection=True)
|
res = self.client.ping('random data', button_protection=True, pin_protection=True, passphrase_protection=True)
|
||||||
self.assertEqual(res, 'random data')
|
self.assertEqual(res, 'random data')
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
# pin and passphrase are cached
|
# pin and passphrase are cached
|
||||||
self.client.set_expected_responses([proto.ButtonRequest(code=proto_types.ButtonRequest_ProtectCall), proto.Success()])
|
self.client.set_expected_responses([proto.ButtonRequest(code=proto.ButtonRequestType.ProtectCall), proto.Success()])
|
||||||
res = self.client.ping('random data', button_protection=True, pin_protection=True, passphrase_protection=True)
|
res = self.client.ping('random data', button_protection=True, pin_protection=True, passphrase_protection=True)
|
||||||
self.assertEqual(res, 'random data')
|
self.assertEqual(res, 'random data')
|
||||||
|
|
|
@ -21,7 +21,7 @@ from __future__ import print_function
|
||||||
import unittest
|
import unittest
|
||||||
import common
|
import common
|
||||||
|
|
||||||
from trezorlib import messages_pb2 as proto
|
from trezorlib import messages as proto
|
||||||
|
|
||||||
|
|
||||||
class TestDeviceRecovery(common.TrezorTest):
|
class TestDeviceRecovery(common.TrezorTest):
|
||||||
|
|
|
@ -21,7 +21,7 @@ from __future__ import print_function
|
||||||
import unittest
|
import unittest
|
||||||
import common
|
import common
|
||||||
|
|
||||||
from trezorlib import messages_pb2 as proto
|
from trezorlib import messages as proto
|
||||||
|
|
||||||
|
|
||||||
class TestDeviceRecoveryDryRun(common.TrezorTest):
|
class TestDeviceRecoveryDryRun(common.TrezorTest):
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
import unittest
|
import unittest
|
||||||
import common
|
import common
|
||||||
|
|
||||||
from trezorlib import messages_pb2 as proto
|
from trezorlib import messages as proto
|
||||||
from mnemonic import Mnemonic
|
from mnemonic import Mnemonic
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
import unittest
|
import unittest
|
||||||
import common
|
import common
|
||||||
|
|
||||||
from trezorlib import messages_pb2 as proto
|
from trezorlib import messages as proto
|
||||||
from mnemonic import Mnemonic
|
from mnemonic import Mnemonic
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ import hashlib
|
||||||
import struct
|
import struct
|
||||||
import common
|
import common
|
||||||
|
|
||||||
import trezorlib.types_pb2 as proto_types
|
from trezorlib import messages as proto
|
||||||
|
|
||||||
|
|
||||||
def check_path(identity):
|
def check_path(identity):
|
||||||
|
@ -59,7 +59,7 @@ class TestMsgSignidentity(common.TrezorTest):
|
||||||
# URI : https://satoshi@bitcoin.org/login
|
# URI : https://satoshi@bitcoin.org/login
|
||||||
# hash : d0e2389d4c8394a9f3e32de01104bf6e8db2d9e2bb0905d60fffa5a18fd696db
|
# hash : d0e2389d4c8394a9f3e32de01104bf6e8db2d9e2bb0905d60fffa5a18fd696db
|
||||||
# path : m/2147483661/2637750992/2845082444/3761103859/4005495825
|
# path : m/2147483661/2637750992/2845082444/3761103859/4005495825
|
||||||
identity = proto_types.IdentityType(proto='https', user='satoshi', host='bitcoin.org', port='', path='/login', index=0)
|
identity = proto.IdentityType(proto='https', user='satoshi', host='bitcoin.org', port='', path='/login', index=0)
|
||||||
sig = self.client.sign_identity(identity, hidden, visual)
|
sig = self.client.sign_identity(identity, hidden, visual)
|
||||||
self.assertEqual(sig.address, '17F17smBTX9VTZA9Mj8LM5QGYNZnmziCjL')
|
self.assertEqual(sig.address, '17F17smBTX9VTZA9Mj8LM5QGYNZnmziCjL')
|
||||||
self.assertEqual(binascii.hexlify(sig.public_key), b'023a472219ad3327b07c18273717bb3a40b39b743756bf287fbd5fa9d263237f45')
|
self.assertEqual(binascii.hexlify(sig.public_key), b'023a472219ad3327b07c18273717bb3a40b39b743756bf287fbd5fa9d263237f45')
|
||||||
|
@ -68,7 +68,7 @@ class TestMsgSignidentity(common.TrezorTest):
|
||||||
# URI : ftp://satoshi@bitcoin.org:2323/pub
|
# URI : ftp://satoshi@bitcoin.org:2323/pub
|
||||||
# hash : 79a6b53831c6ff224fb283587adc4ebae8fb0d734734a46c876838f52dff53f3
|
# hash : 79a6b53831c6ff224fb283587adc4ebae8fb0d734734a46c876838f52dff53f3
|
||||||
# path : m/2147483661/3098912377/2734671409/3632509519/3125730426
|
# path : m/2147483661/3098912377/2734671409/3632509519/3125730426
|
||||||
identity = proto_types.IdentityType(proto='ftp', user='satoshi', host='bitcoin.org', port='2323', path='/pub', index=3)
|
identity = proto.IdentityType(proto='ftp', user='satoshi', host='bitcoin.org', port='2323', path='/pub', index=3)
|
||||||
sig = self.client.sign_identity(identity, hidden, visual)
|
sig = self.client.sign_identity(identity, hidden, visual)
|
||||||
self.assertEqual(sig.address, '1KAr6r5qF2kADL8bAaRQBjGKYEGxn9WrbS')
|
self.assertEqual(sig.address, '1KAr6r5qF2kADL8bAaRQBjGKYEGxn9WrbS')
|
||||||
self.assertEqual(binascii.hexlify(sig.public_key), b'0266cf12d2ba381c5fd797da0d64f59c07a6f1b034ad276cca6bf2729e92b20d9c')
|
self.assertEqual(binascii.hexlify(sig.public_key), b'0266cf12d2ba381c5fd797da0d64f59c07a6f1b034ad276cca6bf2729e92b20d9c')
|
||||||
|
@ -77,17 +77,17 @@ class TestMsgSignidentity(common.TrezorTest):
|
||||||
# URI : ssh://satoshi@bitcoin.org
|
# URI : ssh://satoshi@bitcoin.org
|
||||||
# hash : 5fa612f558a1a3b1fb7f010b2ea0a25cb02520a0ffa202ce74a92fc6145da5f3
|
# hash : 5fa612f558a1a3b1fb7f010b2ea0a25cb02520a0ffa202ce74a92fc6145da5f3
|
||||||
# path : m/2147483661/4111640159/2980290904/2332131323/3701645358
|
# path : m/2147483661/4111640159/2980290904/2332131323/3701645358
|
||||||
identity = proto_types.IdentityType(proto='ssh', user='satoshi', host='bitcoin.org', port='', path='', index=47)
|
identity = proto.IdentityType(proto='ssh', user='satoshi', host='bitcoin.org', port='', path='', index=47)
|
||||||
sig = self.client.sign_identity(identity, hidden, visual, ecdsa_curve_name='nist256p1')
|
sig = self.client.sign_identity(identity, hidden, visual, ecdsa_curve_name='nist256p1')
|
||||||
self.assertEqual(sig.address, '')
|
self.assertEqual(sig.address, None)
|
||||||
self.assertEqual(binascii.hexlify(sig.public_key), b'0373f21a3da3d0e96fc2189f81dd826658c3d76b2d55bd1da349bc6c3573b13ae4')
|
self.assertEqual(binascii.hexlify(sig.public_key), b'0373f21a3da3d0e96fc2189f81dd826658c3d76b2d55bd1da349bc6c3573b13ae4')
|
||||||
self.assertEqual(binascii.hexlify(sig.signature), b'005122cebabb852cdd32103b602662afa88e54c0c0c1b38d7099c64dcd49efe908288114e66ed2d8c82f23a70b769a4db723173ec53840c08aafb840d3f09a18d3')
|
self.assertEqual(binascii.hexlify(sig.signature), b'005122cebabb852cdd32103b602662afa88e54c0c0c1b38d7099c64dcd49efe908288114e66ed2d8c82f23a70b769a4db723173ec53840c08aafb840d3f09a18d3')
|
||||||
|
|
||||||
# URI : ssh://satoshi@bitcoin.org
|
# URI : ssh://satoshi@bitcoin.org
|
||||||
# hash : 5fa612f558a1a3b1fb7f010b2ea0a25cb02520a0ffa202ce74a92fc6145da5f3
|
# hash : 5fa612f558a1a3b1fb7f010b2ea0a25cb02520a0ffa202ce74a92fc6145da5f3
|
||||||
# path : m/2147483661/4111640159/2980290904/2332131323/3701645358
|
# path : m/2147483661/4111640159/2980290904/2332131323/3701645358
|
||||||
identity = proto_types.IdentityType(proto='ssh', user='satoshi', host='bitcoin.org', port='', path='', index=47)
|
identity = proto.IdentityType(proto='ssh', user='satoshi', host='bitcoin.org', port='', path='', index=47)
|
||||||
sig = self.client.sign_identity(identity, hidden, visual, ecdsa_curve_name='ed25519')
|
sig = self.client.sign_identity(identity, hidden, visual, ecdsa_curve_name='ed25519')
|
||||||
self.assertEqual(sig.address, '')
|
self.assertEqual(sig.address, None)
|
||||||
self.assertEqual(binascii.hexlify(sig.public_key), b'000fac2a491e0f5b871dc48288a4cae551bac5cb0ed19df0764d6e721ec5fade18')
|
self.assertEqual(binascii.hexlify(sig.public_key), b'000fac2a491e0f5b871dc48288a4cae551bac5cb0ed19df0764d6e721ec5fade18')
|
||||||
self.assertEqual(binascii.hexlify(sig.signature), b'00f05e5085e666429de397c70a081932654369619c0bd2a6579ea6c1ef2af112ef79998d6c862a16b932d44b1ac1b83c8cbcd0fbda228274fde9e0d0ca6e9cb709')
|
self.assertEqual(binascii.hexlify(sig.signature), b'00f05e5085e666429de397c70a081932654369619c0bd2a6579ea6c1ef2af112ef79998d6c862a16b932d44b1ac1b83c8cbcd0fbda228274fde9e0d0ca6e9cb709')
|
||||||
|
|
|
@ -20,26 +20,26 @@ import unittest
|
||||||
import common
|
import common
|
||||||
import binascii
|
import binascii
|
||||||
|
|
||||||
import trezorlib.types_pb2 as proto_types
|
from trezorlib import messages as proto
|
||||||
|
|
||||||
|
|
||||||
class TestMsgSignmessage(common.TrezorTest):
|
class TestMsgSignmessage(common.TrezorTest):
|
||||||
|
|
||||||
def test_sign(self):
|
def test_sign(self):
|
||||||
self.setup_mnemonic_nopin_nopassphrase()
|
self.setup_mnemonic_nopin_nopassphrase()
|
||||||
sig = self.client.sign_message('Bitcoin', [0], "This is an example of a signed message.", script_type=proto_types.SPENDP2SHWITNESS)
|
sig = self.client.sign_message('Bitcoin', [0], "This is an example of a signed message.", script_type=proto.InputScriptType.SPENDP2SHWITNESS)
|
||||||
self.assertEqual(sig.address, '3CwYaeWxhpXXiHue3ciQez1DLaTEAXcKa1')
|
self.assertEqual(sig.address, '3CwYaeWxhpXXiHue3ciQez1DLaTEAXcKa1')
|
||||||
self.assertEqual(binascii.hexlify(sig.signature), b'249e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80')
|
self.assertEqual(binascii.hexlify(sig.signature), b'249e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80')
|
||||||
|
|
||||||
def test_sign_testnet(self):
|
def test_sign_testnet(self):
|
||||||
self.setup_mnemonic_nopin_nopassphrase()
|
self.setup_mnemonic_nopin_nopassphrase()
|
||||||
sig = self.client.sign_message('Testnet', [0], "This is an example of a signed message.", script_type=proto_types.SPENDP2SHWITNESS)
|
sig = self.client.sign_message('Testnet', [0], "This is an example of a signed message.", script_type=proto.InputScriptType.SPENDP2SHWITNESS)
|
||||||
self.assertEqual(sig.address, '2N4VkePSzKH2sv5YBikLHGvzUYvfPxV6zS9')
|
self.assertEqual(sig.address, '2N4VkePSzKH2sv5YBikLHGvzUYvfPxV6zS9')
|
||||||
self.assertEqual(binascii.hexlify(sig.signature), b'249e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80')
|
self.assertEqual(binascii.hexlify(sig.signature), b'249e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80')
|
||||||
|
|
||||||
def test_sign_long(self):
|
def test_sign_long(self):
|
||||||
self.setup_mnemonic_nopin_nopassphrase()
|
self.setup_mnemonic_nopin_nopassphrase()
|
||||||
sig = self.client.sign_message('Bitcoin', [0], "VeryLongMessage!" * 64, script_type=proto_types.SPENDP2SHWITNESS)
|
sig = self.client.sign_message('Bitcoin', [0], "VeryLongMessage!" * 64, script_type=proto.InputScriptType.SPENDP2SHWITNESS)
|
||||||
self.assertEqual(sig.address, '3CwYaeWxhpXXiHue3ciQez1DLaTEAXcKa1')
|
self.assertEqual(sig.address, '3CwYaeWxhpXXiHue3ciQez1DLaTEAXcKa1')
|
||||||
self.assertEqual(binascii.hexlify(sig.signature), b'245ff795c29aef7538f8b3bdb2e8add0d0722ad630a140b6aefd504a5a895cbd867cbb00981afc50edd0398211e8d7c304bb8efa461181bc0afa67ea4a720a89ed')
|
self.assertEqual(binascii.hexlify(sig.signature), b'245ff795c29aef7538f8b3bdb2e8add0d0722ad630a140b6aefd504a5a895cbd867cbb00981afc50edd0398211e8d7c304bb8efa461181bc0afa67ea4a720a89ed')
|
||||||
|
|
||||||
|
@ -49,10 +49,10 @@ class TestMsgSignmessage(common.TrezorTest):
|
||||||
words_nfkd = u'Pr\u030ci\u0301s\u030cerne\u030c z\u030clut\u030couc\u030cky\u0301 ku\u030an\u030c u\u0301pe\u030cl d\u030ca\u0301belske\u0301 o\u0301dy za\u0301ker\u030cny\u0301 uc\u030cen\u030c be\u030cz\u030ci\u0301 pode\u0301l zo\u0301ny u\u0301lu\u030a'
|
words_nfkd = u'Pr\u030ci\u0301s\u030cerne\u030c z\u030clut\u030couc\u030cky\u0301 ku\u030an\u030c u\u0301pe\u030cl d\u030ca\u0301belske\u0301 o\u0301dy za\u0301ker\u030cny\u0301 uc\u030cen\u030c be\u030cz\u030ci\u0301 pode\u0301l zo\u0301ny u\u0301lu\u030a'
|
||||||
words_nfc = u'P\u0159\xed\u0161ern\u011b \u017elu\u0165ou\u010dk\xfd k\u016f\u0148 \xfap\u011bl \u010f\xe1belsk\xe9 \xf3dy z\xe1ke\u0159n\xfd u\u010de\u0148 b\u011b\u017e\xed pod\xe9l z\xf3ny \xfal\u016f'
|
words_nfc = u'P\u0159\xed\u0161ern\u011b \u017elu\u0165ou\u010dk\xfd k\u016f\u0148 \xfap\u011bl \u010f\xe1belsk\xe9 \xf3dy z\xe1ke\u0159n\xfd u\u010de\u0148 b\u011b\u017e\xed pod\xe9l z\xf3ny \xfal\u016f'
|
||||||
|
|
||||||
sig_nfkd = self.client.sign_message('Bitcoin', [0], words_nfkd, script_type=proto_types.SPENDP2SHWITNESS)
|
sig_nfkd = self.client.sign_message('Bitcoin', [0], words_nfkd, script_type=proto.InputScriptType.SPENDP2SHWITNESS)
|
||||||
self.assertEqual(sig_nfkd.address, '3CwYaeWxhpXXiHue3ciQez1DLaTEAXcKa1')
|
self.assertEqual(sig_nfkd.address, '3CwYaeWxhpXXiHue3ciQez1DLaTEAXcKa1')
|
||||||
self.assertEqual(binascii.hexlify(sig_nfkd.signature), b'24d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6')
|
self.assertEqual(binascii.hexlify(sig_nfkd.signature), b'24d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6')
|
||||||
|
|
||||||
sig_nfc = self.client.sign_message('Bitcoin', [0], words_nfc, script_type=proto_types.SPENDP2SHWITNESS)
|
sig_nfc = self.client.sign_message('Bitcoin', [0], words_nfc, script_type=proto.InputScriptType.SPENDP2SHWITNESS)
|
||||||
self.assertEqual(sig_nfc.address, '3CwYaeWxhpXXiHue3ciQez1DLaTEAXcKa1')
|
self.assertEqual(sig_nfc.address, '3CwYaeWxhpXXiHue3ciQez1DLaTEAXcKa1')
|
||||||
self.assertEqual(binascii.hexlify(sig_nfc.signature), b'24d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6')
|
self.assertEqual(binascii.hexlify(sig_nfc.signature), b'24d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6')
|
||||||
|
|
|
@ -20,26 +20,26 @@ import unittest
|
||||||
import common
|
import common
|
||||||
import binascii
|
import binascii
|
||||||
|
|
||||||
import trezorlib.types_pb2 as proto_types
|
from trezorlib import messages as proto
|
||||||
|
|
||||||
|
|
||||||
class TestMsgSignmessage(common.TrezorTest):
|
class TestMsgSignmessage(common.TrezorTest):
|
||||||
|
|
||||||
def test_sign(self):
|
def test_sign(self):
|
||||||
self.setup_mnemonic_nopin_nopassphrase()
|
self.setup_mnemonic_nopin_nopassphrase()
|
||||||
sig = self.client.sign_message('Bitcoin', [0], "This is an example of a signed message.", script_type=proto_types.SPENDWITNESS)
|
sig = self.client.sign_message('Bitcoin', [0], "This is an example of a signed message.", script_type=proto.InputScriptType.SPENDWITNESS)
|
||||||
self.assertEqual(sig.address, 'bc1qyjjkmdpu7metqt5r36jf872a34syws33s82q2j')
|
self.assertEqual(sig.address, 'bc1qyjjkmdpu7metqt5r36jf872a34syws33s82q2j')
|
||||||
self.assertEqual(binascii.hexlify(sig.signature), b'289e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80')
|
self.assertEqual(binascii.hexlify(sig.signature), b'289e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80')
|
||||||
|
|
||||||
def test_sign_testnet(self):
|
def test_sign_testnet(self):
|
||||||
self.setup_mnemonic_nopin_nopassphrase()
|
self.setup_mnemonic_nopin_nopassphrase()
|
||||||
sig = self.client.sign_message('Testnet', [0], "This is an example of a signed message.", script_type=proto_types.SPENDWITNESS)
|
sig = self.client.sign_message('Testnet', [0], "This is an example of a signed message.", script_type=proto.InputScriptType.SPENDWITNESS)
|
||||||
self.assertEqual(sig.address, 'tb1qyjjkmdpu7metqt5r36jf872a34syws336p3n3p')
|
self.assertEqual(sig.address, 'tb1qyjjkmdpu7metqt5r36jf872a34syws336p3n3p')
|
||||||
self.assertEqual(binascii.hexlify(sig.signature), b'289e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80')
|
self.assertEqual(binascii.hexlify(sig.signature), b'289e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80')
|
||||||
|
|
||||||
def test_sign_long(self):
|
def test_sign_long(self):
|
||||||
self.setup_mnemonic_nopin_nopassphrase()
|
self.setup_mnemonic_nopin_nopassphrase()
|
||||||
sig = self.client.sign_message('Bitcoin', [0], "VeryLongMessage!" * 64, script_type=proto_types.SPENDWITNESS)
|
sig = self.client.sign_message('Bitcoin', [0], "VeryLongMessage!" * 64, script_type=proto.InputScriptType.SPENDWITNESS)
|
||||||
self.assertEqual(sig.address, 'bc1qyjjkmdpu7metqt5r36jf872a34syws33s82q2j')
|
self.assertEqual(sig.address, 'bc1qyjjkmdpu7metqt5r36jf872a34syws33s82q2j')
|
||||||
self.assertEqual(binascii.hexlify(sig.signature), b'285ff795c29aef7538f8b3bdb2e8add0d0722ad630a140b6aefd504a5a895cbd867cbb00981afc50edd0398211e8d7c304bb8efa461181bc0afa67ea4a720a89ed')
|
self.assertEqual(binascii.hexlify(sig.signature), b'285ff795c29aef7538f8b3bdb2e8add0d0722ad630a140b6aefd504a5a895cbd867cbb00981afc50edd0398211e8d7c304bb8efa461181bc0afa67ea4a720a89ed')
|
||||||
|
|
||||||
|
@ -49,10 +49,10 @@ class TestMsgSignmessage(common.TrezorTest):
|
||||||
words_nfkd = u'Pr\u030ci\u0301s\u030cerne\u030c z\u030clut\u030couc\u030cky\u0301 ku\u030an\u030c u\u0301pe\u030cl d\u030ca\u0301belske\u0301 o\u0301dy za\u0301ker\u030cny\u0301 uc\u030cen\u030c be\u030cz\u030ci\u0301 pode\u0301l zo\u0301ny u\u0301lu\u030a'
|
words_nfkd = u'Pr\u030ci\u0301s\u030cerne\u030c z\u030clut\u030couc\u030cky\u0301 ku\u030an\u030c u\u0301pe\u030cl d\u030ca\u0301belske\u0301 o\u0301dy za\u0301ker\u030cny\u0301 uc\u030cen\u030c be\u030cz\u030ci\u0301 pode\u0301l zo\u0301ny u\u0301lu\u030a'
|
||||||
words_nfc = u'P\u0159\xed\u0161ern\u011b \u017elu\u0165ou\u010dk\xfd k\u016f\u0148 \xfap\u011bl \u010f\xe1belsk\xe9 \xf3dy z\xe1ke\u0159n\xfd u\u010de\u0148 b\u011b\u017e\xed pod\xe9l z\xf3ny \xfal\u016f'
|
words_nfc = u'P\u0159\xed\u0161ern\u011b \u017elu\u0165ou\u010dk\xfd k\u016f\u0148 \xfap\u011bl \u010f\xe1belsk\xe9 \xf3dy z\xe1ke\u0159n\xfd u\u010de\u0148 b\u011b\u017e\xed pod\xe9l z\xf3ny \xfal\u016f'
|
||||||
|
|
||||||
sig_nfkd = self.client.sign_message('Bitcoin', [0], words_nfkd, script_type=proto_types.SPENDWITNESS)
|
sig_nfkd = self.client.sign_message('Bitcoin', [0], words_nfkd, script_type=proto.InputScriptType.SPENDWITNESS)
|
||||||
self.assertEqual(sig_nfkd.address, 'bc1qyjjkmdpu7metqt5r36jf872a34syws33s82q2j')
|
self.assertEqual(sig_nfkd.address, 'bc1qyjjkmdpu7metqt5r36jf872a34syws33s82q2j')
|
||||||
self.assertEqual(binascii.hexlify(sig_nfkd.signature), b'28d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6')
|
self.assertEqual(binascii.hexlify(sig_nfkd.signature), b'28d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6')
|
||||||
|
|
||||||
sig_nfc = self.client.sign_message('Bitcoin', [0], words_nfc, script_type=proto_types.SPENDWITNESS)
|
sig_nfc = self.client.sign_message('Bitcoin', [0], words_nfc, script_type=proto.InputScriptType.SPENDWITNESS)
|
||||||
self.assertEqual(sig_nfc.address, 'bc1qyjjkmdpu7metqt5r36jf872a34syws33s82q2j')
|
self.assertEqual(sig_nfc.address, 'bc1qyjjkmdpu7metqt5r36jf872a34syws33s82q2j')
|
||||||
self.assertEqual(binascii.hexlify(sig_nfc.signature), b'28d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6')
|
self.assertEqual(binascii.hexlify(sig_nfc.signature), b'28d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6')
|
||||||
|
|
|
@ -20,8 +20,7 @@ import unittest
|
||||||
import common
|
import common
|
||||||
import binascii
|
import binascii
|
||||||
|
|
||||||
import trezorlib.messages_pb2 as proto
|
from trezorlib import messages as proto
|
||||||
import trezorlib.types_pb2 as proto_types
|
|
||||||
from trezorlib.client import CallException
|
from trezorlib.client import CallException
|
||||||
from trezorlib.tx_api import TxApiTestnet
|
from trezorlib.tx_api import TxApiTestnet
|
||||||
|
|
||||||
|
@ -42,40 +41,39 @@ TXHASH_50f6f1 = binascii.unhexlify('50f6f1209ca92d7359564be803cb2c932cde7d370f7c
|
||||||
|
|
||||||
|
|
||||||
class TestMsgSigntx(common.TrezorTest):
|
class TestMsgSigntx(common.TrezorTest):
|
||||||
|
|
||||||
def test_one_one_fee(self):
|
def test_one_one_fee(self):
|
||||||
self.setup_mnemonic_nopin_nopassphrase()
|
self.setup_mnemonic_nopin_nopassphrase()
|
||||||
|
|
||||||
# tx: d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882
|
# tx: d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882
|
||||||
# input 0: 0.0039 BTC
|
# input 0: 0.0039 BTC
|
||||||
|
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e
|
address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e
|
||||||
# amount=390000,
|
# amount=390000,
|
||||||
prev_hash=TXHASH_d5f65e,
|
prev_hash=TXHASH_d5f65e,
|
||||||
prev_index=0,
|
prev_index=0,
|
||||||
)
|
)
|
||||||
|
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1',
|
address='1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1',
|
||||||
amount=390000 - 10000,
|
amount=390000 - 10000,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=TXHASH_d5f65e)),
|
proto.TxRequest(request_type=proto.RequestType.TXMETA, details=proto.TxRequestDetailsType(tx_hash=TXHASH_d5f65e)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_d5f65e)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_d5f65e)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_d5f65e)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_d5f65e)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_d5f65e)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_d5f65e)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
|
|
||||||
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, ])
|
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, ])
|
||||||
|
@ -89,43 +87,43 @@ class TestMsgSigntx(common.TrezorTest):
|
||||||
|
|
||||||
# tx: e5040e1bc1ae7667ffb9e5248e90b2fb93cd9150234151ce90e14ab2f5933bcd
|
# tx: e5040e1bc1ae7667ffb9e5248e90b2fb93cd9150234151ce90e14ab2f5933bcd
|
||||||
# input 0: 0.31 BTC
|
# input 0: 0.31 BTC
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=self.client.expand_path("44'/1'/0'/0/0"),
|
address_n=self.client.expand_path("44'/1'/0'/0/0"),
|
||||||
# amount=31000000,
|
# amount=31000000,
|
||||||
prev_hash=TXHASH_e5040e,
|
prev_hash=TXHASH_e5040e,
|
||||||
prev_index=0,
|
prev_index=0,
|
||||||
)
|
)
|
||||||
|
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='msj42CCGruhRsFrGATiUuh25dtxYtnpbTx',
|
address='msj42CCGruhRsFrGATiUuh25dtxYtnpbTx',
|
||||||
amount=30090000,
|
amount=30090000,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
|
|
||||||
out2 = proto_types.TxOutputType(
|
out2 = proto.TxOutputType(
|
||||||
address_n=self.client.expand_path("44'/1'/0'/1/0"),
|
address_n=self.client.expand_path("44'/1'/0'/1/0"),
|
||||||
amount=900000,
|
amount=900000,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_tx_api(TxApiTestnet)
|
self.client.set_tx_api(TxApiTestnet)
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=TXHASH_e5040e)),
|
proto.TxRequest(request_type=proto.RequestType.TXMETA, details=proto.TxRequestDetailsType(tx_hash=TXHASH_e5040e)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_e5040e)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_e5040e)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_e5040e)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_e5040e)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_e5040e)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_e5040e)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1, ], [out1, out2])
|
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1, ], [out1, out2])
|
||||||
|
|
||||||
|
@ -136,46 +134,46 @@ class TestMsgSigntx(common.TrezorTest):
|
||||||
|
|
||||||
# tx: 6f90f3c7cbec2258b0971056ef3fe34128dbde30daa9c0639a898f9977299d54
|
# tx: 6f90f3c7cbec2258b0971056ef3fe34128dbde30daa9c0639a898f9977299d54
|
||||||
# input 1: 10.00000000 BTC
|
# input 1: 10.00000000 BTC
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=[0], # mirio8q3gtv7fhdnmb3TpZ4EuafdzSs7zL
|
address_n=[0], # mirio8q3gtv7fhdnmb3TpZ4EuafdzSs7zL
|
||||||
# amount=1000000000,
|
# amount=1000000000,
|
||||||
prev_hash=TXHASH_6f90f3,
|
prev_hash=TXHASH_6f90f3,
|
||||||
prev_index=1,
|
prev_index=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='mfiGQVPcRcaEvQPYDErR34DcCovtxYvUUV',
|
address='mfiGQVPcRcaEvQPYDErR34DcCovtxYvUUV',
|
||||||
amount=1000000000 - 500000000 - 100000000,
|
amount=1000000000 - 500000000 - 100000000,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
|
|
||||||
out2 = proto_types.TxOutputType(
|
out2 = proto.TxOutputType(
|
||||||
address_n=[2],
|
address_n=[2],
|
||||||
amount=500000000,
|
amount=500000000,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_tx_api(TxApiTestnet)
|
self.client.set_tx_api(TxApiTestnet)
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=TXHASH_6f90f3)),
|
proto.TxRequest(request_type=proto.RequestType.TXMETA, details=proto.TxRequestDetailsType(tx_hash=TXHASH_6f90f3)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_6f90f3)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_6f90f3)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_6f90f3)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_6f90f3)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_6f90f3)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_6f90f3)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_6f90f3)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_6f90f3)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_FeeOverThreshold),
|
proto.ButtonRequest(code=proto.ButtonRequestType.FeeOverThreshold),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1, ], [out1, out2])
|
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1, ], [out1, out2])
|
||||||
|
|
||||||
|
@ -186,42 +184,42 @@ class TestMsgSigntx(common.TrezorTest):
|
||||||
|
|
||||||
# tx: c275c333fd1b36bef4af316226c66a8b3693fbfcc081a5e16a2ae5fcb09e92bf
|
# tx: c275c333fd1b36bef4af316226c66a8b3693fbfcc081a5e16a2ae5fcb09e92bf
|
||||||
|
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=self.client.expand_path("m/44'/0'/0'/0/5"), # 1GA9u9TfCG7SWmKCveBumdA1TZpfom6ZdJ
|
address_n=self.client.expand_path("m/44'/0'/0'/0/5"), # 1GA9u9TfCG7SWmKCveBumdA1TZpfom6ZdJ
|
||||||
# amount=50000,
|
# amount=50000,
|
||||||
prev_hash=TXHASH_50f6f1,
|
prev_hash=TXHASH_50f6f1,
|
||||||
prev_index=1,
|
prev_index=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address_n=self.client.expand_path("m/44'/0'/0'/1/3"), # 1EcL6AyfQTyWKGvXwNSfsWoYnD3whzVFdu
|
address_n=self.client.expand_path("m/44'/0'/0'/1/3"), # 1EcL6AyfQTyWKGvXwNSfsWoYnD3whzVFdu
|
||||||
amount=30000,
|
amount=30000,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
|
|
||||||
out2 = proto_types.TxOutputType(
|
out2 = proto.TxOutputType(
|
||||||
address='1Up15Msx4sbvUCGm8Xgo2Zp5FQim3wE59',
|
address='1Up15Msx4sbvUCGm8Xgo2Zp5FQim3wE59',
|
||||||
amount=10000,
|
amount=10000,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=TXHASH_50f6f1)),
|
proto.TxRequest(request_type=proto.RequestType.TXMETA, details=proto.TxRequestDetailsType(tx_hash=TXHASH_50f6f1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_50f6f1)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_50f6f1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_50f6f1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_50f6f1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_50f6f1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_50f6f1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, out2])
|
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, out2])
|
||||||
|
|
||||||
|
@ -233,53 +231,53 @@ class TestMsgSigntx(common.TrezorTest):
|
||||||
# tx: d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882
|
# tx: d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882
|
||||||
# input 0: 0.0039 BTC
|
# input 0: 0.0039 BTC
|
||||||
|
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e
|
address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e
|
||||||
# amount=390000,
|
# amount=390000,
|
||||||
prev_hash=TXHASH_d5f65e,
|
prev_hash=TXHASH_d5f65e,
|
||||||
prev_index=0,
|
prev_index=0,
|
||||||
)
|
)
|
||||||
|
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1',
|
address='1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1',
|
||||||
amount=390000 - 80000 - 12000 - 10000,
|
amount=390000 - 80000 - 12000 - 10000,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
|
|
||||||
out2 = proto_types.TxOutputType(
|
out2 = proto.TxOutputType(
|
||||||
address='13uaUYn6XAooo88QvAqAVsiVvr2mAXutqP',
|
address='13uaUYn6XAooo88QvAqAVsiVvr2mAXutqP',
|
||||||
amount=12000,
|
amount=12000,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
|
|
||||||
out3 = proto_types.TxOutputType(
|
out3 = proto.TxOutputType(
|
||||||
address_n=[1],
|
address_n=[1],
|
||||||
amount=80000,
|
amount=80000,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=TXHASH_d5f65e)),
|
proto.TxRequest(request_type=proto.RequestType.TXMETA, details=proto.TxRequestDetailsType(tx_hash=TXHASH_d5f65e)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_d5f65e)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_d5f65e)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_d5f65e)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_d5f65e)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_d5f65e)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_d5f65e)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=2)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=2)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=2)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=2)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=2)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=2)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, out2, out3])
|
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, out2, out3])
|
||||||
|
|
||||||
|
@ -293,61 +291,61 @@ class TestMsgSigntx(common.TrezorTest):
|
||||||
# tx: 58497a7757224d1ff1941488d23087071103e5bf855f4c1c44e5c8d9d82ca46e
|
# tx: 58497a7757224d1ff1941488d23087071103e5bf855f4c1c44e5c8d9d82ca46e
|
||||||
# input 1: 0.0011 BTC
|
# input 1: 0.0011 BTC
|
||||||
|
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=[1], # 1CK7SJdcb8z9HuvVft3D91HLpLC6KSsGb
|
address_n=[1], # 1CK7SJdcb8z9HuvVft3D91HLpLC6KSsGb
|
||||||
# amount=100000,
|
# amount=100000,
|
||||||
prev_hash=TXHASH_c6be22,
|
prev_hash=TXHASH_c6be22,
|
||||||
prev_index=1,
|
prev_index=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
inp2 = proto_types.TxInputType(
|
inp2 = proto.TxInputType(
|
||||||
address_n=[2], # 15AeAhtNJNKyowK8qPHwgpXkhsokzLtUpG
|
address_n=[2], # 15AeAhtNJNKyowK8qPHwgpXkhsokzLtUpG
|
||||||
# amount=110000,
|
# amount=110000,
|
||||||
prev_hash=TXHASH_58497a,
|
prev_hash=TXHASH_58497a,
|
||||||
prev_index=1,
|
prev_index=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='15Jvu3nZNP7u2ipw2533Q9VVgEu2Lu9F2B',
|
address='15Jvu3nZNP7u2ipw2533Q9VVgEu2Lu9F2B',
|
||||||
amount=210000 - 100000 - 10000,
|
amount=210000 - 100000 - 10000,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
|
|
||||||
out2 = proto_types.TxOutputType(
|
out2 = proto.TxOutputType(
|
||||||
address_n=[3], # 1CmzyJp9w3NafXMSEFH4SLYUPAVCSUrrJ5
|
address_n=[3], # 1CmzyJp9w3NafXMSEFH4SLYUPAVCSUrrJ5
|
||||||
amount=100000,
|
amount=100000,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=TXHASH_c6be22)),
|
proto.TxRequest(request_type=proto.RequestType.TXMETA, details=proto.TxRequestDetailsType(tx_hash=TXHASH_c6be22)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_c6be22)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_c6be22)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_c6be22)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_c6be22)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_c6be22)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_c6be22)),
|
||||||
|
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=TXHASH_58497a)),
|
proto.TxRequest(request_type=proto.RequestType.TXMETA, details=proto.TxRequestDetailsType(tx_hash=TXHASH_58497a)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_58497a)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_58497a)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_58497a)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_58497a)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_58497a)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_58497a)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, inp2], [out1, out2])
|
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, inp2], [out1, out2])
|
||||||
|
|
||||||
|
@ -361,12 +359,12 @@ class TestMsgSigntx(common.TrezorTest):
|
||||||
# tx 4a7b7e0403ae5607e473949cfa03f09f2cd8b0f404bf99ce10b7303d86280bf7 : 100 UTXO for spending for unittests
|
# tx 4a7b7e0403ae5607e473949cfa03f09f2cd8b0f404bf99ce10b7303d86280bf7 : 100 UTXO for spending for unittests
|
||||||
inputs = []
|
inputs = []
|
||||||
for i in range(100):
|
for i in range(100):
|
||||||
inputs.append( proto_types.TxInputType(address_n=[4], # 1NwN6UduuVkJi6sw3gSiKZaCY5rHgVXC2h
|
inputs.append( proto.TxInputType(address_n=[4], # 1NwN6UduuVkJi6sw3gSiKZaCY5rHgVXC2h
|
||||||
prev_hash=TXHASH_4a7b7e,
|
prev_hash=TXHASH_4a7b7e,
|
||||||
prev_index=i) )
|
prev_index=i) )
|
||||||
out = proto_types.TxOutputType(address='19dvDdyxxptP9dGvozYe8BP6tgFV9L4jg5',
|
out = proto.TxOutputType(address='19dvDdyxxptP9dGvozYe8BP6tgFV9L4jg5',
|
||||||
amount=100 * 26000 - 15 * 10000,
|
amount=100 * 26000 - 15 * 10000,
|
||||||
script_type=proto_types.PAYTOADDRESS)
|
script_type=proto.OutputScriptType.PAYTOADDRESS)
|
||||||
with self.client:
|
with self.client:
|
||||||
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', inputs, [out])
|
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', inputs, [out])
|
||||||
# Accepted by network: tx 23d9d8eecf3abf6c0f0f3f8b0976a04792d7f1c9a4ea9b0a8931734949e27c92
|
# Accepted by network: tx 23d9d8eecf3abf6c0f0f3f8b0976a04792d7f1c9a4ea9b0a8931734949e27c92
|
||||||
|
@ -383,14 +381,14 @@ class TestMsgSigntx(common.TrezorTest):
|
||||||
# tx: 39a29e954977662ab3879c66fb251ef753e0912223a83d1dcb009111d28265e5
|
# tx: 39a29e954977662ab3879c66fb251ef753e0912223a83d1dcb009111d28265e5
|
||||||
# index 1: 0.0254 BTC
|
# index 1: 0.0254 BTC
|
||||||
|
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=[3], # 1CmzyJp9w3NafXMSEFH4SLYUPAVCSUrrJ5
|
address_n=[3], # 1CmzyJp9w3NafXMSEFH4SLYUPAVCSUrrJ5
|
||||||
# amount=100000,
|
# amount=100000,
|
||||||
prev_hash=TXHASH_c63e24,
|
prev_hash=TXHASH_c63e24,
|
||||||
prev_index=1,
|
prev_index=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
inp2 = proto_types.TxInputType(
|
inp2 = proto.TxInputType(
|
||||||
address_n=[3], # 1CmzyJp9w3NafXMSEFH4SLYUPAVCSUrrJ5
|
address_n=[3], # 1CmzyJp9w3NafXMSEFH4SLYUPAVCSUrrJ5
|
||||||
# amount=2540000,
|
# amount=2540000,
|
||||||
prev_hash=TXHASH_39a29e,
|
prev_hash=TXHASH_39a29e,
|
||||||
|
@ -400,46 +398,46 @@ class TestMsgSigntx(common.TrezorTest):
|
||||||
outputs = []
|
outputs = []
|
||||||
cnt = 255
|
cnt = 255
|
||||||
for _ in range(cnt):
|
for _ in range(cnt):
|
||||||
out = proto_types.TxOutputType(
|
out = proto.TxOutputType(
|
||||||
address='1NwN6UduuVkJi6sw3gSiKZaCY5rHgVXC2h',
|
address='1NwN6UduuVkJi6sw3gSiKZaCY5rHgVXC2h',
|
||||||
amount=(100000 + 2540000 - 39000) // cnt,
|
amount=(100000 + 2540000 - 39000) // cnt,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
outputs.append(out)
|
outputs.append(out)
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=TXHASH_c63e24)),
|
proto.TxRequest(request_type=proto.RequestType.TXMETA, details=proto.TxRequestDetailsType(tx_hash=TXHASH_c63e24)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_c63e24)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_c63e24)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_c63e24)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_c63e24)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_c63e24)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_c63e24)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_c63e24)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_c63e24)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=TXHASH_39a29e)),
|
proto.TxRequest(request_type=proto.RequestType.TXMETA, details=proto.TxRequestDetailsType(tx_hash=TXHASH_39a29e)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_39a29e)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_39a29e)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_39a29e)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_39a29e)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_39a29e)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_39a29e)),
|
||||||
] + [
|
] + [
|
||||||
item for items in zip(
|
item for items in zip(
|
||||||
[proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=I)) for I in range(cnt)],
|
[proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=I)) for I in range(cnt)],
|
||||||
[proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput)] * cnt
|
[proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput)] * cnt
|
||||||
) for item in items
|
) for item in items
|
||||||
] + [
|
] + [
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
] + [
|
] + [
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=I)) for I in range(cnt)
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=I)) for I in range(cnt)
|
||||||
] + [
|
] + [
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
] + [
|
] + [
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=I)) for I in range(cnt)
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=I)) for I in range(cnt)
|
||||||
] + [
|
] + [
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=I)) for I in range(cnt)
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=I)) for I in range(cnt)
|
||||||
] + [
|
] + [
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, inp2], outputs)
|
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, inp2], outputs)
|
||||||
|
|
||||||
|
@ -452,34 +450,34 @@ class TestMsgSigntx(common.TrezorTest):
|
||||||
# tx: 1570416eb4302cf52979afd5e6909e37d8fdd874301f7cc87e547e509cb1caa6
|
# tx: 1570416eb4302cf52979afd5e6909e37d8fdd874301f7cc87e547e509cb1caa6
|
||||||
# input 0: 1.0 BTC
|
# input 0: 1.0 BTC
|
||||||
|
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=[0], # 1HWDaLTpTCTtRWyWqZkzWx1wex5NKyncLW
|
address_n=[0], # 1HWDaLTpTCTtRWyWqZkzWx1wex5NKyncLW
|
||||||
# amount=100000000,
|
# amount=100000000,
|
||||||
prev_hash=TXHASH_157041,
|
prev_hash=TXHASH_157041,
|
||||||
prev_index=0,
|
prev_index=0,
|
||||||
)
|
)
|
||||||
|
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1',
|
address='1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1',
|
||||||
amount=100000000 - 510000,
|
amount=100000000 - 510000,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=TXHASH_157041)),
|
proto.TxRequest(request_type=proto.RequestType.TXMETA, details=proto.TxRequestDetailsType(tx_hash=TXHASH_157041)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_157041)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_157041)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_157041)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_157041)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_157041)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_157041)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_FeeOverThreshold),
|
proto.ButtonRequest(code=proto.ButtonRequestType.FeeOverThreshold),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, ])
|
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, ])
|
||||||
|
|
||||||
|
@ -491,68 +489,68 @@ class TestMsgSigntx(common.TrezorTest):
|
||||||
# tx: d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882
|
# tx: d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882
|
||||||
# input 0: 0.0039 BTC
|
# input 0: 0.0039 BTC
|
||||||
|
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e
|
address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e
|
||||||
# amount=390000,
|
# amount=390000,
|
||||||
prev_hash=TXHASH_d5f65e,
|
prev_hash=TXHASH_d5f65e,
|
||||||
prev_index=0,
|
prev_index=0,
|
||||||
)
|
)
|
||||||
|
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1',
|
address='1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1',
|
||||||
amount=400000,
|
amount=400000,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=TXHASH_d5f65e)),
|
proto.TxRequest(request_type=proto.RequestType.TXMETA, details=proto.TxRequestDetailsType(tx_hash=TXHASH_d5f65e)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_d5f65e)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_d5f65e)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_d5f65e)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_d5f65e)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_d5f65e)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_d5f65e)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.Failure(code=proto_types.Failure_NotEnoughFunds)
|
proto.Failure(code=proto.FailureType.NotEnoughFunds)
|
||||||
])
|
])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.client.sign_tx('Bitcoin', [inp1, ], [out1, ])
|
self.client.sign_tx('Bitcoin', [inp1, ], [out1, ])
|
||||||
except CallException as e:
|
except CallException as e:
|
||||||
self.assertEqual(e.args[0], proto_types.Failure_NotEnoughFunds)
|
self.assertEqual(e.args[0], proto.FailureType.NotEnoughFunds)
|
||||||
else:
|
else:
|
||||||
self.assert_(False, "types.Failure_NotEnoughFunds expected")
|
self.assert_(False, "types.FailureType.NotEnoughFunds expected")
|
||||||
|
|
||||||
def test_p2sh(self):
|
def test_p2sh(self):
|
||||||
self.setup_mnemonic_nopin_nopassphrase()
|
self.setup_mnemonic_nopin_nopassphrase()
|
||||||
|
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e
|
address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e
|
||||||
# amount=400000,
|
# amount=400000,
|
||||||
prev_hash=TXHASH_54aa56,
|
prev_hash=TXHASH_54aa56,
|
||||||
prev_index=1,
|
prev_index=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='3DKGE1pvPpBAgZj94MbCinwmksewUNNYVR', # p2sh
|
address='3DKGE1pvPpBAgZj94MbCinwmksewUNNYVR', # p2sh
|
||||||
amount=400000 - 10000,
|
amount=400000 - 10000,
|
||||||
script_type=proto_types.PAYTOSCRIPTHASH,
|
script_type=proto.OutputScriptType.PAYTOSCRIPTHASH,
|
||||||
)
|
)
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=TXHASH_54aa56)),
|
proto.TxRequest(request_type=proto.RequestType.TXMETA, details=proto.TxRequestDetailsType(tx_hash=TXHASH_54aa56)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_54aa56)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_54aa56)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_54aa56)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_54aa56)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_54aa56)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_54aa56)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, ])
|
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, ])
|
||||||
|
|
||||||
|
@ -570,30 +568,30 @@ class TestMsgSigntx(common.TrezorTest):
|
||||||
|
|
||||||
self.setup_mnemonic_nopin_nopassphrase()
|
self.setup_mnemonic_nopin_nopassphrase()
|
||||||
|
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=[1], # 1CK7SJdcb8z9HuvVft3D91HLpLC6KSsGb
|
address_n=[1], # 1CK7SJdcb8z9HuvVft3D91HLpLC6KSsGb
|
||||||
# amount=100000,
|
# amount=100000,
|
||||||
prev_hash=TXHASH_c6be22,
|
prev_hash=TXHASH_c6be22,
|
||||||
prev_index=1,
|
prev_index=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
inp2 = proto_types.TxInputType(
|
inp2 = proto.TxInputType(
|
||||||
address_n=[2], # 15AeAhtNJNKyowK8qPHwgpXkhsokzLtUpG
|
address_n=[2], # 15AeAhtNJNKyowK8qPHwgpXkhsokzLtUpG
|
||||||
# amount=110000,
|
# amount=110000,
|
||||||
prev_hash=TXHASH_58497a,
|
prev_hash=TXHASH_58497a,
|
||||||
prev_index=1,
|
prev_index=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='15Jvu3nZNP7u2ipw2533Q9VVgEu2Lu9F2B',
|
address='15Jvu3nZNP7u2ipw2533Q9VVgEu2Lu9F2B',
|
||||||
amount=210000 - 100000 - 10000,
|
amount=210000 - 100000 - 10000,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
|
|
||||||
out2 = proto_types.TxOutputType(
|
out2 = proto.TxOutputType(
|
||||||
address_n=[3], # 1CmzyJp9w3NafXMSEFH4SLYUPAVCSUrrJ5
|
address_n=[3], # 1CmzyJp9w3NafXMSEFH4SLYUPAVCSUrrJ5
|
||||||
amount=100000,
|
amount=100000,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
|
|
||||||
global run_attack
|
global run_attack
|
||||||
|
@ -602,7 +600,7 @@ class TestMsgSigntx(common.TrezorTest):
|
||||||
def attack_processor(req, msg):
|
def attack_processor(req, msg):
|
||||||
global run_attack
|
global run_attack
|
||||||
|
|
||||||
if req.details.tx_hash != b'':
|
if req.details.tx_hash is not None:
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
if req.details.request_index != 1:
|
if req.details.request_index != 1:
|
||||||
|
@ -631,24 +629,24 @@ class TestMsgSigntx(common.TrezorTest):
|
||||||
self.setup_mnemonic_allallall()
|
self.setup_mnemonic_allallall()
|
||||||
self.client.set_tx_api(TxApiTestnet)
|
self.client.set_tx_api(TxApiTestnet)
|
||||||
|
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=self.client.expand_path("44'/1'/4'/0/0"),
|
address_n=self.client.expand_path("44'/1'/4'/0/0"),
|
||||||
# moUJnmge8SRXuediK7bW6t4YfrPqbE6hD7
|
# moUJnmge8SRXuediK7bW6t4YfrPqbE6hD7
|
||||||
prev_hash=TXHASH_d2dcda,
|
prev_hash=TXHASH_d2dcda,
|
||||||
prev_index=1,
|
prev_index=1,
|
||||||
script_type=proto_types.SPENDADDRESS,
|
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||||
)
|
)
|
||||||
|
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='mwue7mokpBRAsJtHqEMcRPanYBmsSmYKvY',
|
address='mwue7mokpBRAsJtHqEMcRPanYBmsSmYKvY',
|
||||||
amount=100000,
|
amount=100000,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
|
|
||||||
out2 = proto_types.TxOutputType(
|
out2 = proto.TxOutputType(
|
||||||
address_n=self.client.expand_path("44'/1'/12345'/1/0"),
|
address_n=self.client.expand_path("44'/1'/12345'/1/0"),
|
||||||
amount=123400000 - 5000 - 100000,
|
amount=123400000 - 5000 - 100000,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
|
|
||||||
global run_attack
|
global run_attack
|
||||||
|
@ -658,10 +656,10 @@ class TestMsgSigntx(common.TrezorTest):
|
||||||
import sys
|
import sys
|
||||||
global run_attack
|
global run_attack
|
||||||
|
|
||||||
if req.details.tx_hash != b'':
|
if req.details.tx_hash is not None:
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
if req.request_type != proto_types.TXINPUT:
|
if req.request_type != proto.RequestType.TXINPUT:
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
if req.details.request_index != 0:
|
if req.details.request_index != 0:
|
||||||
|
@ -682,17 +680,17 @@ class TestMsgSigntx(common.TrezorTest):
|
||||||
# Now run the attack, must trigger the exception
|
# Now run the attack, must trigger the exception
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=TXHASH_d2dcda)),
|
proto.TxRequest(request_type=proto.RequestType.TXMETA, details=proto.TxRequestDetailsType(tx_hash=TXHASH_d2dcda)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_d2dcda)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_d2dcda)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_d2dcda)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_d2dcda)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_d2dcda)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_d2dcda)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.Failure(code=proto_types.Failure_ProcessError),
|
proto.Failure(code=proto.FailureType.ProcessError),
|
||||||
])
|
])
|
||||||
self.assertRaises(CallException, self.client.sign_tx, 'Testnet', [inp1], [out1, out2], debug_processor=attack_processor)
|
self.assertRaises(CallException, self.client.sign_tx, 'Testnet', [inp1], [out1, out2], debug_processor=attack_processor)
|
||||||
|
|
||||||
|
@ -703,33 +701,33 @@ class TestMsgSigntx(common.TrezorTest):
|
||||||
|
|
||||||
self.setup_mnemonic_nopin_nopassphrase()
|
self.setup_mnemonic_nopin_nopassphrase()
|
||||||
|
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=[1], # mfiGQVPcRcaEvQPYDErR34DcCovtxYvUUV
|
address_n=[1], # mfiGQVPcRcaEvQPYDErR34DcCovtxYvUUV
|
||||||
# amount=390000,
|
# amount=390000,
|
||||||
prev_hash=TXHASH_d6da21,
|
prev_hash=TXHASH_d6da21,
|
||||||
prev_index=0,
|
prev_index=0,
|
||||||
)
|
)
|
||||||
|
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='mm6FM31rM5Vc3sw5D7kztiBg3jHUzyqF1g',
|
address='mm6FM31rM5Vc3sw5D7kztiBg3jHUzyqF1g',
|
||||||
amount=2500278230 - 10000,
|
amount=2500278230 - 10000,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_tx_api(TxApiTestnet)
|
self.client.set_tx_api(TxApiTestnet)
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=TXHASH_d6da21)),
|
proto.TxRequest(request_type=proto.RequestType.TXMETA, details=proto.TxRequestDetailsType(tx_hash=TXHASH_d6da21)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_d6da21)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_d6da21)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_d6da21)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_d6da21)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1, ], [out1, ])
|
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1, ], [out1, ])
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,7 @@ import unittest
|
||||||
import common
|
import common
|
||||||
import binascii
|
import binascii
|
||||||
|
|
||||||
import trezorlib.messages_pb2 as proto
|
from trezorlib import messages as proto
|
||||||
import trezorlib.types_pb2 as proto_types
|
|
||||||
from trezorlib.tx_api import TxApiInsight
|
from trezorlib.tx_api import TxApiInsight
|
||||||
from trezorlib.ckd_public import deserialize
|
from trezorlib.ckd_public import deserialize
|
||||||
from trezorlib.client import CallException
|
from trezorlib.client import CallException
|
||||||
|
@ -33,35 +32,35 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||||
def test_send_bch_change(self):
|
def test_send_bch_change(self):
|
||||||
self.setup_mnemonic_allallall()
|
self.setup_mnemonic_allallall()
|
||||||
self.client.set_tx_api(TxApiBitcoinCash)
|
self.client.set_tx_api(TxApiBitcoinCash)
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=self.client.expand_path("44'/145'/0'/0/0"),
|
address_n=self.client.expand_path("44'/145'/0'/0/0"),
|
||||||
# 1MH9KKcvdCTY44xVDC2k3fjBbX5Cz29N1q
|
# 1MH9KKcvdCTY44xVDC2k3fjBbX5Cz29N1q
|
||||||
amount=1995344,
|
amount=1995344,
|
||||||
prev_hash=binascii.unhexlify('bc37c28dfb467d2ecb50261387bf752a3977d7e5337915071bb4151e6b711a78'),
|
prev_hash=binascii.unhexlify('bc37c28dfb467d2ecb50261387bf752a3977d7e5337915071bb4151e6b711a78'),
|
||||||
prev_index=0,
|
prev_index=0,
|
||||||
script_type=proto_types.SPENDADDRESS,
|
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||||
)
|
)
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address_n=self.client.expand_path("44'/145'/0'/1/0"),
|
address_n=self.client.expand_path("44'/145'/0'/1/0"),
|
||||||
amount=1896050,
|
amount=1896050,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
out2 = proto_types.TxOutputType(
|
out2 = proto.TxOutputType(
|
||||||
address='1LRspCZNFJcbuNKQkXgHMDucctFRQya5a3',
|
address='1LRspCZNFJcbuNKQkXgHMDucctFRQya5a3',
|
||||||
amount=73452,
|
amount=73452,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
(signatures, serialized_tx) = self.client.sign_tx('Bcash', [inp1], [out1, out2])
|
(signatures, serialized_tx) = self.client.sign_tx('Bcash', [inp1], [out1, out2])
|
||||||
|
|
||||||
|
@ -70,38 +69,38 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||||
def test_send_bch_nochange(self):
|
def test_send_bch_nochange(self):
|
||||||
self.setup_mnemonic_allallall()
|
self.setup_mnemonic_allallall()
|
||||||
self.client.set_tx_api(TxApiBitcoinCash)
|
self.client.set_tx_api(TxApiBitcoinCash)
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=self.client.expand_path("44'/145'/0'/1/0"),
|
address_n=self.client.expand_path("44'/145'/0'/1/0"),
|
||||||
# 1HADRPJpgqBzThepERpVXNi6qRgiLQRNoE
|
# 1HADRPJpgqBzThepERpVXNi6qRgiLQRNoE
|
||||||
amount=1896050,
|
amount=1896050,
|
||||||
prev_hash=binascii.unhexlify('502e8577b237b0152843a416f8f1ab0c63321b1be7a8cad7bf5c5c216fcf062c'),
|
prev_hash=binascii.unhexlify('502e8577b237b0152843a416f8f1ab0c63321b1be7a8cad7bf5c5c216fcf062c'),
|
||||||
prev_index=0,
|
prev_index=0,
|
||||||
script_type=proto_types.SPENDADDRESS,
|
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||||
)
|
)
|
||||||
inp2 = proto_types.TxInputType(
|
inp2 = proto.TxInputType(
|
||||||
address_n=self.client.expand_path("44'/145'/0'/0/1"),
|
address_n=self.client.expand_path("44'/145'/0'/0/1"),
|
||||||
# 1LRspCZNFJcbuNKQkXgHMDucctFRQya5a3
|
# 1LRspCZNFJcbuNKQkXgHMDucctFRQya5a3
|
||||||
amount=73452,
|
amount=73452,
|
||||||
prev_hash=binascii.unhexlify('502e8577b237b0152843a416f8f1ab0c63321b1be7a8cad7bf5c5c216fcf062c'),
|
prev_hash=binascii.unhexlify('502e8577b237b0152843a416f8f1ab0c63321b1be7a8cad7bf5c5c216fcf062c'),
|
||||||
prev_index=1,
|
prev_index=1,
|
||||||
script_type=proto_types.SPENDADDRESS,
|
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||||
)
|
)
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='15pnEDZJo3ycPUamqP3tEDnEju1oW5fBCz',
|
address='15pnEDZJo3ycPUamqP3tEDnEju1oW5fBCz',
|
||||||
amount=1934960,
|
amount=1934960,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
(signatures, serialized_tx) = self.client.sign_tx('Bcash', [inp1, inp2], [out1])
|
(signatures, serialized_tx) = self.client.sign_tx('Bcash', [inp1, inp2], [out1])
|
||||||
|
|
||||||
|
@ -110,26 +109,26 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||||
def test_attack_amount(self):
|
def test_attack_amount(self):
|
||||||
self.setup_mnemonic_allallall()
|
self.setup_mnemonic_allallall()
|
||||||
self.client.set_tx_api(TxApiBitcoinCash)
|
self.client.set_tx_api(TxApiBitcoinCash)
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=self.client.expand_path("44'/145'/0'/1/0"),
|
address_n=self.client.expand_path("44'/145'/0'/1/0"),
|
||||||
# 1HADRPJpgqBzThepERpVXNi6qRgiLQRNoE
|
# 1HADRPJpgqBzThepERpVXNi6qRgiLQRNoE
|
||||||
amount=1896050 - 1,
|
amount=1896050 - 1,
|
||||||
prev_hash=binascii.unhexlify('502e8577b237b0152843a416f8f1ab0c63321b1be7a8cad7bf5c5c216fcf062c'),
|
prev_hash=binascii.unhexlify('502e8577b237b0152843a416f8f1ab0c63321b1be7a8cad7bf5c5c216fcf062c'),
|
||||||
prev_index=0,
|
prev_index=0,
|
||||||
script_type=proto_types.SPENDADDRESS,
|
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||||
)
|
)
|
||||||
inp2 = proto_types.TxInputType(
|
inp2 = proto.TxInputType(
|
||||||
address_n=self.client.expand_path("44'/145'/0'/0/1"),
|
address_n=self.client.expand_path("44'/145'/0'/0/1"),
|
||||||
# 1LRspCZNFJcbuNKQkXgHMDucctFRQya5a3
|
# 1LRspCZNFJcbuNKQkXgHMDucctFRQya5a3
|
||||||
amount=73452,
|
amount=73452,
|
||||||
prev_hash=binascii.unhexlify('502e8577b237b0152843a416f8f1ab0c63321b1be7a8cad7bf5c5c216fcf062c'),
|
prev_hash=binascii.unhexlify('502e8577b237b0152843a416f8f1ab0c63321b1be7a8cad7bf5c5c216fcf062c'),
|
||||||
prev_index=1,
|
prev_index=1,
|
||||||
script_type=proto_types.SPENDADDRESS,
|
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||||
)
|
)
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='15pnEDZJo3ycPUamqP3tEDnEju1oW5fBCz',
|
address='15pnEDZJo3ycPUamqP3tEDnEju1oW5fBCz',
|
||||||
amount=1934960,
|
amount=1934960,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
|
|
||||||
global run_attack
|
global run_attack
|
||||||
|
@ -139,10 +138,10 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||||
import sys
|
import sys
|
||||||
global run_attack
|
global run_attack
|
||||||
|
|
||||||
if req.details.tx_hash != b'':
|
if req.details.tx_hash is not None:
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
if req.request_type != proto_types.TXINPUT:
|
if req.request_type != proto.RequestType.TXINPUT:
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
if req.details.request_index != 0:
|
if req.details.request_index != 0:
|
||||||
|
@ -157,36 +156,36 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.Failure(code=proto_types.Failure_ProcessError),
|
proto.Failure(code=proto.FailureType.ProcessError),
|
||||||
])
|
])
|
||||||
self.assertRaises(CallException, self.client.sign_tx, 'Bcash', [inp1, inp2], [out1], 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):
|
def test_attack_change_input(self):
|
||||||
self.setup_mnemonic_allallall()
|
self.setup_mnemonic_allallall()
|
||||||
self.client.set_tx_api(TxApiBitcoinCash)
|
self.client.set_tx_api(TxApiBitcoinCash)
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=self.client.expand_path("44'/145'/1000'/0/0"),
|
address_n=self.client.expand_path("44'/145'/1000'/0/0"),
|
||||||
# 1MH9KKcvdCTY44xVDC2k3fjBbX5Cz29N1q
|
# 1MH9KKcvdCTY44xVDC2k3fjBbX5Cz29N1q
|
||||||
amount=1995344,
|
amount=1995344,
|
||||||
prev_hash=binascii.unhexlify('bc37c28dfb467d2ecb50261387bf752a3977d7e5337915071bb4151e6b711a78'),
|
prev_hash=binascii.unhexlify('bc37c28dfb467d2ecb50261387bf752a3977d7e5337915071bb4151e6b711a78'),
|
||||||
prev_index=0,
|
prev_index=0,
|
||||||
script_type=proto_types.SPENDADDRESS,
|
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||||
)
|
)
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address_n=self.client.expand_path("44'/145'/1000'/1/0"),
|
address_n=self.client.expand_path("44'/145'/1000'/1/0"),
|
||||||
amount=1896050,
|
amount=1896050,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
out2 = proto_types.TxOutputType(
|
out2 = proto.TxOutputType(
|
||||||
address='1LRspCZNFJcbuNKQkXgHMDucctFRQya5a3',
|
address='1LRspCZNFJcbuNKQkXgHMDucctFRQya5a3',
|
||||||
amount=73452,
|
amount=73452,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
|
|
||||||
global attack_ctr
|
global attack_ctr
|
||||||
|
@ -196,10 +195,10 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||||
import sys
|
import sys
|
||||||
global attack_ctr
|
global attack_ctr
|
||||||
|
|
||||||
if req.details.tx_hash != b'':
|
if req.details.tx_hash is not None:
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
if req.request_type != proto_types.TXINPUT:
|
if req.request_type != proto.RequestType.TXINPUT:
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
attack_ctr += 1
|
attack_ctr += 1
|
||||||
|
@ -211,13 +210,13 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.Failure(code=proto_types.Failure_ProcessError),
|
proto.Failure(code=proto.FailureType.ProcessError),
|
||||||
])
|
])
|
||||||
self.assertRaises(CallException, self.client.sign_tx, 'Bcash', [inp1], [out1, out2], debug_processor=attack_processor)
|
self.assertRaises(CallException, self.client.sign_tx, 'Bcash', [inp1], [out1, out2], debug_processor=attack_processor)
|
||||||
|
|
||||||
|
@ -229,46 +228,46 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||||
xpubs.append(n.xpub)
|
xpubs.append(n.xpub)
|
||||||
|
|
||||||
def getmultisig(chain, nr, signatures=[b'', b'', b''], xpubs=xpubs):
|
def getmultisig(chain, nr, signatures=[b'', b'', b''], xpubs=xpubs):
|
||||||
return proto_types.MultisigRedeemScriptType(
|
return proto.MultisigRedeemScriptType(
|
||||||
pubkeys=map(lambda xpub: proto_types.HDNodePathType(node=deserialize(xpub), address_n=[chain, nr]), xpubs),
|
pubkeys=list(map(lambda xpub: proto.HDNodePathType(node=deserialize(xpub), address_n=[chain, nr]), xpubs)),
|
||||||
signatures=signatures,
|
signatures=signatures,
|
||||||
m=2,
|
m=2,
|
||||||
)
|
)
|
||||||
correcthorse = proto_types.HDNodeType(
|
correcthorse = proto.HDNodeType(
|
||||||
depth=1, fingerprint=0, child_num=0,
|
depth=1, fingerprint=0, child_num=0,
|
||||||
chain_code=binascii.unhexlify('0000000000000000000000000000000000000000000000000000000000000000'),
|
chain_code=binascii.unhexlify('0000000000000000000000000000000000000000000000000000000000000000'),
|
||||||
public_key=binascii.unhexlify('0378d430274f8c5ec1321338151e9f27f4c676a008bdf8638d07c0b6be9ab35c71'))
|
public_key=binascii.unhexlify('0378d430274f8c5ec1321338151e9f27f4c676a008bdf8638d07c0b6be9ab35c71'))
|
||||||
sig = binascii.unhexlify(b'304402207274b5a4d15e75f3df7319a375557b0efba9b27bc63f9f183a17da95a6125c94022000efac57629f1522e2d3958430e2ef073b0706cfac06cce492651b79858f09ae')
|
sig = binascii.unhexlify(b'304402207274b5a4d15e75f3df7319a375557b0efba9b27bc63f9f183a17da95a6125c94022000efac57629f1522e2d3958430e2ef073b0706cfac06cce492651b79858f09ae')
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=self.client.expand_path("44'/145'/1'/1/0"),
|
address_n=self.client.expand_path("44'/145'/1'/1/0"),
|
||||||
multisig=getmultisig(1, 0, [b'', sig, b'']),
|
multisig=getmultisig(1, 0, [b'', sig, b'']),
|
||||||
# 3CPtPpL5mGAPdxUeUDfm2RNdWoSN9dKpXE
|
# 3CPtPpL5mGAPdxUeUDfm2RNdWoSN9dKpXE
|
||||||
amount=24000,
|
amount=24000,
|
||||||
prev_hash=binascii.unhexlify('f68caf10df12d5b07a34601d88fa6856c6edcbf4d05ebef3486510ae1c293d5f'),
|
prev_hash=binascii.unhexlify('f68caf10df12d5b07a34601d88fa6856c6edcbf4d05ebef3486510ae1c293d5f'),
|
||||||
prev_index=1,
|
prev_index=1,
|
||||||
script_type=proto_types.SPENDMULTISIG,
|
script_type=proto.InputScriptType.SPENDMULTISIG,
|
||||||
)
|
)
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address_n=self.client.expand_path("44'/145'/1'/1/1"),
|
address_n=self.client.expand_path("44'/145'/1'/1/1"),
|
||||||
multisig=proto_types.MultisigRedeemScriptType(
|
multisig=proto.MultisigRedeemScriptType(
|
||||||
pubkeys=[proto_types.HDNodePathType(node=deserialize(xpubs[0]), address_n=[1, 1]),
|
pubkeys=[proto.HDNodePathType(node=deserialize(xpubs[0]), address_n=[1, 1]),
|
||||||
proto_types.HDNodePathType(node=correcthorse, address_n=[]),
|
proto.HDNodePathType(node=correcthorse, address_n=[]),
|
||||||
proto_types.HDNodePathType(node=correcthorse, address_n=[])],
|
proto.HDNodePathType(node=correcthorse, address_n=[])],
|
||||||
signatures=[b'', b'', b''],
|
signatures=[b'', b'', b''],
|
||||||
m=2,
|
m=2,
|
||||||
),
|
),
|
||||||
script_type=proto_types.PAYTOMULTISIG,
|
script_type=proto.OutputScriptType.PAYTOMULTISIG,
|
||||||
amount=23000
|
amount=23000
|
||||||
)
|
)
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
(signatures1, serialized_tx) = self.client.sign_tx('Bcash', [inp1], [out1])
|
(signatures1, serialized_tx) = self.client.sign_tx('Bcash', [inp1], [out1])
|
||||||
self.assertEqual(binascii.hexlify(signatures1[0]), b'3044022052ccf022b3684ecce9f961ce8828387b97267c86bedf0ce16a24bf014e62e42c022035d315ddbeeef7ab3456bd09aed8b625ea58852216b60e4b84ba9f85827d305c')
|
self.assertEqual(binascii.hexlify(signatures1[0]), b'3044022052ccf022b3684ecce9f961ce8828387b97267c86bedf0ce16a24bf014e62e42c022035d315ddbeeef7ab3456bd09aed8b625ea58852216b60e4b84ba9f85827d305c')
|
||||||
|
@ -282,69 +281,69 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||||
xpubs.append(n.xpub)
|
xpubs.append(n.xpub)
|
||||||
|
|
||||||
def getmultisig(chain, nr, signatures=[b'', b'', b''], xpubs=xpubs):
|
def getmultisig(chain, nr, signatures=[b'', b'', b''], xpubs=xpubs):
|
||||||
return proto_types.MultisigRedeemScriptType(
|
return proto.MultisigRedeemScriptType(
|
||||||
pubkeys=map(lambda xpub: proto_types.HDNodePathType(node=deserialize(xpub), address_n=[chain, nr]), xpubs),
|
pubkeys=list(map(lambda xpub: proto.HDNodePathType(node=deserialize(xpub), address_n=[chain, nr]), xpubs)),
|
||||||
signatures=signatures,
|
signatures=signatures,
|
||||||
m=2,
|
m=2,
|
||||||
)
|
)
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=self.client.expand_path("44'/145'/3'/0/0"),
|
address_n=self.client.expand_path("44'/145'/3'/0/0"),
|
||||||
multisig=getmultisig(0, 0),
|
multisig=getmultisig(0, 0),
|
||||||
# 33Ju286QvonBz5N1V754ZekQv4GLJqcc5R
|
# 33Ju286QvonBz5N1V754ZekQv4GLJqcc5R
|
||||||
amount=48490,
|
amount=48490,
|
||||||
prev_hash=binascii.unhexlify('8b6db9b8ba24235d86b053ea2ccb484fc32b96f89c3c39f98d86f90db16076a0'),
|
prev_hash=binascii.unhexlify('8b6db9b8ba24235d86b053ea2ccb484fc32b96f89c3c39f98d86f90db16076a0'),
|
||||||
prev_index=0,
|
prev_index=0,
|
||||||
script_type=proto_types.SPENDMULTISIG,
|
script_type=proto.InputScriptType.SPENDMULTISIG,
|
||||||
)
|
)
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='113Q5hHQNQ3bc1RpPX6UNw4GAXstyeA3Dk',
|
address='113Q5hHQNQ3bc1RpPX6UNw4GAXstyeA3Dk',
|
||||||
amount=24000,
|
amount=24000,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
out2 = proto_types.TxOutputType(
|
out2 = proto.TxOutputType(
|
||||||
address_n=self.client.expand_path("44'/145'/3'/1/0"),
|
address_n=self.client.expand_path("44'/145'/3'/1/0"),
|
||||||
multisig=getmultisig(1, 0),
|
multisig=getmultisig(1, 0),
|
||||||
script_type=proto_types.PAYTOMULTISIG,
|
script_type=proto.OutputScriptType.PAYTOMULTISIG,
|
||||||
amount=24000
|
amount=24000
|
||||||
)
|
)
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
(signatures1, serialized_tx) = self.client.sign_tx('Bcash', [inp1], [out1, out2])
|
(signatures1, serialized_tx) = self.client.sign_tx('Bcash', [inp1], [out1, out2])
|
||||||
|
|
||||||
self.assertEqual(binascii.hexlify(signatures1[0]), b'3045022100bcb1a7134a13025a06052546ee1c6ac3640a0abd2d130190ed13ed7fcb43e9cd02207c381478e2ee123c850425bfbf6d3c691230eb37e333832cb32a1ed3f2cd9e85')
|
self.assertEqual(binascii.hexlify(signatures1[0]), b'3045022100bcb1a7134a13025a06052546ee1c6ac3640a0abd2d130190ed13ed7fcb43e9cd02207c381478e2ee123c850425bfbf6d3c691230eb37e333832cb32a1ed3f2cd9e85')
|
||||||
|
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=self.client.expand_path("44'/145'/1'/0/0"),
|
address_n=self.client.expand_path("44'/145'/1'/0/0"),
|
||||||
multisig=getmultisig(0, 0, [b'', b'', signatures1[0]]),
|
multisig=getmultisig(0, 0, [b'', b'', signatures1[0]]),
|
||||||
# 33Ju286QvonBz5N1V754ZekQv4GLJqcc5R
|
# 33Ju286QvonBz5N1V754ZekQv4GLJqcc5R
|
||||||
amount=48490,
|
amount=48490,
|
||||||
prev_hash=binascii.unhexlify('8b6db9b8ba24235d86b053ea2ccb484fc32b96f89c3c39f98d86f90db16076a0'),
|
prev_hash=binascii.unhexlify('8b6db9b8ba24235d86b053ea2ccb484fc32b96f89c3c39f98d86f90db16076a0'),
|
||||||
prev_index=0,
|
prev_index=0,
|
||||||
script_type=proto_types.SPENDMULTISIG,
|
script_type=proto.InputScriptType.SPENDMULTISIG,
|
||||||
)
|
)
|
||||||
out2.address_n[2] = 1 + 0x80000000
|
out2.address_n[2] = 1 + 0x80000000
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
(signatures1, serialized_tx) = self.client.sign_tx('Bcash', [inp1], [out1, out2])
|
(signatures1, serialized_tx) = self.client.sign_tx('Bcash', [inp1], [out1, out2])
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,7 @@ import unittest
|
||||||
import common
|
import common
|
||||||
import binascii
|
import binascii
|
||||||
|
|
||||||
import trezorlib.messages_pb2 as proto
|
from trezorlib import messages as proto
|
||||||
import trezorlib.types_pb2 as proto_types
|
|
||||||
from trezorlib.tx_api import TxApiTestnet
|
from trezorlib.tx_api import TxApiTestnet
|
||||||
from trezorlib.ckd_public import deserialize
|
from trezorlib.ckd_public import deserialize
|
||||||
from trezorlib.client import CallException
|
from trezorlib.client import CallException
|
||||||
|
@ -31,37 +30,37 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||||
def test_send_p2sh(self):
|
def test_send_p2sh(self):
|
||||||
self.setup_mnemonic_allallall()
|
self.setup_mnemonic_allallall()
|
||||||
self.client.set_tx_api(TxApiTestnet)
|
self.client.set_tx_api(TxApiTestnet)
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=self.client.expand_path("49'/1'/0'/1/0"),
|
address_n=self.client.expand_path("49'/1'/0'/1/0"),
|
||||||
# 2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX
|
# 2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX
|
||||||
amount=123456789,
|
amount=123456789,
|
||||||
prev_hash=binascii.unhexlify('20912f98ea3ed849042efed0fdac8cb4fc301961c5988cba56902d8ffb61c337'),
|
prev_hash=binascii.unhexlify('20912f98ea3ed849042efed0fdac8cb4fc301961c5988cba56902d8ffb61c337'),
|
||||||
prev_index=0,
|
prev_index=0,
|
||||||
script_type=proto_types.SPENDP2SHWITNESS,
|
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||||
)
|
)
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='mhRx1CeVfaayqRwq5zgRQmD7W5aWBfD5mC',
|
address='mhRx1CeVfaayqRwq5zgRQmD7W5aWBfD5mC',
|
||||||
amount=12300000,
|
amount=12300000,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
out2 = proto_types.TxOutputType(
|
out2 = proto.TxOutputType(
|
||||||
address='2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX',
|
address='2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX',
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
amount=123456789 - 11000 - 12300000,
|
amount=123456789 - 11000 - 12300000,
|
||||||
)
|
)
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1, out2])
|
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1, out2])
|
||||||
|
|
||||||
|
@ -70,36 +69,36 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||||
def test_send_p2sh_change(self):
|
def test_send_p2sh_change(self):
|
||||||
self.setup_mnemonic_allallall()
|
self.setup_mnemonic_allallall()
|
||||||
self.client.set_tx_api(TxApiTestnet)
|
self.client.set_tx_api(TxApiTestnet)
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=self.client.expand_path("49'/1'/0'/1/0"),
|
address_n=self.client.expand_path("49'/1'/0'/1/0"),
|
||||||
# 2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX
|
# 2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX
|
||||||
amount=123456789,
|
amount=123456789,
|
||||||
prev_hash=binascii.unhexlify('20912f98ea3ed849042efed0fdac8cb4fc301961c5988cba56902d8ffb61c337'),
|
prev_hash=binascii.unhexlify('20912f98ea3ed849042efed0fdac8cb4fc301961c5988cba56902d8ffb61c337'),
|
||||||
prev_index=0,
|
prev_index=0,
|
||||||
script_type=proto_types.SPENDP2SHWITNESS,
|
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||||
)
|
)
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='mhRx1CeVfaayqRwq5zgRQmD7W5aWBfD5mC',
|
address='mhRx1CeVfaayqRwq5zgRQmD7W5aWBfD5mC',
|
||||||
amount=12300000,
|
amount=12300000,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
out2 = proto_types.TxOutputType(
|
out2 = proto.TxOutputType(
|
||||||
address_n=self.client.expand_path("49'/1'/0'/1/0"),
|
address_n=self.client.expand_path("49'/1'/0'/1/0"),
|
||||||
script_type=proto_types.PAYTOP2SHWITNESS,
|
script_type=proto.OutputScriptType.PAYTOP2SHWITNESS,
|
||||||
amount=123456789 - 11000 - 12300000,
|
amount=123456789 - 11000 - 12300000,
|
||||||
)
|
)
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1, out2])
|
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1, out2])
|
||||||
|
|
||||||
|
@ -109,35 +108,35 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||||
self.setup_mnemonic_allallall()
|
self.setup_mnemonic_allallall()
|
||||||
self.client.set_tx_api(TxApiTestnet)
|
self.client.set_tx_api(TxApiTestnet)
|
||||||
nodes = map(lambda index: self.client.get_public_node(self.client.expand_path("999'/1'/%d'" % index)), range(1, 4))
|
nodes = map(lambda index: self.client.get_public_node(self.client.expand_path("999'/1'/%d'" % index)), range(1, 4))
|
||||||
multisig = proto_types.MultisigRedeemScriptType(
|
multisig = proto.MultisigRedeemScriptType(
|
||||||
pubkeys=map(lambda n: proto_types.HDNodePathType(node=deserialize(n.xpub), address_n=[2, 0]), nodes),
|
pubkeys=list(map(lambda n: proto.HDNodePathType(node=deserialize(n.xpub), address_n=[2, 0]), nodes)),
|
||||||
signatures=[b'', b'', b''],
|
signatures=[b'', b'', b''],
|
||||||
m=2,
|
m=2,
|
||||||
)
|
)
|
||||||
|
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=self.client.expand_path("999'/1'/1'/2/0"),
|
address_n=self.client.expand_path("999'/1'/1'/2/0"),
|
||||||
prev_hash=binascii.unhexlify('9c31922be756c06d02167656465c8dc83bb553bf386a3f478ae65b5c021002be'),
|
prev_hash=binascii.unhexlify('9c31922be756c06d02167656465c8dc83bb553bf386a3f478ae65b5c021002be'),
|
||||||
prev_index=1,
|
prev_index=1,
|
||||||
script_type=proto_types.SPENDP2SHWITNESS,
|
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||||
multisig=multisig,
|
multisig=multisig,
|
||||||
amount=1610436
|
amount=1610436
|
||||||
)
|
)
|
||||||
|
|
||||||
out1 = proto_types.TxOutputType(address='mhRx1CeVfaayqRwq5zgRQmD7W5aWBfD5mC',
|
out1 = proto.TxOutputType(address='mhRx1CeVfaayqRwq5zgRQmD7W5aWBfD5mC',
|
||||||
amount=1605000,
|
amount=1605000,
|
||||||
script_type=proto_types.PAYTOADDRESS)
|
script_type=proto.OutputScriptType.PAYTOADDRESS)
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
(signatures1, _) = self.client.sign_tx('Testnet', [inp1], [out1])
|
(signatures1, _) = self.client.sign_tx('Testnet', [inp1], [out1])
|
||||||
# store signature
|
# store signature
|
||||||
|
@ -145,14 +144,14 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||||
# sign with third key
|
# sign with third key
|
||||||
inp1.address_n[2] = 0x80000003
|
inp1.address_n[2] = 0x80000003
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
(signatures2, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1])
|
(signatures2, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1])
|
||||||
|
|
||||||
|
@ -164,22 +163,22 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||||
|
|
||||||
self.setup_mnemonic_allallall()
|
self.setup_mnemonic_allallall()
|
||||||
self.client.set_tx_api(TxApiTestnet)
|
self.client.set_tx_api(TxApiTestnet)
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=self.client.expand_path("49'/1'/0'/1/0"),
|
address_n=self.client.expand_path("49'/1'/0'/1/0"),
|
||||||
# 2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX
|
# 2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX
|
||||||
amount=123456789,
|
amount=123456789,
|
||||||
prev_hash=binascii.unhexlify('20912f98ea3ed849042efed0fdac8cb4fc301961c5988cba56902d8ffb61c337'),
|
prev_hash=binascii.unhexlify('20912f98ea3ed849042efed0fdac8cb4fc301961c5988cba56902d8ffb61c337'),
|
||||||
prev_index=0,
|
prev_index=0,
|
||||||
script_type=proto_types.SPENDP2SHWITNESS,
|
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||||
)
|
)
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='mhRx1CeVfaayqRwq5zgRQmD7W5aWBfD5mC',
|
address='mhRx1CeVfaayqRwq5zgRQmD7W5aWBfD5mC',
|
||||||
amount=12300000,
|
amount=12300000,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
out2 = proto_types.TxOutputType(
|
out2 = proto.TxOutputType(
|
||||||
address_n=self.client.expand_path("49'/1'/12345'/1/0"),
|
address_n=self.client.expand_path("49'/1'/12345'/1/0"),
|
||||||
script_type=proto_types.PAYTOP2SHWITNESS,
|
script_type=proto.OutputScriptType.PAYTOP2SHWITNESS,
|
||||||
amount=123456789 - 11000 - 12300000,
|
amount=123456789 - 11000 - 12300000,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -190,10 +189,10 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||||
import sys
|
import sys
|
||||||
global run_attack
|
global run_attack
|
||||||
|
|
||||||
if req.details.tx_hash != b'':
|
if req.details.tx_hash is not None:
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
if req.request_type != proto_types.TXINPUT:
|
if req.request_type != proto.RequestType.TXINPUT:
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
if req.details.request_index != 0:
|
if req.details.request_index != 0:
|
||||||
|
@ -209,17 +208,17 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||||
# Test if the transaction can be signed normally
|
# Test if the transaction can be signed normally
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1, out2])
|
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1, out2])
|
||||||
|
|
||||||
|
@ -228,12 +227,12 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||||
# Now run the attack, must trigger the exception
|
# Now run the attack, must trigger the exception
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.Failure(code=proto_types.Failure_ProcessError),
|
proto.Failure(code=proto.FailureType.ProcessError),
|
||||||
])
|
])
|
||||||
self.assertRaises(CallException, self.client.sign_tx, 'Testnet', [inp1], [out1, out2], debug_processor=attack_processor)
|
self.assertRaises(CallException, self.client.sign_tx, 'Testnet', [inp1], [out1, out2], debug_processor=attack_processor)
|
||||||
|
|
|
@ -19,8 +19,7 @@ import unittest
|
||||||
import common
|
import common
|
||||||
import binascii
|
import binascii
|
||||||
|
|
||||||
import trezorlib.messages_pb2 as proto
|
from trezorlib import messages as proto
|
||||||
import trezorlib.types_pb2 as proto_types
|
|
||||||
from trezorlib.tx_api import TxApiTestnet
|
from trezorlib.tx_api import TxApiTestnet
|
||||||
from trezorlib.ckd_public import deserialize
|
from trezorlib.ckd_public import deserialize
|
||||||
|
|
||||||
|
@ -30,37 +29,37 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||||
def test_send_p2sh(self):
|
def test_send_p2sh(self):
|
||||||
self.setup_mnemonic_allallall()
|
self.setup_mnemonic_allallall()
|
||||||
self.client.set_tx_api(TxApiTestnet)
|
self.client.set_tx_api(TxApiTestnet)
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=self.client.expand_path("49'/1'/0'/1/0"),
|
address_n=self.client.expand_path("49'/1'/0'/1/0"),
|
||||||
# 2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX
|
# 2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX
|
||||||
amount=123456789,
|
amount=123456789,
|
||||||
prev_hash=binascii.unhexlify('20912f98ea3ed849042efed0fdac8cb4fc301961c5988cba56902d8ffb61c337'),
|
prev_hash=binascii.unhexlify('20912f98ea3ed849042efed0fdac8cb4fc301961c5988cba56902d8ffb61c337'),
|
||||||
prev_index=0,
|
prev_index=0,
|
||||||
script_type=proto_types.SPENDP2SHWITNESS,
|
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||||
)
|
)
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='tb1qqzv60m9ajw8drqulta4ld4gfx0rdh82un5s65s',
|
address='tb1qqzv60m9ajw8drqulta4ld4gfx0rdh82un5s65s',
|
||||||
amount=12300000,
|
amount=12300000,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
out2 = proto_types.TxOutputType(
|
out2 = proto.TxOutputType(
|
||||||
address='2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX',
|
address='2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX',
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
amount=123456789 - 11000 - 12300000,
|
amount=123456789 - 11000 - 12300000,
|
||||||
)
|
)
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1, out2])
|
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1, out2])
|
||||||
|
|
||||||
|
@ -69,36 +68,36 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||||
def test_send_p2sh_change(self):
|
def test_send_p2sh_change(self):
|
||||||
self.setup_mnemonic_allallall()
|
self.setup_mnemonic_allallall()
|
||||||
self.client.set_tx_api(TxApiTestnet)
|
self.client.set_tx_api(TxApiTestnet)
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=self.client.expand_path("49'/1'/0'/1/0"),
|
address_n=self.client.expand_path("49'/1'/0'/1/0"),
|
||||||
# 2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX
|
# 2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX
|
||||||
amount=123456789,
|
amount=123456789,
|
||||||
prev_hash=binascii.unhexlify('20912f98ea3ed849042efed0fdac8cb4fc301961c5988cba56902d8ffb61c337'),
|
prev_hash=binascii.unhexlify('20912f98ea3ed849042efed0fdac8cb4fc301961c5988cba56902d8ffb61c337'),
|
||||||
prev_index=0,
|
prev_index=0,
|
||||||
script_type=proto_types.SPENDP2SHWITNESS,
|
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||||
)
|
)
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='tb1qqzv60m9ajw8drqulta4ld4gfx0rdh82un5s65s',
|
address='tb1qqzv60m9ajw8drqulta4ld4gfx0rdh82un5s65s',
|
||||||
amount=12300000,
|
amount=12300000,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
out2 = proto_types.TxOutputType(
|
out2 = proto.TxOutputType(
|
||||||
address_n=self.client.expand_path("49'/1'/0'/1/0"),
|
address_n=self.client.expand_path("49'/1'/0'/1/0"),
|
||||||
script_type=proto_types.PAYTOP2SHWITNESS,
|
script_type=proto.OutputScriptType.PAYTOP2SHWITNESS,
|
||||||
amount=123456789 - 11000 - 12300000,
|
amount=123456789 - 11000 - 12300000,
|
||||||
)
|
)
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1, out2])
|
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1, out2])
|
||||||
|
|
||||||
|
@ -107,37 +106,37 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||||
def test_send_native(self):
|
def test_send_native(self):
|
||||||
self.setup_mnemonic_allallall()
|
self.setup_mnemonic_allallall()
|
||||||
self.client.set_tx_api(TxApiTestnet)
|
self.client.set_tx_api(TxApiTestnet)
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=self.client.expand_path("49'/1'/0'/0/0"),
|
address_n=self.client.expand_path("49'/1'/0'/0/0"),
|
||||||
# tb1qqzv60m9ajw8drqulta4ld4gfx0rdh82un5s65s
|
# tb1qqzv60m9ajw8drqulta4ld4gfx0rdh82un5s65s
|
||||||
amount=12300000,
|
amount=12300000,
|
||||||
prev_hash=binascii.unhexlify('09144602765ce3dd8f4329445b20e3684e948709c5cdcaf12da3bb079c99448a'),
|
prev_hash=binascii.unhexlify('09144602765ce3dd8f4329445b20e3684e948709c5cdcaf12da3bb079c99448a'),
|
||||||
prev_index=0,
|
prev_index=0,
|
||||||
script_type=proto_types.SPENDWITNESS,
|
script_type=proto.InputScriptType.SPENDWITNESS,
|
||||||
)
|
)
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='2N4Q5FhU2497BryFfUgbqkAJE87aKHUhXMp',
|
address='2N4Q5FhU2497BryFfUgbqkAJE87aKHUhXMp',
|
||||||
amount=5000000,
|
amount=5000000,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
out2 = proto_types.TxOutputType(
|
out2 = proto.TxOutputType(
|
||||||
address='tb1q694ccp5qcc0udmfwgp692u2s2hjpq5h407urtu',
|
address='tb1q694ccp5qcc0udmfwgp692u2s2hjpq5h407urtu',
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
amount=12300000 - 11000 - 5000000,
|
amount=12300000 - 11000 - 5000000,
|
||||||
)
|
)
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1, out2])
|
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1, out2])
|
||||||
|
|
||||||
|
@ -146,36 +145,36 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||||
def test_send_native_change(self):
|
def test_send_native_change(self):
|
||||||
self.setup_mnemonic_allallall()
|
self.setup_mnemonic_allallall()
|
||||||
self.client.set_tx_api(TxApiTestnet)
|
self.client.set_tx_api(TxApiTestnet)
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=self.client.expand_path("49'/1'/0'/0/0"),
|
address_n=self.client.expand_path("49'/1'/0'/0/0"),
|
||||||
# tb1qqzv60m9ajw8drqulta4ld4gfx0rdh82un5s65s
|
# tb1qqzv60m9ajw8drqulta4ld4gfx0rdh82un5s65s
|
||||||
amount=12300000,
|
amount=12300000,
|
||||||
prev_hash=binascii.unhexlify('09144602765ce3dd8f4329445b20e3684e948709c5cdcaf12da3bb079c99448a'),
|
prev_hash=binascii.unhexlify('09144602765ce3dd8f4329445b20e3684e948709c5cdcaf12da3bb079c99448a'),
|
||||||
prev_index=0,
|
prev_index=0,
|
||||||
script_type=proto_types.SPENDWITNESS,
|
script_type=proto.InputScriptType.SPENDWITNESS,
|
||||||
)
|
)
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='2N4Q5FhU2497BryFfUgbqkAJE87aKHUhXMp',
|
address='2N4Q5FhU2497BryFfUgbqkAJE87aKHUhXMp',
|
||||||
amount=5000000,
|
amount=5000000,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
out2 = proto_types.TxOutputType(
|
out2 = proto.TxOutputType(
|
||||||
address_n=self.client.expand_path("49'/1'/0'/1/0"),
|
address_n=self.client.expand_path("49'/1'/0'/1/0"),
|
||||||
script_type=proto_types.PAYTOWITNESS,
|
script_type=proto.OutputScriptType.PAYTOWITNESS,
|
||||||
amount=12300000 - 11000 - 5000000,
|
amount=12300000 - 11000 - 5000000,
|
||||||
)
|
)
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1, out2])
|
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1, out2])
|
||||||
|
|
||||||
|
@ -184,59 +183,59 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||||
def test_send_both(self):
|
def test_send_both(self):
|
||||||
self.setup_mnemonic_allallall()
|
self.setup_mnemonic_allallall()
|
||||||
self.client.set_tx_api(TxApiTestnet)
|
self.client.set_tx_api(TxApiTestnet)
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=self.client.expand_path("49'/1'/0'/1/0"),
|
address_n=self.client.expand_path("49'/1'/0'/1/0"),
|
||||||
# 2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX
|
# 2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX
|
||||||
amount=111145789,
|
amount=111145789,
|
||||||
prev_hash=binascii.unhexlify('09144602765ce3dd8f4329445b20e3684e948709c5cdcaf12da3bb079c99448a'),
|
prev_hash=binascii.unhexlify('09144602765ce3dd8f4329445b20e3684e948709c5cdcaf12da3bb079c99448a'),
|
||||||
prev_index=1,
|
prev_index=1,
|
||||||
script_type=proto_types.SPENDP2SHWITNESS,
|
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||||
)
|
)
|
||||||
inp2 = proto_types.TxInputType(
|
inp2 = proto.TxInputType(
|
||||||
address_n=self.client.expand_path("49'/1'/0'/1/0"),
|
address_n=self.client.expand_path("49'/1'/0'/1/0"),
|
||||||
# tb1q694ccp5qcc0udmfwgp692u2s2hjpq5h407urtu
|
# tb1q694ccp5qcc0udmfwgp692u2s2hjpq5h407urtu
|
||||||
amount=7289000,
|
amount=7289000,
|
||||||
prev_hash=binascii.unhexlify('65b811d3eca0fe6915d9f2d77c86c5a7f19bf66b1b1253c2c51cb4ae5f0c017b'),
|
prev_hash=binascii.unhexlify('65b811d3eca0fe6915d9f2d77c86c5a7f19bf66b1b1253c2c51cb4ae5f0c017b'),
|
||||||
prev_index=1,
|
prev_index=1,
|
||||||
script_type=proto_types.SPENDWITNESS,
|
script_type=proto.InputScriptType.SPENDWITNESS,
|
||||||
)
|
)
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='tb1q54un3q39sf7e7tlfq99d6ezys7qgc62a6rxllc',
|
address='tb1q54un3q39sf7e7tlfq99d6ezys7qgc62a6rxllc',
|
||||||
amount=12300000,
|
amount=12300000,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
out2 = proto_types.TxOutputType(
|
out2 = proto.TxOutputType(
|
||||||
# address_n=self.client.expand_path("44'/1'/0'/0/0"),
|
# address_n=self.client.expand_path("44'/1'/0'/0/0"),
|
||||||
# script_type=proto_types.PAYTOP2SHWITNESS,
|
# script_type=proto.OutputScriptType.PAYTOP2SHWITNESS,
|
||||||
address='2N6UeBoqYEEnybg4cReFYDammpsyDw8R2Mc',
|
address='2N6UeBoqYEEnybg4cReFYDammpsyDw8R2Mc',
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
amount=45600000,
|
amount=45600000,
|
||||||
)
|
)
|
||||||
out3 = proto_types.TxOutputType(
|
out3 = proto.TxOutputType(
|
||||||
address='mvbu1Gdy8SUjTenqerxUaZyYjmveZvt33q',
|
address='mvbu1Gdy8SUjTenqerxUaZyYjmveZvt33q',
|
||||||
amount=111145789 + 7289000 - 11000 - 12300000 - 45600000,
|
amount=111145789 + 7289000 - 11000 - 12300000 - 45600000,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=2)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=2)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=2)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=2)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1, inp2], [out1, out2, out3])
|
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1, inp2], [out1, out2, out3])
|
||||||
|
|
||||||
|
@ -247,37 +246,37 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||||
self.setup_mnemonic_allallall()
|
self.setup_mnemonic_allallall()
|
||||||
self.client.set_tx_api(TxApiTestnet)
|
self.client.set_tx_api(TxApiTestnet)
|
||||||
nodes = [self.client.get_public_node(self.client.expand_path("999'/1'/%d'" % index)) for index in range(1, 4)]
|
nodes = [self.client.get_public_node(self.client.expand_path("999'/1'/%d'" % index)) for index in range(1, 4)]
|
||||||
multisig = proto_types.MultisigRedeemScriptType(
|
multisig = proto.MultisigRedeemScriptType(
|
||||||
pubkeys=map(lambda n: proto_types.HDNodePathType(node=deserialize(n.xpub), address_n=[2, 0]), nodes),
|
pubkeys=list(map(lambda n: proto.HDNodePathType(node=deserialize(n.xpub), address_n=[2, 0]), nodes)),
|
||||||
signatures=[b'', b'', b''],
|
signatures=[b'', b'', b''],
|
||||||
m=2,
|
m=2,
|
||||||
)
|
)
|
||||||
|
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=self.client.expand_path("999'/1'/1'/2/0"),
|
address_n=self.client.expand_path("999'/1'/1'/2/0"),
|
||||||
prev_hash=binascii.unhexlify('9c31922be756c06d02167656465c8dc83bb553bf386a3f478ae65b5c021002be'),
|
prev_hash=binascii.unhexlify('9c31922be756c06d02167656465c8dc83bb553bf386a3f478ae65b5c021002be'),
|
||||||
prev_index=1,
|
prev_index=1,
|
||||||
script_type=proto_types.SPENDP2SHWITNESS,
|
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||||
multisig=multisig,
|
multisig=multisig,
|
||||||
amount=1610436
|
amount=1610436
|
||||||
)
|
)
|
||||||
|
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='tb1qch62pf820spe9mlq49ns5uexfnl6jzcezp7d328fw58lj0rhlhasge9hzy',
|
address='tb1qch62pf820spe9mlq49ns5uexfnl6jzcezp7d328fw58lj0rhlhasge9hzy',
|
||||||
amount=1605000,
|
amount=1605000,
|
||||||
script_type=proto_types.PAYTOADDRESS
|
script_type=proto.OutputScriptType.PAYTOADDRESS
|
||||||
)
|
)
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
(signatures1, _) = self.client.sign_tx('Testnet', [inp1], [out1])
|
(signatures1, _) = self.client.sign_tx('Testnet', [inp1], [out1])
|
||||||
# store signature
|
# store signature
|
||||||
|
@ -285,14 +284,14 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||||
# sign with third key
|
# sign with third key
|
||||||
inp1.address_n[2] = 0x80000003
|
inp1.address_n[2] = 0x80000003
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
(signatures2, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1])
|
(signatures2, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1])
|
||||||
|
|
||||||
|
@ -303,37 +302,37 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||||
self.setup_mnemonic_allallall()
|
self.setup_mnemonic_allallall()
|
||||||
self.client.set_tx_api(TxApiTestnet)
|
self.client.set_tx_api(TxApiTestnet)
|
||||||
nodes = [self.client.get_public_node(self.client.expand_path("999'/1'/%d'" % index)) for index in range(1, 4)]
|
nodes = [self.client.get_public_node(self.client.expand_path("999'/1'/%d'" % index)) for index in range(1, 4)]
|
||||||
multisig = proto_types.MultisigRedeemScriptType(
|
multisig = proto.MultisigRedeemScriptType(
|
||||||
pubkeys=map(lambda n: proto_types.HDNodePathType(node=deserialize(n.xpub), address_n=[2, 1]), nodes),
|
pubkeys=list(map(lambda n: proto.HDNodePathType(node=deserialize(n.xpub), address_n=[2, 1]), nodes)),
|
||||||
signatures=[b'', b'', b''],
|
signatures=[b'', b'', b''],
|
||||||
m=2,
|
m=2,
|
||||||
)
|
)
|
||||||
|
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=self.client.expand_path("999'/1'/2'/2/1"),
|
address_n=self.client.expand_path("999'/1'/2'/2/1"),
|
||||||
prev_hash=binascii.unhexlify('f41cbedd8becee05a830f418d13aa665125464547db5c7a6cd28f21639fe1228'),
|
prev_hash=binascii.unhexlify('f41cbedd8becee05a830f418d13aa665125464547db5c7a6cd28f21639fe1228'),
|
||||||
prev_index=0,
|
prev_index=0,
|
||||||
script_type=proto_types.SPENDWITNESS,
|
script_type=proto.InputScriptType.SPENDWITNESS,
|
||||||
multisig=multisig,
|
multisig=multisig,
|
||||||
amount=1605000
|
amount=1605000
|
||||||
)
|
)
|
||||||
|
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='tb1qr6xa5v60zyt3ry9nmfew2fk5g9y3gerkjeu6xxdz7qga5kknz2ssld9z2z',
|
address='tb1qr6xa5v60zyt3ry9nmfew2fk5g9y3gerkjeu6xxdz7qga5kknz2ssld9z2z',
|
||||||
amount=1604000,
|
amount=1604000,
|
||||||
script_type=proto_types.PAYTOADDRESS
|
script_type=proto.OutputScriptType.PAYTOADDRESS
|
||||||
)
|
)
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
(signatures1, _) = self.client.sign_tx('Testnet', [inp1], [out1])
|
(signatures1, _) = self.client.sign_tx('Testnet', [inp1], [out1])
|
||||||
# store signature
|
# store signature
|
||||||
|
@ -341,14 +340,14 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||||
# sign with first key
|
# sign with first key
|
||||||
inp1.address_n[2] = 0x80000001
|
inp1.address_n[2] = 0x80000001
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
(signatures2, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1])
|
(signatures2, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1])
|
||||||
|
|
||||||
|
@ -359,42 +358,42 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||||
self.setup_mnemonic_allallall()
|
self.setup_mnemonic_allallall()
|
||||||
self.client.set_tx_api(TxApiTestnet)
|
self.client.set_tx_api(TxApiTestnet)
|
||||||
nodes = [self.client.get_public_node(self.client.expand_path("999'/1'/%d'" % index)) for index in range(1, 4)]
|
nodes = [self.client.get_public_node(self.client.expand_path("999'/1'/%d'" % index)) for index in range(1, 4)]
|
||||||
multisig = proto_types.MultisigRedeemScriptType(
|
multisig = proto.MultisigRedeemScriptType(
|
||||||
pubkeys=map(lambda n: proto_types.HDNodePathType(node=deserialize(n.xpub), address_n=[2, 0]), nodes),
|
pubkeys=list(map(lambda n: proto.HDNodePathType(node=deserialize(n.xpub), address_n=[2, 0]), nodes)),
|
||||||
signatures=[b'', b'', b''],
|
signatures=[b'', b'', b''],
|
||||||
m=2,
|
m=2,
|
||||||
)
|
)
|
||||||
multisig2 = proto_types.MultisigRedeemScriptType(
|
multisig2 = proto.MultisigRedeemScriptType(
|
||||||
pubkeys=map(lambda n: proto_types.HDNodePathType(node=deserialize(n.xpub), address_n=[1, 1]), nodes),
|
pubkeys=list(map(lambda n: proto.HDNodePathType(node=deserialize(n.xpub), address_n=[1, 1]), nodes)),
|
||||||
signatures=[b'', b'', b''],
|
signatures=[b'', b'', b''],
|
||||||
m=2,
|
m=2,
|
||||||
)
|
)
|
||||||
|
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=self.client.expand_path("999'/1'/1'/2/0"),
|
address_n=self.client.expand_path("999'/1'/1'/2/0"),
|
||||||
prev_hash=binascii.unhexlify('c9348040bbc2024e12dcb4a0b4806b0398646b91acf314da028c3f03dd0179fc'),
|
prev_hash=binascii.unhexlify('c9348040bbc2024e12dcb4a0b4806b0398646b91acf314da028c3f03dd0179fc'),
|
||||||
prev_index=0,
|
prev_index=0,
|
||||||
script_type=proto_types.SPENDWITNESS,
|
script_type=proto.InputScriptType.SPENDWITNESS,
|
||||||
multisig=multisig,
|
multisig=multisig,
|
||||||
amount=1604000
|
amount=1604000
|
||||||
)
|
)
|
||||||
|
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address_n=self.client.expand_path("999'/1'/1'/1/1"),
|
address_n=self.client.expand_path("999'/1'/1'/1/1"),
|
||||||
amount=1603000,
|
amount=1603000,
|
||||||
multisig=multisig2,
|
multisig=multisig2,
|
||||||
script_type=proto_types.PAYTOP2SHWITNESS
|
script_type=proto.OutputScriptType.PAYTOP2SHWITNESS
|
||||||
)
|
)
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
(signatures1, _) = self.client.sign_tx('Testnet', [inp1], [out1])
|
(signatures1, _) = self.client.sign_tx('Testnet', [inp1], [out1])
|
||||||
# store signature
|
# store signature
|
||||||
|
@ -403,13 +402,13 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||||
inp1.address_n[2] = 0x80000003
|
inp1.address_n[2] = 0x80000003
|
||||||
out1.address_n[2] = 0x80000003
|
out1.address_n[2] = 0x80000003
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
(signatures2, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1])
|
(signatures2, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1])
|
||||||
|
|
||||||
|
@ -420,42 +419,42 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||||
self.setup_mnemonic_allallall()
|
self.setup_mnemonic_allallall()
|
||||||
self.client.set_tx_api(TxApiTestnet)
|
self.client.set_tx_api(TxApiTestnet)
|
||||||
nodes = [self.client.get_public_node(self.client.expand_path("999'/1'/%d'" % index)) for index in range(1, 4)]
|
nodes = [self.client.get_public_node(self.client.expand_path("999'/1'/%d'" % index)) for index in range(1, 4)]
|
||||||
multisig = proto_types.MultisigRedeemScriptType(
|
multisig = proto.MultisigRedeemScriptType(
|
||||||
pubkeys=map(lambda n: proto_types.HDNodePathType(node=deserialize(n.xpub), address_n=[1, 1]), nodes),
|
pubkeys=list(map(lambda n: proto.HDNodePathType(node=deserialize(n.xpub), address_n=[1, 1]), nodes)),
|
||||||
signatures=[b'', b'', b''],
|
signatures=[b'', b'', b''],
|
||||||
m=2,
|
m=2,
|
||||||
)
|
)
|
||||||
multisig2 = proto_types.MultisigRedeemScriptType(
|
multisig2 = proto.MultisigRedeemScriptType(
|
||||||
pubkeys=map(lambda n: proto_types.HDNodePathType(node=deserialize(n.xpub), address_n=[1, 2]), nodes),
|
pubkeys=list(map(lambda n: proto.HDNodePathType(node=deserialize(n.xpub), address_n=[1, 2]), nodes)),
|
||||||
signatures=[b'', b'', b''],
|
signatures=[b'', b'', b''],
|
||||||
m=2,
|
m=2,
|
||||||
)
|
)
|
||||||
|
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=self.client.expand_path("999'/1'/1'/1/1"),
|
address_n=self.client.expand_path("999'/1'/1'/1/1"),
|
||||||
prev_hash=binascii.unhexlify('31bc1c88ce6ae337a6b3057a16d5bad0b561ad1dfc047d0a7fbb8814668f91e5'),
|
prev_hash=binascii.unhexlify('31bc1c88ce6ae337a6b3057a16d5bad0b561ad1dfc047d0a7fbb8814668f91e5'),
|
||||||
prev_index=0,
|
prev_index=0,
|
||||||
script_type=proto_types.SPENDP2SHWITNESS,
|
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||||
multisig=multisig,
|
multisig=multisig,
|
||||||
amount=1603000
|
amount=1603000
|
||||||
)
|
)
|
||||||
|
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address_n=self.client.expand_path("999'/1'/1'/1/2"),
|
address_n=self.client.expand_path("999'/1'/1'/1/2"),
|
||||||
amount=1602000,
|
amount=1602000,
|
||||||
multisig=multisig2,
|
multisig=multisig2,
|
||||||
script_type=proto_types.PAYTOWITNESS
|
script_type=proto.OutputScriptType.PAYTOWITNESS
|
||||||
)
|
)
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
(signatures1, _) = self.client.sign_tx('Testnet', [inp1], [out1])
|
(signatures1, _) = self.client.sign_tx('Testnet', [inp1], [out1])
|
||||||
# store signature
|
# store signature
|
||||||
|
@ -464,13 +463,13 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||||
inp1.address_n[2] = 0x80000003
|
inp1.address_n[2] = 0x80000003
|
||||||
out1.address_n[2] = 0x80000003
|
out1.address_n[2] = 0x80000003
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
(signatures2, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1])
|
(signatures2, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1])
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,7 @@ import unittest
|
||||||
import common
|
import common
|
||||||
import binascii
|
import binascii
|
||||||
|
|
||||||
import trezorlib.messages_pb2 as proto
|
from trezorlib import messages as proto
|
||||||
import trezorlib.types_pb2 as proto_types
|
|
||||||
from trezorlib.tx_api import TxApiZcash
|
from trezorlib.tx_api import TxApiZcash
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,36 +36,36 @@ class TestMsgSigntx(common.TrezorTest):
|
||||||
# tx: 93373e63cc626c4a7d049ad775d6511bb5eba985f142db660c9b9f955c722f5c
|
# tx: 93373e63cc626c4a7d049ad775d6511bb5eba985f142db660c9b9f955c722f5c
|
||||||
# input 0: 1.234567 TAZ
|
# input 0: 1.234567 TAZ
|
||||||
|
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=[2147483692, 2147483649, 2147483648, 0, 0], # tmQoJ3PTXgQLaRRZZYT6xk8XtjRbr2kCqwu
|
address_n=[2147483692, 2147483649, 2147483648, 0, 0], # tmQoJ3PTXgQLaRRZZYT6xk8XtjRbr2kCqwu
|
||||||
# amount=123456700,
|
# amount=123456700,
|
||||||
prev_hash=TXHASH_93373e,
|
prev_hash=TXHASH_93373e,
|
||||||
prev_index=0,
|
prev_index=0,
|
||||||
)
|
)
|
||||||
|
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='tmJ1xYxP8XNTtCoDgvdmQPSrxh5qZJgy65Z',
|
address='tmJ1xYxP8XNTtCoDgvdmQPSrxh5qZJgy65Z',
|
||||||
amount=123456700 - 1940,
|
amount=123456700 - 1940,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_tx_api(TxApiZcash)
|
self.client.set_tx_api(TxApiZcash)
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=TXHASH_93373e)),
|
proto.TxRequest(request_type=proto.RequestType.TXMETA, details=proto.TxRequestDetailsType(tx_hash=TXHASH_93373e)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_93373e)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_93373e)),
|
||||||
proto.TxRequest(request_type=proto_types.TXEXTRADATA, details=proto_types.TxRequestDetailsType(tx_hash=TXHASH_93373e, extra_data_offset=0, extra_data_len=1024)),
|
proto.TxRequest(request_type=proto.RequestType.TXEXTRADATA, details=proto.TxRequestDetailsType(tx_hash=TXHASH_93373e, extra_data_offset=0, extra_data_len=1024)),
|
||||||
proto.TxRequest(request_type=proto_types.TXEXTRADATA, details=proto_types.TxRequestDetailsType(tx_hash=TXHASH_93373e, extra_data_offset=1024, extra_data_len=1024)),
|
proto.TxRequest(request_type=proto.RequestType.TXEXTRADATA, details=proto.TxRequestDetailsType(tx_hash=TXHASH_93373e, extra_data_offset=1024, extra_data_len=1024)),
|
||||||
proto.TxRequest(request_type=proto_types.TXEXTRADATA, details=proto_types.TxRequestDetailsType(tx_hash=TXHASH_93373e, extra_data_offset=2048, extra_data_len=1024)),
|
proto.TxRequest(request_type=proto.RequestType.TXEXTRADATA, details=proto.TxRequestDetailsType(tx_hash=TXHASH_93373e, extra_data_offset=2048, extra_data_len=1024)),
|
||||||
proto.TxRequest(request_type=proto_types.TXEXTRADATA, details=proto_types.TxRequestDetailsType(tx_hash=TXHASH_93373e, extra_data_offset=3072, extra_data_len=629)),
|
proto.TxRequest(request_type=proto.RequestType.TXEXTRADATA, details=proto.TxRequestDetailsType(tx_hash=TXHASH_93373e, extra_data_offset=3072, extra_data_len=629)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
|
|
||||||
(signatures, serialized_tx) = self.client.sign_tx('Zcash', [inp1, ], [out1, ])
|
(signatures, serialized_tx) = self.client.sign_tx('Zcash', [inp1, ], [out1, ])
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
import unittest
|
import unittest
|
||||||
import common
|
import common
|
||||||
|
|
||||||
from trezorlib import messages_pb2 as proto
|
from trezorlib import messages as proto
|
||||||
|
|
||||||
|
|
||||||
class TestDeviceWipe(common.TrezorTest):
|
class TestDeviceWipe(common.TrezorTest):
|
||||||
|
|
|
@ -22,9 +22,8 @@ import unittest
|
||||||
import common
|
import common
|
||||||
import binascii
|
import binascii
|
||||||
|
|
||||||
import trezorlib.messages_pb2 as proto
|
from trezorlib import messages as proto
|
||||||
import trezorlib.ckd_public as bip32
|
import trezorlib.ckd_public as bip32
|
||||||
import trezorlib.types_pb2 as proto_types
|
|
||||||
from trezorlib.client import CallException
|
from trezorlib.client import CallException
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,45 +64,45 @@ class TestMultisig(common.TrezorTest):
|
||||||
|
|
||||||
node = bip32.deserialize('xpub661MyMwAqRbcF1zGijBb2K6x9YiJPh58xpcCeLvTxMX6spkY3PcpJ4ABcCyWfskq5DDxM3e6Ez5ePCqG5bnPUXR4wL8TZWyoDaUdiWW7bKy')
|
node = bip32.deserialize('xpub661MyMwAqRbcF1zGijBb2K6x9YiJPh58xpcCeLvTxMX6spkY3PcpJ4ABcCyWfskq5DDxM3e6Ez5ePCqG5bnPUXR4wL8TZWyoDaUdiWW7bKy')
|
||||||
|
|
||||||
multisig = proto_types.MultisigRedeemScriptType(
|
multisig = proto.MultisigRedeemScriptType(
|
||||||
pubkeys=[
|
pubkeys=[
|
||||||
proto_types.HDNodePathType(node=node, address_n=[1]),
|
proto.HDNodePathType(node=node, address_n=[1]),
|
||||||
proto_types.HDNodePathType(node=node, address_n=[2]),
|
proto.HDNodePathType(node=node, address_n=[2]),
|
||||||
proto_types.HDNodePathType(node=node, address_n=[3])
|
proto.HDNodePathType(node=node, address_n=[3])
|
||||||
],
|
],
|
||||||
signatures=[b'', b'', b''],
|
signatures=[b'', b'', b''],
|
||||||
m=2,
|
m=2,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Let's go to sign with key 1
|
# Let's go to sign with key 1
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=[1],
|
address_n=[1],
|
||||||
prev_hash=TXHASH_c6091a,
|
prev_hash=TXHASH_c6091a,
|
||||||
prev_index=1,
|
prev_index=1,
|
||||||
script_type=proto_types.SPENDMULTISIG,
|
script_type=proto.InputScriptType.SPENDMULTISIG,
|
||||||
multisig=multisig,
|
multisig=multisig,
|
||||||
)
|
)
|
||||||
|
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='12iyMbUb4R2K3gre4dHSrbu5azG5KaqVss',
|
address='12iyMbUb4R2K3gre4dHSrbu5azG5KaqVss',
|
||||||
amount=100000,
|
amount=100000,
|
||||||
script_type=proto_types.PAYTOADDRESS
|
script_type=proto.OutputScriptType.PAYTOADDRESS
|
||||||
)
|
)
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=TXHASH_c6091a)),
|
proto.TxRequest(request_type=proto.RequestType.TXMETA, details=proto.TxRequestDetailsType(tx_hash=TXHASH_c6091a)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_c6091a)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_c6091a)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_c6091a)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_c6091a)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_c6091a)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_c6091a)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
|
|
||||||
# Now we have first signature
|
# Now we have first signature
|
||||||
|
@ -114,39 +113,39 @@ class TestMultisig(common.TrezorTest):
|
||||||
# ---------------------------------------
|
# ---------------------------------------
|
||||||
# Let's do second signature using 3rd key
|
# Let's do second signature using 3rd key
|
||||||
|
|
||||||
multisig = proto_types.MultisigRedeemScriptType(
|
multisig = proto.MultisigRedeemScriptType(
|
||||||
pubkeys=[
|
pubkeys=[
|
||||||
proto_types.HDNodePathType(node=node, address_n=[1]),
|
proto.HDNodePathType(node=node, address_n=[1]),
|
||||||
proto_types.HDNodePathType(node=node, address_n=[2]),
|
proto.HDNodePathType(node=node, address_n=[2]),
|
||||||
proto_types.HDNodePathType(node=node, address_n=[3])
|
proto.HDNodePathType(node=node, address_n=[3])
|
||||||
],
|
],
|
||||||
signatures=[signatures1[0], b'', b''], # Fill signature from previous signing process
|
signatures=[signatures1[0], b'', b''], # Fill signature from previous signing process
|
||||||
m=2,
|
m=2,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Let's do a second signature with key 3
|
# Let's do a second signature with key 3
|
||||||
inp3 = proto_types.TxInputType(
|
inp3 = proto.TxInputType(
|
||||||
address_n=[3],
|
address_n=[3],
|
||||||
prev_hash=TXHASH_c6091a,
|
prev_hash=TXHASH_c6091a,
|
||||||
prev_index=1,
|
prev_index=1,
|
||||||
script_type=proto_types.SPENDMULTISIG,
|
script_type=proto.InputScriptType.SPENDMULTISIG,
|
||||||
multisig=multisig,
|
multisig=multisig,
|
||||||
)
|
)
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=TXHASH_c6091a)),
|
proto.TxRequest(request_type=proto.RequestType.TXMETA, details=proto.TxRequestDetailsType(tx_hash=TXHASH_c6091a)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_c6091a)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_c6091a)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_c6091a)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_c6091a)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_c6091a)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_c6091a)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
(signatures2, serialized_tx) = self.client.sign_tx('Bitcoin', [inp3, ], [out1, ])
|
(signatures2, serialized_tx) = self.client.sign_tx('Bitcoin', [inp3, ], [out1, ])
|
||||||
|
|
||||||
|
@ -171,7 +170,7 @@ class TestMultisig(common.TrezorTest):
|
||||||
|
|
||||||
pubs = []
|
pubs = []
|
||||||
for x in range(15):
|
for x in range(15):
|
||||||
pubs.append(proto_types.HDNodePathType(node=node, address_n=[x]))
|
pubs.append(proto.HDNodePathType(node=node, address_n=[x]))
|
||||||
|
|
||||||
# redeeemscript
|
# redeeemscript
|
||||||
# 5f21023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43d210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a621038caebd6f753bbbd2bb1f3346a43cd32140648583673a31d62f2dfb56ad0ab9e32103477b9f0f34ae85434ce795f0c5e1e90c9420e5b5fad084d7cce9a487b94a79022103fe91eca10602d7dad4c9dab2b2a0858f71e25a219a6940749ce7a48118480dae210234716c01c2dd03fa7ee302705e2b8fbd1311895d94b1dca15e62eedea9b0968f210341fb2ead334952cf60f4481ba435c4693d0be649be01d2cfe9b02018e483e7bd2102dad8b2bce360a705c16e74a50a36459b4f8f4b78f9cd67def29d54ef6f7c7cf9210222dbe3f5f197a34a1d50e2cbe2a1085cac2d605c9e176f9a240e0fd0c669330d2103fb41afab56c9cdb013fda63d777d4938ddc3cb2ad939712da688e3ed333f95982102435f177646bdc717cb3211bf46656ca7e8d642726144778c9ce816b8b8c36ccf2102158d8e20095364031d923c7e9f7f08a14b1be1ddee21fe1a5431168e31345e5521026259794892428ca0818c8fb61d2d459ddfe20e57f50803c7295e6f4e2f5586652102815f910a8689151db627e6e262e0a2075ad5ec2993a6bc1b876a9d420923d681210318f54647f645ff01bd49fedc0219343a6a22d3ea3180a3c3d3097e4b888a8db45fae
|
# 5f21023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43d210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a621038caebd6f753bbbd2bb1f3346a43cd32140648583673a31d62f2dfb56ad0ab9e32103477b9f0f34ae85434ce795f0c5e1e90c9420e5b5fad084d7cce9a487b94a79022103fe91eca10602d7dad4c9dab2b2a0858f71e25a219a6940749ce7a48118480dae210234716c01c2dd03fa7ee302705e2b8fbd1311895d94b1dca15e62eedea9b0968f210341fb2ead334952cf60f4481ba435c4693d0be649be01d2cfe9b02018e483e7bd2102dad8b2bce360a705c16e74a50a36459b4f8f4b78f9cd67def29d54ef6f7c7cf9210222dbe3f5f197a34a1d50e2cbe2a1085cac2d605c9e176f9a240e0fd0c669330d2103fb41afab56c9cdb013fda63d777d4938ddc3cb2ad939712da688e3ed333f95982102435f177646bdc717cb3211bf46656ca7e8d642726144778c9ce816b8b8c36ccf2102158d8e20095364031d923c7e9f7f08a14b1be1ddee21fe1a5431168e31345e5521026259794892428ca0818c8fb61d2d459ddfe20e57f50803c7295e6f4e2f5586652102815f910a8689151db627e6e262e0a2075ad5ec2993a6bc1b876a9d420923d681210318f54647f645ff01bd49fedc0219343a6a22d3ea3180a3c3d3097e4b888a8db45fae
|
||||||
|
@ -181,24 +180,24 @@ class TestMultisig(common.TrezorTest):
|
||||||
|
|
||||||
signatures = [b''] * 15
|
signatures = [b''] * 15
|
||||||
|
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='17kTB7qSk3MupQxWdiv5ZU3zcrZc2Azes1',
|
address='17kTB7qSk3MupQxWdiv5ZU3zcrZc2Azes1',
|
||||||
amount=10000,
|
amount=10000,
|
||||||
script_type=proto_types.PAYTOADDRESS
|
script_type=proto.OutputScriptType.PAYTOADDRESS
|
||||||
)
|
)
|
||||||
|
|
||||||
for x in range(15):
|
for x in range(15):
|
||||||
multisig = proto_types.MultisigRedeemScriptType(
|
multisig = proto.MultisigRedeemScriptType(
|
||||||
pubkeys=pubs,
|
pubkeys=pubs,
|
||||||
signatures=signatures,
|
signatures=signatures,
|
||||||
m=15,
|
m=15,
|
||||||
)
|
)
|
||||||
|
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=[x],
|
address_n=[x],
|
||||||
prev_hash=binascii.unhexlify('6189e3febb5a21cee8b725aa1ef04ffce7e609448446d3a8d6f483c634ef5315'),
|
prev_hash=binascii.unhexlify('6189e3febb5a21cee8b725aa1ef04ffce7e609448446d3a8d6f483c634ef5315'),
|
||||||
prev_index=1,
|
prev_index=1,
|
||||||
script_type=proto_types.SPENDMULTISIG,
|
script_type=proto.InputScriptType.SPENDMULTISIG,
|
||||||
multisig=multisig,
|
multisig=multisig,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -228,29 +227,29 @@ class TestMultisig(common.TrezorTest):
|
||||||
# xpub661MyMwAqRbcF1zGijBb2K6x9YiJPh58xpcCeLvTxMX6spkY3PcpJ4ABcCyWfskq5DDxM3e6Ez5ePCqG5bnPUXR4wL8TZWyoDaUdiWW7bKy
|
# xpub661MyMwAqRbcF1zGijBb2K6x9YiJPh58xpcCeLvTxMX6spkY3PcpJ4ABcCyWfskq5DDxM3e6Ez5ePCqG5bnPUXR4wL8TZWyoDaUdiWW7bKy
|
||||||
node = bip32.deserialize('xpub661MyMwAqRbcF1zGijBb2K6x9YiJPh58xpcCeLvTxMX6spkY3PcpJ4ABcCyWfskq5DDxM3e6Ez5ePCqG5bnPUXR4wL8TZWyoDaUdiWW7bKy')
|
node = bip32.deserialize('xpub661MyMwAqRbcF1zGijBb2K6x9YiJPh58xpcCeLvTxMX6spkY3PcpJ4ABcCyWfskq5DDxM3e6Ez5ePCqG5bnPUXR4wL8TZWyoDaUdiWW7bKy')
|
||||||
|
|
||||||
multisig = proto_types.MultisigRedeemScriptType(
|
multisig = proto.MultisigRedeemScriptType(
|
||||||
pubkeys=[
|
pubkeys=[
|
||||||
proto_types.HDNodePathType(node=node, address_n=[1]),
|
proto.HDNodePathType(node=node, address_n=[1]),
|
||||||
proto_types.HDNodePathType(node=node, address_n=[2]),
|
proto.HDNodePathType(node=node, address_n=[2]),
|
||||||
proto_types.HDNodePathType(node=node, address_n=[3])
|
proto.HDNodePathType(node=node, address_n=[3])
|
||||||
],
|
],
|
||||||
signatures=[b'', b'', b''],
|
signatures=[b'', b'', b''],
|
||||||
m=2,
|
m=2,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Let's go to sign with key 10, which is NOT in pubkeys
|
# Let's go to sign with key 10, which is NOT in pubkeys
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=[10],
|
address_n=[10],
|
||||||
prev_hash=TXHASH_c6091a,
|
prev_hash=TXHASH_c6091a,
|
||||||
prev_index=1,
|
prev_index=1,
|
||||||
script_type=proto_types.SPENDMULTISIG,
|
script_type=proto.InputScriptType.SPENDMULTISIG,
|
||||||
multisig=multisig,
|
multisig=multisig,
|
||||||
)
|
)
|
||||||
|
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='12iyMbUb4R2K3gre4dHSrbu5azG5KaqVss',
|
address='12iyMbUb4R2K3gre4dHSrbu5azG5KaqVss',
|
||||||
amount=100000,
|
amount=100000,
|
||||||
script_type=proto_types.PAYTOADDRESS
|
script_type=proto.OutputScriptType.PAYTOADDRESS
|
||||||
)
|
)
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
|
|
|
@ -20,9 +20,8 @@ import unittest
|
||||||
import common
|
import common
|
||||||
import binascii
|
import binascii
|
||||||
|
|
||||||
import trezorlib.messages_pb2 as proto
|
from trezorlib import messages as proto
|
||||||
import trezorlib.ckd_public as bip32
|
import trezorlib.ckd_public as bip32
|
||||||
import trezorlib.types_pb2 as proto_types
|
|
||||||
from trezorlib import tx_api
|
from trezorlib import tx_api
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,101 +65,101 @@ class TestMultisigChange(common.TrezorTest):
|
||||||
# tx: e4bc1ae5e5007a08f2b3926fe11c66612e8f73c6b00c69c7027213b84d259be3
|
# tx: e4bc1ae5e5007a08f2b3926fe11c66612e8f73c6b00c69c7027213b84d259be3
|
||||||
# input 1: 0.001 BTC
|
# input 1: 0.001 BTC
|
||||||
|
|
||||||
multisig_in1 = proto_types.MultisigRedeemScriptType(
|
multisig_in1 = proto.MultisigRedeemScriptType(
|
||||||
pubkeys=[
|
pubkeys=[
|
||||||
proto_types.HDNodePathType(node=node_ext2, address_n=[0, 0]),
|
proto.HDNodePathType(node=node_ext2, address_n=[0, 0]),
|
||||||
proto_types.HDNodePathType(node=node_ext1, address_n=[0, 0]),
|
proto.HDNodePathType(node=node_ext1, address_n=[0, 0]),
|
||||||
proto_types.HDNodePathType(node=node_int, address_n=[0, 0])
|
proto.HDNodePathType(node=node_int, address_n=[0, 0])
|
||||||
],
|
],
|
||||||
signatures=[b'', b'', b''],
|
signatures=[b'', b'', b''],
|
||||||
m=2,
|
m=2,
|
||||||
)
|
)
|
||||||
|
|
||||||
multisig_in2 = proto_types.MultisigRedeemScriptType(
|
multisig_in2 = proto.MultisigRedeemScriptType(
|
||||||
pubkeys=[
|
pubkeys=[
|
||||||
proto_types.HDNodePathType(node=node_ext1, address_n=[0, 1]),
|
proto.HDNodePathType(node=node_ext1, address_n=[0, 1]),
|
||||||
proto_types.HDNodePathType(node=node_ext2, address_n=[0, 1]),
|
proto.HDNodePathType(node=node_ext2, address_n=[0, 1]),
|
||||||
proto_types.HDNodePathType(node=node_int, address_n=[0, 1]),
|
proto.HDNodePathType(node=node_int, address_n=[0, 1]),
|
||||||
],
|
],
|
||||||
signatures=[b'', b'', b''],
|
signatures=[b'', b'', b''],
|
||||||
m=2,
|
m=2,
|
||||||
)
|
)
|
||||||
|
|
||||||
multisig_in3 = proto_types.MultisigRedeemScriptType(
|
multisig_in3 = proto.MultisigRedeemScriptType(
|
||||||
pubkeys=[
|
pubkeys=[
|
||||||
proto_types.HDNodePathType(node=node_ext1, address_n=[0, 1]),
|
proto.HDNodePathType(node=node_ext1, address_n=[0, 1]),
|
||||||
proto_types.HDNodePathType(node=node_ext3, address_n=[0, 1]),
|
proto.HDNodePathType(node=node_ext3, address_n=[0, 1]),
|
||||||
proto_types.HDNodePathType(node=node_int, address_n=[0, 1])
|
proto.HDNodePathType(node=node_int, address_n=[0, 1])
|
||||||
],
|
],
|
||||||
signatures=[b'', b'', b''],
|
signatures=[b'', b'', b''],
|
||||||
m=2,
|
m=2,
|
||||||
)
|
)
|
||||||
|
|
||||||
# 2N9W4z9AhAPaHghtqVQPbaTAGHdbrhKeBQw
|
# 2N9W4z9AhAPaHghtqVQPbaTAGHdbrhKeBQw
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=[45 | 0x80000000, 0, 0, 0],
|
address_n=[45 | 0x80000000, 0, 0, 0],
|
||||||
prev_hash=binascii.unhexlify('16c6c8471b8db7a628f2b2bb86bfeefae1766463ce8692438c7fd3fce3f43ce5'),
|
prev_hash=binascii.unhexlify('16c6c8471b8db7a628f2b2bb86bfeefae1766463ce8692438c7fd3fce3f43ce5'),
|
||||||
prev_index=1,
|
prev_index=1,
|
||||||
script_type=proto_types.SPENDMULTISIG,
|
script_type=proto.InputScriptType.SPENDMULTISIG,
|
||||||
multisig=multisig_in1,
|
multisig=multisig_in1,
|
||||||
)
|
)
|
||||||
|
|
||||||
# 2NDBG6QXQLtnQ3jRGkrqo53BiCeXfQXLdj4
|
# 2NDBG6QXQLtnQ3jRGkrqo53BiCeXfQXLdj4
|
||||||
inp2 = proto_types.TxInputType(
|
inp2 = proto.TxInputType(
|
||||||
address_n=[45 | 0x80000000, 0, 0, 1],
|
address_n=[45 | 0x80000000, 0, 0, 1],
|
||||||
prev_hash=binascii.unhexlify('d80c34ee14143a8bf61125102b7ef594118a3796cad670fa8ee15080ae155318'),
|
prev_hash=binascii.unhexlify('d80c34ee14143a8bf61125102b7ef594118a3796cad670fa8ee15080ae155318'),
|
||||||
prev_index=0,
|
prev_index=0,
|
||||||
script_type=proto_types.SPENDMULTISIG,
|
script_type=proto.InputScriptType.SPENDMULTISIG,
|
||||||
multisig=multisig_in2,
|
multisig=multisig_in2,
|
||||||
)
|
)
|
||||||
|
|
||||||
# 2MvwPWfp2XPU3S1cMwgEMKBPUw38VP5SBE4
|
# 2MvwPWfp2XPU3S1cMwgEMKBPUw38VP5SBE4
|
||||||
inp3 = proto_types.TxInputType(
|
inp3 = proto.TxInputType(
|
||||||
address_n=[45 | 0x80000000, 0, 0, 1],
|
address_n=[45 | 0x80000000, 0, 0, 1],
|
||||||
prev_hash=binascii.unhexlify('b0946dc27ba308a749b11afecc2018980af18f79e89ad6b080b58220d856f739'),
|
prev_hash=binascii.unhexlify('b0946dc27ba308a749b11afecc2018980af18f79e89ad6b080b58220d856f739'),
|
||||||
prev_index=0,
|
prev_index=0,
|
||||||
script_type=proto_types.SPENDMULTISIG,
|
script_type=proto.InputScriptType.SPENDMULTISIG,
|
||||||
multisig=multisig_in3,
|
multisig=multisig_in3,
|
||||||
)
|
)
|
||||||
|
|
||||||
def _responses(self, inp1, inp2, change=0):
|
def _responses(self, inp1, inp2, change=0):
|
||||||
resp = [
|
resp = [
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=inp1.prev_hash)),
|
proto.TxRequest(request_type=proto.RequestType.TXMETA, details=proto.TxRequestDetailsType(tx_hash=inp1.prev_hash)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=inp1.prev_hash)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=inp1.prev_hash)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=inp1.prev_hash)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=inp1.prev_hash)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=inp1.prev_hash)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1, tx_hash=inp1.prev_hash)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=inp2.prev_hash)),
|
proto.TxRequest(request_type=proto.RequestType.TXMETA, details=proto.TxRequestDetailsType(tx_hash=inp2.prev_hash)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=inp2.prev_hash)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=inp2.prev_hash)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=inp2.prev_hash)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=inp2.prev_hash)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=inp2.prev_hash)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1, tx_hash=inp2.prev_hash)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
]
|
]
|
||||||
if change != 1:
|
if change != 1:
|
||||||
resp.append(
|
resp.append(
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput)
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput)
|
||||||
)
|
)
|
||||||
resp.append(
|
resp.append(
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1))
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1))
|
||||||
)
|
)
|
||||||
if change != 2:
|
if change != 2:
|
||||||
resp.append(
|
resp.append(
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput)
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput)
|
||||||
)
|
)
|
||||||
resp += [
|
resp += [
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
]
|
]
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
|
@ -168,16 +167,16 @@ class TestMultisigChange(common.TrezorTest):
|
||||||
def test_external_external(self):
|
def test_external_external(self):
|
||||||
self.setup_mnemonic_nopin_nopassphrase()
|
self.setup_mnemonic_nopin_nopassphrase()
|
||||||
|
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='muevUcG1Bb8eM2nGUGhqmeujHRX7YXjSEu',
|
address='muevUcG1Bb8eM2nGUGhqmeujHRX7YXjSEu',
|
||||||
amount=40000000,
|
amount=40000000,
|
||||||
script_type=proto_types.PAYTOADDRESS
|
script_type=proto.OutputScriptType.PAYTOADDRESS
|
||||||
)
|
)
|
||||||
|
|
||||||
out2 = proto_types.TxOutputType(
|
out2 = proto.TxOutputType(
|
||||||
address='mwdrpMVSJxxsM8f8xbnCHn9ERaRT1NG1UX',
|
address='mwdrpMVSJxxsM8f8xbnCHn9ERaRT1NG1UX',
|
||||||
amount=44000000,
|
amount=44000000,
|
||||||
script_type=proto_types.PAYTOADDRESS
|
script_type=proto.OutputScriptType.PAYTOADDRESS
|
||||||
)
|
)
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
|
@ -190,16 +189,16 @@ class TestMultisigChange(common.TrezorTest):
|
||||||
def test_external_internal(self):
|
def test_external_internal(self):
|
||||||
self.setup_mnemonic_nopin_nopassphrase()
|
self.setup_mnemonic_nopin_nopassphrase()
|
||||||
|
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='muevUcG1Bb8eM2nGUGhqmeujHRX7YXjSEu',
|
address='muevUcG1Bb8eM2nGUGhqmeujHRX7YXjSEu',
|
||||||
amount=40000000,
|
amount=40000000,
|
||||||
script_type=proto_types.PAYTOADDRESS
|
script_type=proto.OutputScriptType.PAYTOADDRESS
|
||||||
)
|
)
|
||||||
|
|
||||||
out2 = proto_types.TxOutputType(
|
out2 = proto.TxOutputType(
|
||||||
address_n=self.client.expand_path("45'/0/1/1"),
|
address_n=self.client.expand_path("45'/0/1/1"),
|
||||||
amount=44000000,
|
amount=44000000,
|
||||||
script_type=proto_types.PAYTOADDRESS
|
script_type=proto.OutputScriptType.PAYTOADDRESS
|
||||||
)
|
)
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
|
@ -212,16 +211,16 @@ class TestMultisigChange(common.TrezorTest):
|
||||||
def test_internal_external(self):
|
def test_internal_external(self):
|
||||||
self.setup_mnemonic_nopin_nopassphrase()
|
self.setup_mnemonic_nopin_nopassphrase()
|
||||||
|
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address_n=self.client.expand_path("45'/0/1/0"),
|
address_n=self.client.expand_path("45'/0/1/0"),
|
||||||
amount=40000000,
|
amount=40000000,
|
||||||
script_type=proto_types.PAYTOADDRESS
|
script_type=proto.OutputScriptType.PAYTOADDRESS
|
||||||
)
|
)
|
||||||
|
|
||||||
out2 = proto_types.TxOutputType(
|
out2 = proto.TxOutputType(
|
||||||
address='mwdrpMVSJxxsM8f8xbnCHn9ERaRT1NG1UX',
|
address='mwdrpMVSJxxsM8f8xbnCHn9ERaRT1NG1UX',
|
||||||
amount=44000000,
|
amount=44000000,
|
||||||
script_type=proto_types.PAYTOADDRESS
|
script_type=proto.OutputScriptType.PAYTOADDRESS
|
||||||
)
|
)
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
|
@ -234,16 +233,16 @@ class TestMultisigChange(common.TrezorTest):
|
||||||
def test_multisig_external_external(self):
|
def test_multisig_external_external(self):
|
||||||
self.setup_mnemonic_nopin_nopassphrase()
|
self.setup_mnemonic_nopin_nopassphrase()
|
||||||
|
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='2N2aFoogGntQFFwdUVPfRmutXD22ThcNTsR',
|
address='2N2aFoogGntQFFwdUVPfRmutXD22ThcNTsR',
|
||||||
amount=40000000,
|
amount=40000000,
|
||||||
script_type=proto_types.PAYTOADDRESS
|
script_type=proto.OutputScriptType.PAYTOADDRESS
|
||||||
)
|
)
|
||||||
|
|
||||||
out2 = proto_types.TxOutputType(
|
out2 = proto.TxOutputType(
|
||||||
address='2NFJjQcU8mw4Z3ywpbek8HL1VoJ27GDrkHw',
|
address='2NFJjQcU8mw4Z3ywpbek8HL1VoJ27GDrkHw',
|
||||||
amount=44000000,
|
amount=44000000,
|
||||||
script_type=proto_types.PAYTOADDRESS
|
script_type=proto.OutputScriptType.PAYTOADDRESS
|
||||||
)
|
)
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
|
@ -256,27 +255,27 @@ class TestMultisigChange(common.TrezorTest):
|
||||||
def test_multisig_change_match_first(self):
|
def test_multisig_change_match_first(self):
|
||||||
self.setup_mnemonic_nopin_nopassphrase()
|
self.setup_mnemonic_nopin_nopassphrase()
|
||||||
|
|
||||||
multisig_out1 = proto_types.MultisigRedeemScriptType(
|
multisig_out1 = proto.MultisigRedeemScriptType(
|
||||||
pubkeys=[
|
pubkeys=[
|
||||||
proto_types.HDNodePathType(node=self.node_ext2, address_n=[1, 0]),
|
proto.HDNodePathType(node=self.node_ext2, address_n=[1, 0]),
|
||||||
proto_types.HDNodePathType(node=self.node_ext1, address_n=[1, 0]),
|
proto.HDNodePathType(node=self.node_ext1, address_n=[1, 0]),
|
||||||
proto_types.HDNodePathType(node=self.node_int, address_n=[1, 0])
|
proto.HDNodePathType(node=self.node_int, address_n=[1, 0])
|
||||||
],
|
],
|
||||||
signatures=[b'', b'', b''],
|
signatures=[b'', b'', b''],
|
||||||
m=2,
|
m=2,
|
||||||
)
|
)
|
||||||
|
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address_n=[0x80000000 | 45, 0, 1, 0],
|
address_n=[0x80000000 | 45, 0, 1, 0],
|
||||||
multisig=multisig_out1,
|
multisig=multisig_out1,
|
||||||
amount=40000000,
|
amount=40000000,
|
||||||
script_type=proto_types.PAYTOMULTISIG
|
script_type=proto.OutputScriptType.PAYTOMULTISIG
|
||||||
)
|
)
|
||||||
|
|
||||||
out2 = proto_types.TxOutputType(
|
out2 = proto.TxOutputType(
|
||||||
address='2NFJjQcU8mw4Z3ywpbek8HL1VoJ27GDrkHw',
|
address='2NFJjQcU8mw4Z3ywpbek8HL1VoJ27GDrkHw',
|
||||||
amount=44000000,
|
amount=44000000,
|
||||||
script_type=proto_types.PAYTOADDRESS
|
script_type=proto.OutputScriptType.PAYTOADDRESS
|
||||||
)
|
)
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
|
@ -289,27 +288,27 @@ class TestMultisigChange(common.TrezorTest):
|
||||||
def test_multisig_change_match_second(self):
|
def test_multisig_change_match_second(self):
|
||||||
self.setup_mnemonic_nopin_nopassphrase()
|
self.setup_mnemonic_nopin_nopassphrase()
|
||||||
|
|
||||||
multisig_out2 = proto_types.MultisigRedeemScriptType(
|
multisig_out2 = proto.MultisigRedeemScriptType(
|
||||||
pubkeys=[
|
pubkeys=[
|
||||||
proto_types.HDNodePathType(node=self.node_ext1, address_n=[1, 1]),
|
proto.HDNodePathType(node=self.node_ext1, address_n=[1, 1]),
|
||||||
proto_types.HDNodePathType(node=self.node_ext2, address_n=[1, 1]),
|
proto.HDNodePathType(node=self.node_ext2, address_n=[1, 1]),
|
||||||
proto_types.HDNodePathType(node=self.node_int, address_n=[1, 1])
|
proto.HDNodePathType(node=self.node_int, address_n=[1, 1])
|
||||||
],
|
],
|
||||||
signatures=[b'', b'', b''],
|
signatures=[b'', b'', b''],
|
||||||
m=2,
|
m=2,
|
||||||
)
|
)
|
||||||
|
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='2N2aFoogGntQFFwdUVPfRmutXD22ThcNTsR',
|
address='2N2aFoogGntQFFwdUVPfRmutXD22ThcNTsR',
|
||||||
amount=40000000,
|
amount=40000000,
|
||||||
script_type=proto_types.PAYTOADDRESS
|
script_type=proto.OutputScriptType.PAYTOADDRESS
|
||||||
)
|
)
|
||||||
|
|
||||||
out2 = proto_types.TxOutputType(
|
out2 = proto.TxOutputType(
|
||||||
address_n=[0x80000000 | 45, 0, 1, 1],
|
address_n=[0x80000000 | 45, 0, 1, 1],
|
||||||
multisig=multisig_out2,
|
multisig=multisig_out2,
|
||||||
amount=44000000,
|
amount=44000000,
|
||||||
script_type=proto_types.PAYTOMULTISIG
|
script_type=proto.OutputScriptType.PAYTOMULTISIG
|
||||||
)
|
)
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
|
@ -322,27 +321,27 @@ class TestMultisigChange(common.TrezorTest):
|
||||||
def test_multisig_mismatch_change(self):
|
def test_multisig_mismatch_change(self):
|
||||||
self.setup_mnemonic_nopin_nopassphrase()
|
self.setup_mnemonic_nopin_nopassphrase()
|
||||||
|
|
||||||
multisig_out2 = proto_types.MultisigRedeemScriptType(
|
multisig_out2 = proto.MultisigRedeemScriptType(
|
||||||
pubkeys=[
|
pubkeys=[
|
||||||
proto_types.HDNodePathType(node=self.node_ext1, address_n=[1, 0]),
|
proto.HDNodePathType(node=self.node_ext1, address_n=[1, 0]),
|
||||||
proto_types.HDNodePathType(node=self.node_int, address_n=[1, 0]),
|
proto.HDNodePathType(node=self.node_int, address_n=[1, 0]),
|
||||||
proto_types.HDNodePathType(node=self.node_ext3, address_n=[1, 0])
|
proto.HDNodePathType(node=self.node_ext3, address_n=[1, 0])
|
||||||
],
|
],
|
||||||
signatures=[b'', b'', b''],
|
signatures=[b'', b'', b''],
|
||||||
m=2,
|
m=2,
|
||||||
)
|
)
|
||||||
|
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='2N2aFoogGntQFFwdUVPfRmutXD22ThcNTsR',
|
address='2N2aFoogGntQFFwdUVPfRmutXD22ThcNTsR',
|
||||||
amount=40000000,
|
amount=40000000,
|
||||||
script_type=proto_types.PAYTOADDRESS
|
script_type=proto.OutputScriptType.PAYTOADDRESS
|
||||||
)
|
)
|
||||||
|
|
||||||
out2 = proto_types.TxOutputType(
|
out2 = proto.TxOutputType(
|
||||||
address_n=[0x80000000 | 45, 0, 1, 0],
|
address_n=[0x80000000 | 45, 0, 1, 0],
|
||||||
multisig=multisig_out2,
|
multisig=multisig_out2,
|
||||||
amount=44000000,
|
amount=44000000,
|
||||||
script_type=proto_types.PAYTOMULTISIG
|
script_type=proto.OutputScriptType.PAYTOMULTISIG
|
||||||
)
|
)
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
|
@ -355,27 +354,27 @@ class TestMultisigChange(common.TrezorTest):
|
||||||
def test_multisig_mismatch_inputs(self):
|
def test_multisig_mismatch_inputs(self):
|
||||||
self.setup_mnemonic_nopin_nopassphrase()
|
self.setup_mnemonic_nopin_nopassphrase()
|
||||||
|
|
||||||
multisig_out1 = proto_types.MultisigRedeemScriptType(
|
multisig_out1 = proto.MultisigRedeemScriptType(
|
||||||
pubkeys=[
|
pubkeys=[
|
||||||
proto_types.HDNodePathType(node=self.node_ext2, address_n=[1, 0]),
|
proto.HDNodePathType(node=self.node_ext2, address_n=[1, 0]),
|
||||||
proto_types.HDNodePathType(node=self.node_ext1, address_n=[1, 0]),
|
proto.HDNodePathType(node=self.node_ext1, address_n=[1, 0]),
|
||||||
proto_types.HDNodePathType(node=self.node_int, address_n=[1, 0])
|
proto.HDNodePathType(node=self.node_int, address_n=[1, 0])
|
||||||
],
|
],
|
||||||
signatures=[b'', b'', b''],
|
signatures=[b'', b'', b''],
|
||||||
m=2,
|
m=2,
|
||||||
)
|
)
|
||||||
|
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address_n=[0x80000000 | 45, 0, 1, 0],
|
address_n=[0x80000000 | 45, 0, 1, 0],
|
||||||
multisig=multisig_out1,
|
multisig=multisig_out1,
|
||||||
amount=40000000,
|
amount=40000000,
|
||||||
script_type=proto_types.PAYTOMULTISIG
|
script_type=proto.OutputScriptType.PAYTOMULTISIG
|
||||||
)
|
)
|
||||||
|
|
||||||
out2 = proto_types.TxOutputType(
|
out2 = proto.TxOutputType(
|
||||||
address='2NFJjQcU8mw4Z3ywpbek8HL1VoJ27GDrkHw',
|
address='2NFJjQcU8mw4Z3ywpbek8HL1VoJ27GDrkHw',
|
||||||
amount=65000000,
|
amount=65000000,
|
||||||
script_type=proto_types.PAYTOADDRESS
|
script_type=proto.OutputScriptType.PAYTOADDRESS
|
||||||
)
|
)
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
|
|
|
@ -20,8 +20,7 @@ import unittest
|
||||||
import binascii
|
import binascii
|
||||||
import common
|
import common
|
||||||
|
|
||||||
import trezorlib.messages_pb2 as proto
|
from trezorlib import messages as proto
|
||||||
import trezorlib.types_pb2 as proto_types
|
|
||||||
from trezorlib.client import CallException
|
from trezorlib.client import CallException
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,43 +35,43 @@ class TestOpReturn(common.TrezorTest):
|
||||||
# tx: d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882
|
# tx: d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882
|
||||||
# input 0: 0.0039 BTC
|
# input 0: 0.0039 BTC
|
||||||
|
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e
|
address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e
|
||||||
# amount=390000,
|
# amount=390000,
|
||||||
prev_hash=TXHASH_d5f65e,
|
prev_hash=TXHASH_d5f65e,
|
||||||
prev_index=0,
|
prev_index=0,
|
||||||
)
|
)
|
||||||
|
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1',
|
address='1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1',
|
||||||
amount=390000 - 10000,
|
amount=390000 - 10000,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
|
|
||||||
out2 = proto_types.TxOutputType(
|
out2 = proto.TxOutputType(
|
||||||
op_return_data=b'test of the op_return data',
|
op_return_data=b'test of the op_return data',
|
||||||
amount=0,
|
amount=0,
|
||||||
script_type=proto_types.PAYTOOPRETURN,
|
script_type=proto.OutputScriptType.PAYTOOPRETURN,
|
||||||
)
|
)
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=TXHASH_d5f65e)),
|
proto.TxRequest(request_type=proto.RequestType.TXMETA, details=proto.TxRequestDetailsType(tx_hash=TXHASH_d5f65e)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_d5f65e)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_d5f65e)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_d5f65e)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_d5f65e)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_d5f65e)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_d5f65e)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=1)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=1)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, out2])
|
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, out2])
|
||||||
|
|
||||||
|
@ -84,33 +83,33 @@ class TestOpReturn(common.TrezorTest):
|
||||||
# tx: d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882
|
# tx: d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882
|
||||||
# input 0: 0.0039 BTC
|
# input 0: 0.0039 BTC
|
||||||
|
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e
|
address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e
|
||||||
# amount=390000,
|
# amount=390000,
|
||||||
prev_hash=TXHASH_d5f65e,
|
prev_hash=TXHASH_d5f65e,
|
||||||
prev_index=0,
|
prev_index=0,
|
||||||
)
|
)
|
||||||
|
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1',
|
address='1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1',
|
||||||
amount=390000 - 10000 - 10000,
|
amount=390000 - 10000 - 10000,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
|
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
op_return_data=b'test of the op_return data',
|
op_return_data=b'test of the op_return data',
|
||||||
amount=10000,
|
amount=10000,
|
||||||
script_type=proto_types.PAYTOOPRETURN,
|
script_type=proto.OutputScriptType.PAYTOOPRETURN,
|
||||||
)
|
)
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=TXHASH_d5f65e)),
|
proto.TxRequest(request_type=proto.RequestType.TXMETA, details=proto.TxRequestDetailsType(tx_hash=TXHASH_d5f65e)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_d5f65e)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_d5f65e)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_d5f65e)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_d5f65e)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_d5f65e)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_d5f65e)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.Failure()
|
proto.Failure()
|
||||||
])
|
])
|
||||||
self.assertRaises(CallException, self.client.sign_tx, 'Bitcoin', [inp1, ], [out1, ])
|
self.assertRaises(CallException, self.client.sign_tx, 'Bitcoin', [inp1, ], [out1, ])
|
||||||
|
|
|
@ -22,8 +22,8 @@ import time
|
||||||
import unittest
|
import unittest
|
||||||
import common
|
import common
|
||||||
|
|
||||||
from trezorlib import messages_pb2 as proto
|
from trezorlib import messages as proto
|
||||||
from trezorlib.client import PinException
|
from trezorlib.client import PinException, CallException
|
||||||
|
|
||||||
# FIXME TODO Add passphrase tests
|
# FIXME TODO Add passphrase tests
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ class TestProtectCall(common.TrezorTest):
|
||||||
self.setup_mnemonic_nopin_nopassphrase()
|
self.setup_mnemonic_nopin_nopassphrase()
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
self.assertEqual(self.client.debug.read_pin()[0], '')
|
self.assertEqual(self.client.debug.read_pin()[0], None)
|
||||||
self.client.set_expected_responses([proto.Success()])
|
self.client.set_expected_responses([proto.Success()])
|
||||||
self._some_protected_call(False, True, True)
|
self._some_protected_call(False, True, True)
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,7 @@ import unittest
|
||||||
import common
|
import common
|
||||||
import binascii
|
import binascii
|
||||||
|
|
||||||
from trezorlib import messages_pb2 as proto
|
from trezorlib import messages as proto
|
||||||
from trezorlib import types_pb2 as proto_types
|
|
||||||
|
|
||||||
|
|
||||||
TXHASH_d5f65e = binascii.unhexlify('d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882')
|
TXHASH_d5f65e = binascii.unhexlify('d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882')
|
||||||
|
@ -158,42 +157,19 @@ class TestProtectionLevels(common.TrezorTest):
|
||||||
binascii.unhexlify('209e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80'),
|
binascii.unhexlify('209e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80'),
|
||||||
'This is an example of a signed message.')
|
'This is an example of a signed message.')
|
||||||
|
|
||||||
"""
|
|
||||||
def test_simplesigntx(self):
|
|
||||||
self.setup_mnemonic_pin_passphrase()
|
|
||||||
|
|
||||||
inp1 = proto_types.TxInputType(address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e
|
|
||||||
prev_hash=TXHASH_d5f65e,
|
|
||||||
prev_index=0,
|
|
||||||
)
|
|
||||||
|
|
||||||
out1 = proto_types.TxOutputType(address='1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1',
|
|
||||||
amount=390000 - 10000,
|
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
|
||||||
)
|
|
||||||
|
|
||||||
with self.client:
|
|
||||||
self.client.set_expected_responses([proto.PinMatrixRequest(),
|
|
||||||
proto.PassphraseRequest(),
|
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED)])
|
|
||||||
self.client.simple_sign_tx('Bitcoin', [inp1, ], [out1, ])
|
|
||||||
"""
|
|
||||||
|
|
||||||
def test_signtx(self):
|
def test_signtx(self):
|
||||||
self.setup_mnemonic_pin_passphrase()
|
self.setup_mnemonic_pin_passphrase()
|
||||||
|
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e
|
address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e
|
||||||
prev_hash=TXHASH_d5f65e,
|
prev_hash=TXHASH_d5f65e,
|
||||||
prev_index=0,
|
prev_index=0,
|
||||||
)
|
)
|
||||||
|
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address='1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1',
|
address='1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1',
|
||||||
amount=390000 - 10000,
|
amount=390000 - 10000,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
|
|
||||||
with self.client:
|
with self.client:
|
||||||
|
@ -201,18 +177,18 @@ class TestProtectionLevels(common.TrezorTest):
|
||||||
self.client.set_expected_responses([
|
self.client.set_expected_responses([
|
||||||
proto.PinMatrixRequest(),
|
proto.PinMatrixRequest(),
|
||||||
proto.PassphraseRequest(),
|
proto.PassphraseRequest(),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=TXHASH_d5f65e)),
|
proto.TxRequest(request_type=proto.RequestType.TXMETA, details=proto.TxRequestDetailsType(tx_hash=TXHASH_d5f65e)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_d5f65e)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_d5f65e)),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_d5f65e)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=1, tx_hash=TXHASH_d5f65e)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_d5f65e)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0, tx_hash=TXHASH_d5f65e)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput),
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
proto.ButtonRequest(code=proto_types.ButtonRequest_SignTx),
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXOUTPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
|
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||||
proto.TxRequest(request_type=proto_types.TXFINISHED),
|
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||||
])
|
])
|
||||||
self.client.sign_tx('Bitcoin', [inp1, ], [out1, ])
|
self.client.sign_tx('Bitcoin', [inp1, ], [out1, ])
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ import binascii
|
||||||
import sys
|
import sys
|
||||||
import common
|
import common
|
||||||
|
|
||||||
import trezorlib.types_pb2 as proto_types
|
from trezorlib import messages as proto
|
||||||
|
|
||||||
if sys.version_info < (3,):
|
if sys.version_info < (3,):
|
||||||
def byteindex(data, index):
|
def byteindex(data, index):
|
||||||
|
@ -45,7 +45,7 @@ class TestZeroSig(common.TrezorTest):
|
||||||
# tx: d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882
|
# tx: d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882
|
||||||
# input 0: 0.0039 BTC
|
# input 0: 0.0039 BTC
|
||||||
|
|
||||||
inp1 = proto_types.TxInputType(address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e
|
inp1 = proto.TxInputType(address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e
|
||||||
# amount=390000,
|
# amount=390000,
|
||||||
prev_hash=TXHASH_d5f65e,
|
prev_hash=TXHASH_d5f65e,
|
||||||
prev_index=0,
|
prev_index=0,
|
||||||
|
@ -54,9 +54,9 @@ class TestZeroSig(common.TrezorTest):
|
||||||
msg = self.client._prepare_sign_tx('Bitcoin', [inp1, ], [])
|
msg = self.client._prepare_sign_tx('Bitcoin', [inp1, ], [])
|
||||||
|
|
||||||
for n in range(3500, 200000):
|
for n in range(3500, 200000):
|
||||||
out1 = proto_types.TxOutputType(address_n=[n],
|
out1 = proto.TxOutputType(address_n=[n],
|
||||||
amount=390000 - 10000,
|
amount=390000 - 10000,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
msg.ClearField('outputs')
|
msg.ClearField('outputs')
|
||||||
msg.outputs.extend([out1, ])
|
msg.outputs.extend([out1, ])
|
||||||
|
@ -74,7 +74,7 @@ class TestZeroSig(common.TrezorTest):
|
||||||
def test_one_zero_signature(self):
|
def test_one_zero_signature(self):
|
||||||
self.setup_mnemonic_nopin_nopassphrase()
|
self.setup_mnemonic_nopin_nopassphrase()
|
||||||
|
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e
|
address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e
|
||||||
# amount=390000,
|
# amount=390000,
|
||||||
prev_hash=TXHASH_d5f65e,
|
prev_hash=TXHASH_d5f65e,
|
||||||
|
@ -82,10 +82,10 @@ class TestZeroSig(common.TrezorTest):
|
||||||
)
|
)
|
||||||
|
|
||||||
# Following address_n has been mined by 'test_mine_zero_signature'
|
# Following address_n has been mined by 'test_mine_zero_signature'
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address_n=[177],
|
address_n=[177],
|
||||||
amount=390000 - 10000,
|
amount=390000 - 10000,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
|
|
||||||
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, ])
|
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, ])
|
||||||
|
@ -97,7 +97,7 @@ class TestZeroSig(common.TrezorTest):
|
||||||
def test_two_zero_signature(self):
|
def test_two_zero_signature(self):
|
||||||
self.setup_mnemonic_nopin_nopassphrase()
|
self.setup_mnemonic_nopin_nopassphrase()
|
||||||
|
|
||||||
inp1 = proto_types.TxInputType(
|
inp1 = proto.TxInputType(
|
||||||
address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e
|
address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e
|
||||||
# amount=390000,
|
# amount=390000,
|
||||||
prev_hash=TXHASH_d5f65e,
|
prev_hash=TXHASH_d5f65e,
|
||||||
|
@ -105,10 +105,10 @@ class TestZeroSig(common.TrezorTest):
|
||||||
)
|
)
|
||||||
|
|
||||||
# Following address_n has been mined by 'test_mine_zero_signature'
|
# Following address_n has been mined by 'test_mine_zero_signature'
|
||||||
out1 = proto_types.TxOutputType(
|
out1 = proto.TxOutputType(
|
||||||
address_n=[16518],
|
address_n=[16518],
|
||||||
amount=390000 - 10000,
|
amount=390000 - 10000,
|
||||||
script_type=proto_types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
)
|
)
|
||||||
|
|
||||||
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, ])
|
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, ])
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
#!/bin/bash
|
||||||
|
CURDIR=$(pwd)
|
||||||
|
mkdir -p $CURDIR/pb2/
|
||||||
|
touch $CURDIR/pb2/__init__.py
|
||||||
|
|
||||||
|
mkdir -p ../trezorlib/messages
|
||||||
|
|
||||||
|
INDEX=../trezorlib/messages/__init__.py
|
||||||
|
rm -f $INDEX
|
||||||
|
echo '# Automatically generated by pb2py' >> $INDEX
|
||||||
|
echo 'from __future__ import absolute_import' >> $INDEX
|
||||||
|
echo '' >> $INDEX
|
||||||
|
|
||||||
|
for i in types messages storage ; do
|
||||||
|
# Compile .proto files to python2 modules using google protobuf library
|
||||||
|
cd $CURDIR/../../trezor-common/protob
|
||||||
|
protoc --python_out=$CURDIR/pb2/ -I/usr/include -I. $i.proto
|
||||||
|
done
|
||||||
|
|
||||||
|
# hack to make output python 3 compatible
|
||||||
|
sed -i 's/^import types_pb2/from . import types_pb2/g' $CURDIR/pb2/messages_pb2.py
|
||||||
|
sed -i 's/^import types_pb2/from . import types_pb2/g' $CURDIR/pb2/storage_pb2.py
|
||||||
|
|
||||||
|
for i in types messages storage ; do
|
||||||
|
# Convert google protobuf library to trezor's internal format
|
||||||
|
cd $CURDIR
|
||||||
|
./pb2py -p $CURDIR -l $INDEX $i ../trezorlib/messages/
|
||||||
|
done
|
||||||
|
|
||||||
|
rm -rf $CURDIR/pb2/
|
|
@ -0,0 +1,213 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# Converts Google's protobuf python definitions of TREZOR wire messages
|
||||||
|
# to plain-python objects as used in TREZOR Core and python-trezor
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
from google.protobuf.internal.enum_type_wrapper import EnumTypeWrapper
|
||||||
|
|
||||||
|
|
||||||
|
def process_type(t, cls, msg_id, indexfile, is_upy):
|
||||||
|
print(" * type %s" % t)
|
||||||
|
|
||||||
|
imports = []
|
||||||
|
out = ["", "", "class %s(p.MessageType):" % t, ]
|
||||||
|
|
||||||
|
if cls.DESCRIPTOR.fields_by_name:
|
||||||
|
out.append(" FIELDS = {")
|
||||||
|
elif msg_id is None:
|
||||||
|
out.append(" pass")
|
||||||
|
|
||||||
|
for v in sorted(cls.DESCRIPTOR.fields_by_name.values(), key=lambda x: x.number):
|
||||||
|
number = v.number
|
||||||
|
fieldname = v.name
|
||||||
|
type = None
|
||||||
|
repeated = v.label == 3
|
||||||
|
required = v.label == 2
|
||||||
|
|
||||||
|
# print v.has_default_value, v.default_value
|
||||||
|
|
||||||
|
if v.type in (4, 13, 14):
|
||||||
|
# TYPE_UINT64 = 4
|
||||||
|
# TYPE_UINT32 = 13
|
||||||
|
# TYPE_ENUM = 14
|
||||||
|
type = 'p.UVarintType'
|
||||||
|
|
||||||
|
elif v.type in (17,):
|
||||||
|
# TYPE_SINT32 = 17
|
||||||
|
type = 'p.Sint32Type'
|
||||||
|
|
||||||
|
elif v.type == 9:
|
||||||
|
# TYPE_STRING = 9
|
||||||
|
type = 'p.UnicodeType'
|
||||||
|
|
||||||
|
elif v.type == 8:
|
||||||
|
# TYPE_BOOL = 8
|
||||||
|
type = 'p.BoolType'
|
||||||
|
|
||||||
|
elif v.type == 12:
|
||||||
|
# TYPE_BYTES = 12
|
||||||
|
type = 'p.BytesType'
|
||||||
|
|
||||||
|
elif v.type == 11:
|
||||||
|
# TYPE_MESSAGE = 1
|
||||||
|
type = v.message_type.name
|
||||||
|
imports.append("from .%s import %s" %
|
||||||
|
(v.message_type.name, v.message_type.name))
|
||||||
|
|
||||||
|
else:
|
||||||
|
raise Exception("Unknown field type %s for field %s" %
|
||||||
|
(v.type, fieldname))
|
||||||
|
|
||||||
|
if required:
|
||||||
|
comment = ' # required'
|
||||||
|
elif v.has_default_value:
|
||||||
|
comment = ' # default=%s' % repr(v.default_value)
|
||||||
|
else:
|
||||||
|
comment = ''
|
||||||
|
|
||||||
|
if repeated:
|
||||||
|
flags = 'p.FLAG_REPEATED'
|
||||||
|
else:
|
||||||
|
flags = '0'
|
||||||
|
|
||||||
|
out.append(" %d: ('%s', %s, %s),%s" %
|
||||||
|
(number, fieldname, type, flags, comment))
|
||||||
|
|
||||||
|
# print fieldname, number, type, repeated, comment
|
||||||
|
# print v.__dict__
|
||||||
|
# print v.CPPTYPE_STRING
|
||||||
|
# print v.LABEL_REPEATED
|
||||||
|
# print v.enum_type
|
||||||
|
# v.has_default_value, v.default_value
|
||||||
|
# v.label == 3 # repeated
|
||||||
|
# print v.number
|
||||||
|
|
||||||
|
if cls.DESCRIPTOR.fields_by_name:
|
||||||
|
out.append(" }")
|
||||||
|
|
||||||
|
if msg_id is not None:
|
||||||
|
out.append(" MESSAGE_WIRE_TYPE = %d" % msg_id)
|
||||||
|
if indexfile is not None:
|
||||||
|
if is_upy:
|
||||||
|
indexfile.write("%s = const(%d)\n" % (t, msg_id))
|
||||||
|
else:
|
||||||
|
indexfile.write("%s = %d\n" % (t, msg_id))
|
||||||
|
|
||||||
|
# Remove duplicate imports
|
||||||
|
imports = list(set(imports))
|
||||||
|
|
||||||
|
if is_upy:
|
||||||
|
imports = ['import protobuf as p'] + imports
|
||||||
|
else:
|
||||||
|
imports = ['from __future__ import absolute_import',
|
||||||
|
'from .. import protobuf as p'] + imports
|
||||||
|
|
||||||
|
|
||||||
|
return imports + out
|
||||||
|
|
||||||
|
|
||||||
|
def process_enum(t, cls, is_upy):
|
||||||
|
out = []
|
||||||
|
|
||||||
|
if is_upy:
|
||||||
|
out += ("from micropython import const", "")
|
||||||
|
|
||||||
|
print(" * enum %s" % t)
|
||||||
|
|
||||||
|
for k, v in cls.items():
|
||||||
|
# Remove type name from the beginning of the constant
|
||||||
|
# For example "PinMatrixRequestType_Current" -> "Current"
|
||||||
|
if k.startswith("%s_" % t):
|
||||||
|
k = k.replace("%s_" % t, '')
|
||||||
|
|
||||||
|
# If type ends with *Type, but constant use type name without *Type, remove it too :)
|
||||||
|
# For example "ButtonRequestType & ButtonRequest_Other" => "Other"
|
||||||
|
if t.endswith("Type") and k.startswith("%s_" % t.replace("Type", '')):
|
||||||
|
k = k.replace("%s_" % t.replace("Type", ''), '')
|
||||||
|
|
||||||
|
if is_upy:
|
||||||
|
out.append("%s = const(%s)" % (k, v))
|
||||||
|
else:
|
||||||
|
out.append("%s = %s" % (k, v))
|
||||||
|
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
def find_msg_type(msg_types, t):
|
||||||
|
for k, v in msg_types:
|
||||||
|
msg_name = k.replace('MessageType_', '')
|
||||||
|
if msg_name == t:
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
|
def process_module(mod, genpath, indexfile, modlist, is_upy):
|
||||||
|
|
||||||
|
print("Processing module %s" % mod.__name__)
|
||||||
|
types = dict([(name, cls)
|
||||||
|
for name, cls in mod.__dict__.items() if isinstance(cls, type)])
|
||||||
|
|
||||||
|
msg_types = __import__('pb2', globals(), locals(), [
|
||||||
|
'messages_pb2', ]).messages_pb2.MessageType.items()
|
||||||
|
|
||||||
|
for t, cls in sorted(types.items()):
|
||||||
|
# Find message type for given class
|
||||||
|
msg_id = find_msg_type(msg_types, t)
|
||||||
|
|
||||||
|
out = process_type(t, cls, msg_id, indexfile, is_upy)
|
||||||
|
|
||||||
|
write_to_file(genpath, t, out)
|
||||||
|
if modlist:
|
||||||
|
modlist.write("from .%s import *\n" % t)
|
||||||
|
|
||||||
|
enums = dict([(name, cls) for name, cls in mod.__dict__.items()
|
||||||
|
if isinstance(cls, EnumTypeWrapper)])
|
||||||
|
|
||||||
|
for t, cls in enums.items():
|
||||||
|
out = process_enum(t, cls, is_upy)
|
||||||
|
write_to_file(genpath, t, out)
|
||||||
|
if modlist:
|
||||||
|
modlist.write("from . import %s\n" % t)
|
||||||
|
|
||||||
|
|
||||||
|
def write_to_file(genpath, t, out):
|
||||||
|
# Write generated sourcecode to given file
|
||||||
|
f = open(os.path.join(genpath, "%s.py" % t), 'w')
|
||||||
|
out = ["# Automatically generated by pb2py"] + out
|
||||||
|
|
||||||
|
data = "\n".join(out) + "\n"
|
||||||
|
|
||||||
|
f.write(data)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument('modulename', type=str, help="Name of module to generate")
|
||||||
|
parser.add_argument('genpath', type=str, help="Directory for generated source code")
|
||||||
|
parser.add_argument('-i', '--indexfile', type=str, help="[optional] Generate index file of wire types")
|
||||||
|
parser.add_argument('-l', '--modlist', type=str, help="[optional] Generate list of modules")
|
||||||
|
parser.add_argument('-p', '--protopath', type=str, help="[optional] Path to search for pregenerated Google's python sources")
|
||||||
|
parser.add_argument('-m', '--micropython', action='store_true', help="Use micropython-favoured source code")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if args.indexfile:
|
||||||
|
indexfile = open(args.indexfile, 'a')
|
||||||
|
else:
|
||||||
|
indexfile = None
|
||||||
|
|
||||||
|
if args.modlist:
|
||||||
|
modlist = open(args.modlist, 'a')
|
||||||
|
else:
|
||||||
|
modlist = None
|
||||||
|
|
||||||
|
if args.protopath:
|
||||||
|
sys.path.append(args.protopath)
|
||||||
|
|
||||||
|
# Dynamically load module from argv[1]
|
||||||
|
tmp = __import__('pb2', globals(), locals(), ['%s_pb2' % args.modulename])
|
||||||
|
mod = getattr(tmp, "%s_pb2" % args.modulename)
|
||||||
|
|
||||||
|
process_module(mod, args.genpath, indexfile, modlist, args.micropython)
|
45
trezorctl
45
trezorctl
|
@ -28,7 +28,8 @@ import json
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from trezorlib.client import TrezorClient, TrezorClientVerbose, CallException
|
from trezorlib.client import TrezorClient, TrezorClientVerbose, CallException
|
||||||
import trezorlib.types_pb2 as types
|
from trezorlib import messages as proto
|
||||||
|
from trezorlib import protobuf
|
||||||
from trezorlib.coins import coins_txapi
|
from trezorlib.coins import coins_txapi
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,16 +79,12 @@ def cli(ctx, transport, path, verbose, is_json):
|
||||||
@cli.resultcallback()
|
@cli.resultcallback()
|
||||||
def print_result(res, transport, path, verbose, is_json):
|
def print_result(res, transport, path, verbose, is_json):
|
||||||
if is_json:
|
if is_json:
|
||||||
from google.protobuf import json_format, message
|
if issubclass(res.__class__, protobuf.MessageType):
|
||||||
if isinstance(res, message.Message):
|
click.echo(json.dumps({res.__class__.__name__: res.__dict__}))
|
||||||
click.echo(json_format.MessageToJson(res, preserving_proto_field_name=True))
|
|
||||||
else:
|
else:
|
||||||
click.echo(json.dumps(res, sort_keys=True, indent=4))
|
click.echo(json.dumps(res, sort_keys=True, indent=4))
|
||||||
else:
|
else:
|
||||||
from google.protobuf import text_format, message
|
if isinstance(res, list):
|
||||||
if isinstance(res, message.Message):
|
|
||||||
click.echo('%s {\n%s}' % (res.DESCRIPTOR.name, text_format.MessageToString(res, indent=4)))
|
|
||||||
elif isinstance(res, list):
|
|
||||||
for line in res:
|
for line in res:
|
||||||
click.echo(line)
|
click.echo(line)
|
||||||
elif isinstance(res, dict):
|
elif isinstance(res, dict):
|
||||||
|
@ -219,7 +216,7 @@ def set_homescreen(connect, filename):
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
im = Image.open(filename)
|
im = Image.open(filename)
|
||||||
if im.size != (128, 64):
|
if im.size != (128, 64):
|
||||||
raise CallException(types.Failure_DataError, 'Wrong size of the image')
|
raise CallException(proto.FailureType.DataError, 'Wrong size of the image')
|
||||||
im = im.convert('1')
|
im = im.convert('1')
|
||||||
pix = im.load()
|
pix = im.load()
|
||||||
img = bytearray(1024)
|
img = bytearray(1024)
|
||||||
|
@ -257,7 +254,7 @@ def wipe_device(connect):
|
||||||
@click.pass_obj
|
@click.pass_obj
|
||||||
def load_device(connect, mnemonic, expand, xprv, pin, passphrase_protection, label, ignore_checksum, slip0014):
|
def load_device(connect, mnemonic, expand, xprv, pin, passphrase_protection, label, ignore_checksum, slip0014):
|
||||||
if not mnemonic and not xprv and not slip0014:
|
if not mnemonic and not xprv and not slip0014:
|
||||||
raise CallException(types.Failure_DataError, 'Please provide mnemonic or xprv')
|
raise CallException(proto.FailureType.DataError, 'Please provide mnemonic or xprv')
|
||||||
|
|
||||||
client = connect()
|
client = connect()
|
||||||
if mnemonic:
|
if mnemonic:
|
||||||
|
@ -298,8 +295,8 @@ def load_device(connect, mnemonic, expand, xprv, pin, passphrase_protection, lab
|
||||||
@click.pass_obj
|
@click.pass_obj
|
||||||
def recovery_device(connect, words, expand, pin_protection, passphrase_protection, label, rec_type, dry_run):
|
def recovery_device(connect, words, expand, pin_protection, passphrase_protection, label, rec_type, dry_run):
|
||||||
typemap = {
|
typemap = {
|
||||||
'scrambled': types.RecoveryDeviceType_ScrambledWords,
|
'scrambled': proto.RecoveryDeviceType.ScrambledWords,
|
||||||
'matrix': types.RecoveryDeviceType_Matrix
|
'matrix': proto.RecoveryDeviceType.Matrix
|
||||||
}
|
}
|
||||||
return connect().recovery_device(
|
return connect().recovery_device(
|
||||||
int(words),
|
int(words),
|
||||||
|
@ -385,7 +382,7 @@ def firmware_update(connect, filename, url, version, skip_check):
|
||||||
if fp[:8] == b'54525a52' or fp[:8] == b'54525a56':
|
if fp[:8] == b'54525a52' or fp[:8] == b'54525a56':
|
||||||
fp = binascii.unhexlify(fp)
|
fp = binascii.unhexlify(fp)
|
||||||
if fp[:4] != b'TRZR' and fp[:4] != b'TRZV':
|
if fp[:4] != b'TRZR' and fp[:4] != b'TRZV':
|
||||||
raise CallException(types.Failure_FirmwareError, 'TREZOR firmware header expected')
|
raise CallException(proto.FailureType.FirmwareError, 'TREZOR firmware header expected')
|
||||||
|
|
||||||
click.echo('Please confirm action on device...')
|
click.echo('Please confirm action on device...')
|
||||||
|
|
||||||
|
@ -414,9 +411,9 @@ def get_address(connect, coin, address, script_type, show_display):
|
||||||
client = connect()
|
client = connect()
|
||||||
address_n = client.expand_path(address)
|
address_n = client.expand_path(address)
|
||||||
typemap = {
|
typemap = {
|
||||||
'address': types.SPENDADDRESS,
|
'address': proto.OutputScriptType.SPENDADDRESS,
|
||||||
'segwit': types.SPENDWITNESS,
|
'segwit': proto.OutputScriptType.SPENDWITNESS,
|
||||||
'p2shsegwit': types.SPENDP2SHWITNESS,
|
'p2shsegwit': proto.OutputScriptType.SPENDP2SHWITNESS,
|
||||||
}
|
}
|
||||||
script_type = typemap[script_type]
|
script_type = typemap[script_type]
|
||||||
return client.get_address(coin, address_n, show_display, script_type=script_type)
|
return client.get_address(coin, address_n, show_display, script_type=script_type)
|
||||||
|
@ -477,7 +474,7 @@ def sign_tx(connect, coin):
|
||||||
break
|
break
|
||||||
prev_in_hash, prev_in_vout = prev.split(':')
|
prev_in_hash, prev_in_vout = prev.split(':')
|
||||||
addrn = input("Node path to sign with (e.g.- %s/0'/0/0): " % coin).strip()
|
addrn = input("Node path to sign with (e.g.- %s/0'/0/0): " % coin).strip()
|
||||||
inputs.append(types.TxInputType(
|
inputs.append(proto.TxInputType(
|
||||||
prev_hash=binascii.unhexlify(prev_in_hash),
|
prev_hash=binascii.unhexlify(prev_in_hash),
|
||||||
prev_index=int(prev_in_vout, 10),
|
prev_index=int(prev_in_vout, 10),
|
||||||
address_n=client.expand_path(addrn)
|
address_n=client.expand_path(addrn)
|
||||||
|
@ -490,9 +487,9 @@ def sign_tx(connect, coin):
|
||||||
if out_addr == '':
|
if out_addr == '':
|
||||||
break
|
break
|
||||||
out_amount = input('Amount (in satoshis): ').strip()
|
out_amount = input('Amount (in satoshis): ').strip()
|
||||||
outputs.append(types.TxOutputType(
|
outputs.append(proto.TxOutputType(
|
||||||
amount=int(out_amount, 10),
|
amount=int(out_amount, 10),
|
||||||
script_type=types.PAYTOADDRESS,
|
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||||
address=out_addr
|
address=out_addr
|
||||||
))
|
))
|
||||||
|
|
||||||
|
@ -523,9 +520,9 @@ def sign_message(connect, coin, address, message, script_type):
|
||||||
client = connect()
|
client = connect()
|
||||||
address_n = client.expand_path(address)
|
address_n = client.expand_path(address)
|
||||||
typemap = {
|
typemap = {
|
||||||
'address': types.SPENDADDRESS,
|
'address': proto.InputScriptType.SPENDADDRESS,
|
||||||
'segwit': types.SPENDWITNESS,
|
'segwit': proto.InputScriptType.SPENDWITNESS,
|
||||||
'p2shsegwit': types.SPENDP2SHWITNESS,
|
'p2shsegwit': proto.InputScriptType.SPENDP2SHWITNESS,
|
||||||
}
|
}
|
||||||
script_type = typemap[script_type]
|
script_type = typemap[script_type]
|
||||||
res = client.sign_message(coin, address_n, message, script_type)
|
res = client.sign_message(coin, address_n, message, script_type)
|
||||||
|
@ -693,7 +690,7 @@ def ethereum_sign_tx(connect, host, chain_id, address, value, gas_limit, gas_pri
|
||||||
if ' ' in value:
|
if ' ' in value:
|
||||||
value, unit = value.split(' ', 1)
|
value, unit = value.split(' ', 1)
|
||||||
if unit.lower() not in ether_units:
|
if unit.lower() not in ether_units:
|
||||||
raise CallException(types.Failure_DataError, 'Unrecognized ether unit %r' % unit)
|
raise CallException(proto.Failure_DataError, 'Unrecognized ether unit %r' % unit)
|
||||||
value = int(value) * ether_units[unit.lower()]
|
value = int(value) * ether_units[unit.lower()]
|
||||||
else:
|
else:
|
||||||
value = int(value)
|
value = int(value)
|
||||||
|
@ -702,7 +699,7 @@ def ethereum_sign_tx(connect, host, chain_id, address, value, gas_limit, gas_pri
|
||||||
if ' ' in gas_price:
|
if ' ' in gas_price:
|
||||||
gas_price, unit = gas_price.split(' ', 1)
|
gas_price, unit = gas_price.split(' ', 1)
|
||||||
if unit.lower() not in ether_units:
|
if unit.lower() not in ether_units:
|
||||||
raise CallException(types.Failure_DataError, 'Unrecognized gas price unit %r' % unit)
|
raise CallException(proto.Failure_DataError, 'Unrecognized gas price unit %r' % unit)
|
||||||
gas_price = int(gas_price) * ether_units[unit.lower()]
|
gas_price = int(gas_price) * ether_units[unit.lower()]
|
||||||
else:
|
else:
|
||||||
gas_price = int(gas_price)
|
gas_price = int(gas_price)
|
||||||
|
|
|
@ -28,7 +28,7 @@ from ecdsa.curves import SECP256k1
|
||||||
from ecdsa.ellipticcurve import Point, INFINITY
|
from ecdsa.ellipticcurve import Point, INFINITY
|
||||||
|
|
||||||
from . import tools
|
from . import tools
|
||||||
from . import types_pb2 as proto_types
|
from . import messages as proto
|
||||||
|
|
||||||
PRIME_DERIVATION_FLAG = 0x80000000
|
PRIME_DERIVATION_FLAG = 0x80000000
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ def public_ckd(public_node, n):
|
||||||
if not isinstance(n, list):
|
if not isinstance(n, list):
|
||||||
raise ValueError('Parameter must be a list')
|
raise ValueError('Parameter must be a list')
|
||||||
|
|
||||||
node = proto_types.HDNodeType()
|
node = proto.HDNodeType()
|
||||||
node.CopyFrom(public_node)
|
node.CopyFrom(public_node)
|
||||||
|
|
||||||
for i in n:
|
for i in n:
|
||||||
|
@ -105,7 +105,7 @@ def get_subnode(node, i):
|
||||||
I64 = hmac.HMAC(key=node.chain_code, msg=data, digestmod=hashlib.sha512).digest()
|
I64 = hmac.HMAC(key=node.chain_code, msg=data, digestmod=hashlib.sha512).digest()
|
||||||
I_left_as_exponent = string_to_number(I64[:32])
|
I_left_as_exponent = string_to_number(I64[:32])
|
||||||
|
|
||||||
node_out = proto_types.HDNodeType()
|
node_out = proto.HDNodeType()
|
||||||
node_out.depth = node.depth + 1
|
node_out.depth = node.depth + 1
|
||||||
node_out.child_num = i
|
node_out.child_num = i
|
||||||
node_out.chain_code = I64[32:]
|
node_out.chain_code = I64[32:]
|
||||||
|
@ -145,7 +145,7 @@ def deserialize(xpub):
|
||||||
if tools.Hash(data[:-4])[:4] != data[-4:]:
|
if tools.Hash(data[:-4])[:4] != data[-4:]:
|
||||||
raise ValueError("Checksum failed")
|
raise ValueError("Checksum failed")
|
||||||
|
|
||||||
node = proto_types.HDNodeType()
|
node = proto.HDNodeType()
|
||||||
node.depth = struct.unpack('>B', data[4:5])[0]
|
node.depth = struct.unpack('>B', data[4:5])[0]
|
||||||
node.fingerprint = struct.unpack('>I', data[5:9])[0]
|
node.fingerprint = struct.unpack('>I', data[5:9])[0]
|
||||||
node.child_num = struct.unpack('>I', data[9:13])[0]
|
node.child_num = struct.unpack('>I', data[9:13])[0]
|
||||||
|
|
|
@ -30,10 +30,8 @@ import getpass
|
||||||
|
|
||||||
from mnemonic import Mnemonic
|
from mnemonic import Mnemonic
|
||||||
|
|
||||||
|
from . import messages as proto
|
||||||
from . import tools
|
from . import tools
|
||||||
# from . import mapping
|
|
||||||
from . import messages_pb2 as proto
|
|
||||||
from . import types_pb2 as types
|
|
||||||
from .coins import coins_slip44
|
from .coins import coins_slip44
|
||||||
from .debuglink import DebugLink
|
from .debuglink import DebugLink
|
||||||
|
|
||||||
|
@ -54,9 +52,6 @@ SCREENSHOT = False
|
||||||
|
|
||||||
DEFAULT_CURVE = 'secp256k1'
|
DEFAULT_CURVE = 'secp256k1'
|
||||||
|
|
||||||
# monkeypatching: text formatting of protobuf messages
|
|
||||||
tools.monkeypatch_google_protobuf_text_format()
|
|
||||||
|
|
||||||
|
|
||||||
def getch():
|
def getch():
|
||||||
try:
|
try:
|
||||||
|
@ -85,17 +80,12 @@ def getch():
|
||||||
|
|
||||||
def get_buttonrequest_value(code):
|
def get_buttonrequest_value(code):
|
||||||
# Converts integer code to its string representation of ButtonRequestType
|
# Converts integer code to its string representation of ButtonRequestType
|
||||||
return [k for k, v in types.ButtonRequestType.items() if v == code][0]
|
return [k for k in dir(proto.ButtonRequestType) if getattr(proto.ButtonRequestType, k) == code][0]
|
||||||
|
|
||||||
|
|
||||||
def pprint(msg):
|
def pprint(msg):
|
||||||
msg_class = msg.__class__.__name__
|
msg_class = msg.__class__.__name__
|
||||||
msg_size = msg.ByteSize()
|
msg_size = msg.ByteSize()
|
||||||
"""
|
|
||||||
msg_ser = msg.SerializeToString()
|
|
||||||
msg_id = mapping.get_type(msg)
|
|
||||||
msg_json = json_format.MessageToDict(msg, preserving_proto_field_name=True)
|
|
||||||
"""
|
|
||||||
if isinstance(msg, proto.FirmwareUpload) or isinstance(msg, proto.SelfTest):
|
if isinstance(msg, proto.FirmwareUpload) or isinstance(msg, proto.SelfTest):
|
||||||
return "<%s> (%d bytes):\n" % (msg_class, msg_size)
|
return "<%s> (%d bytes):\n" % (msg_class, msg_size)
|
||||||
else:
|
else:
|
||||||
|
@ -128,7 +118,6 @@ class field(object):
|
||||||
def __call__(self, f):
|
def __call__(self, f):
|
||||||
def wrapped_f(*args, **kwargs):
|
def wrapped_f(*args, **kwargs):
|
||||||
ret = f(*args, **kwargs)
|
ret = f(*args, **kwargs)
|
||||||
ret.HasField(self.field)
|
|
||||||
return getattr(ret, self.field)
|
return getattr(ret, self.field)
|
||||||
return wrapped_f
|
return wrapped_f
|
||||||
|
|
||||||
|
@ -209,8 +198,8 @@ class BaseClient(object):
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
def callback_Failure(self, msg):
|
def callback_Failure(self, msg):
|
||||||
if msg.code in (types.Failure_PinInvalid,
|
if msg.code in (proto.FailureType.PinInvalid,
|
||||||
types.Failure_PinCancelled, types.Failure_PinExpected):
|
proto.FailureType.PinCancelled, proto.FailureType.PinExpected):
|
||||||
raise PinException(msg.code, msg.message)
|
raise PinException(msg.code, msg.message)
|
||||||
|
|
||||||
raise CallException(msg.code, msg.message)
|
raise CallException(msg.code, msg.message)
|
||||||
|
@ -255,18 +244,18 @@ class TextUIMixin(object):
|
||||||
return proto.WordAck(word='\x08')
|
return proto.WordAck(word='\x08')
|
||||||
|
|
||||||
# ignore middle column if only 6 keys requested.
|
# ignore middle column if only 6 keys requested.
|
||||||
if msg.type == types.WordRequestType_Matrix6 and character in ('2', '5', '8'):
|
if msg.type == proto.WordRequestType_Matrix6 and character in ('2', '5', '8'):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if character.isdigit():
|
if character.isdigit():
|
||||||
return proto.WordAck(word=character)
|
return proto.WordAck(word=character)
|
||||||
|
|
||||||
def callback_PinMatrixRequest(self, msg):
|
def callback_PinMatrixRequest(self, msg):
|
||||||
if msg.type == types.PinMatrixRequestType_Current:
|
if msg.type == proto.PinMatrixRequestType_Current:
|
||||||
desc = 'current PIN'
|
desc = 'current PIN'
|
||||||
elif msg.type == types.PinMatrixRequestType_NewFirst:
|
elif msg.type == proto.PinMatrixRequestType_NewFirst:
|
||||||
desc = 'new PIN'
|
desc = 'new PIN'
|
||||||
elif msg.type == types.PinMatrixRequestType_NewSecond:
|
elif msg.type == proto.PinMatrixRequestType_NewSecond:
|
||||||
desc = 'new PIN again'
|
desc = 'new PIN again'
|
||||||
else:
|
else:
|
||||||
desc = 'PIN'
|
desc = 'PIN'
|
||||||
|
@ -293,8 +282,8 @@ class TextUIMixin(object):
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
def callback_WordRequest(self, msg):
|
def callback_WordRequest(self, msg):
|
||||||
if msg.type in (types.WordRequestType_Matrix9,
|
if msg.type in (proto.WordRequestType_Matrix9,
|
||||||
types.WordRequestType_Matrix6):
|
proto.WordRequestType_Matrix6):
|
||||||
return self.callback_RecoveryMatrix(msg)
|
return self.callback_RecoveryMatrix(msg)
|
||||||
log("Enter one word of mnemonic: ")
|
log("Enter one word of mnemonic: ")
|
||||||
word = input()
|
word = input()
|
||||||
|
@ -401,17 +390,17 @@ class DebugLinkMixin(object):
|
||||||
try:
|
try:
|
||||||
expected = self.expected_responses.pop(0)
|
expected = self.expected_responses.pop(0)
|
||||||
except IndexError:
|
except IndexError:
|
||||||
raise CallException(types.Failure_UnexpectedMessage,
|
raise CallException(proto.FailureType.UnexpectedMessage,
|
||||||
"Got %s, but no message has been expected" % pprint(msg))
|
"Got %s, but no message has been expected" % pprint(msg))
|
||||||
|
|
||||||
if msg.__class__ != expected.__class__:
|
if msg.__class__ != expected.__class__:
|
||||||
raise CallException(types.Failure_UnexpectedMessage,
|
raise CallException(proto.FailureType.UnexpectedMessage,
|
||||||
"Expected %s, got %s" % (pprint(expected), pprint(msg)))
|
"Expected %s, got %s" % (pprint(expected), pprint(msg)))
|
||||||
|
|
||||||
fields = expected.ListFields() # only filled (including extensions)
|
for field, value in expected.__dict__.items():
|
||||||
for field, value in fields:
|
print("EXPECTED", getattr(expected, field), getattr(msg, field), field, value)
|
||||||
if not msg.HasField(field.name) or getattr(msg, field.name) != value:
|
if getattr(expected, field) != value:
|
||||||
raise CallException(types.Failure_UnexpectedMessage,
|
raise CallException(proto.FailureType.UnexpectedMessage,
|
||||||
"Expected %s, got %s" % (pprint(expected), pprint(msg)))
|
"Expected %s, got %s" % (pprint(expected), pprint(msg)))
|
||||||
|
|
||||||
def callback_ButtonRequest(self, msg):
|
def callback_ButtonRequest(self, msg):
|
||||||
|
@ -513,7 +502,7 @@ class ProtocolMixin(object):
|
||||||
|
|
||||||
@field('address')
|
@field('address')
|
||||||
@expect(proto.Address)
|
@expect(proto.Address)
|
||||||
def get_address(self, coin_name, n, show_display=False, multisig=None, script_type=types.SPENDADDRESS):
|
def get_address(self, coin_name, n, show_display=False, multisig=None, script_type=proto.InputScriptType.SPENDADDRESS):
|
||||||
n = self._convert_prime(n)
|
n = self._convert_prime(n)
|
||||||
if multisig:
|
if multisig:
|
||||||
return self.call(proto.GetAddress(address_n=n, coin_name=coin_name, show_display=show_display, multisig=multisig, script_type=script_type))
|
return self.call(proto.GetAddress(address_n=n, coin_name=coin_name, show_display=show_display, multisig=multisig, script_type=script_type))
|
||||||
|
@ -556,7 +545,7 @@ class ProtocolMixin(object):
|
||||||
|
|
||||||
response = self.call(msg)
|
response = self.call(msg)
|
||||||
|
|
||||||
while response.HasField('data_length'):
|
while response.data_length is not None:
|
||||||
data_length = response.data_length
|
data_length = response.data_length
|
||||||
data, chunk = data[data_length:], data[:data_length]
|
data, chunk = data[data_length:], data[:data_length]
|
||||||
response = self.call(proto.EthereumTxAck(data_chunk=chunk))
|
response = self.call(proto.EthereumTxAck(data_chunk=chunk))
|
||||||
|
@ -635,7 +624,7 @@ class ProtocolMixin(object):
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
@expect(proto.MessageSignature)
|
@expect(proto.MessageSignature)
|
||||||
def sign_message(self, coin_name, n, message, script_type=types.SPENDADDRESS):
|
def sign_message(self, coin_name, n, message, script_type=proto.InputScriptType.SPENDADDRESS):
|
||||||
n = self._convert_prime(n)
|
n = self._convert_prime(n)
|
||||||
# Convert message to UTF8 NFC (seems to be a bitcoin-qt standard)
|
# Convert message to UTF8 NFC (seems to be a bitcoin-qt standard)
|
||||||
message = normalize_nfc(message).encode("utf-8")
|
message = normalize_nfc(message).encode("utf-8")
|
||||||
|
@ -675,16 +664,20 @@ class ProtocolMixin(object):
|
||||||
def nem_sign_tx(self, n, transaction):
|
def nem_sign_tx(self, n, transaction):
|
||||||
n = self._convert_prime(n)
|
n = self._convert_prime(n)
|
||||||
|
|
||||||
def common_to_proto(common, msg):
|
def common_to_proto(common):
|
||||||
|
msg = proto.NEMTransactionCommon()
|
||||||
msg.network = (common["version"] >> 24) & 0xFF
|
msg.network = (common["version"] >> 24) & 0xFF
|
||||||
msg.timestamp = common["timeStamp"]
|
msg.timestamp = common["timeStamp"]
|
||||||
msg.fee = common["fee"]
|
msg.fee = common["fee"]
|
||||||
msg.deadline = common["deadline"]
|
msg.deadline = common["deadline"]
|
||||||
|
|
||||||
if "signer" in common:
|
if "signed" in common:
|
||||||
msg.signer = binascii.unhexlify(common["signer"])
|
msg.signer = binascii.unhexlify(common["signer"])
|
||||||
|
|
||||||
def transfer_to_proto(transfer, msg):
|
return msg
|
||||||
|
|
||||||
|
def transfer_to_proto(transfer):
|
||||||
|
msg = proto.NEMTransfer()
|
||||||
msg.recipient = transfer["recipient"]
|
msg.recipient = transfer["recipient"]
|
||||||
msg.amount = transfer["amount"]
|
msg.amount = transfer["amount"]
|
||||||
|
|
||||||
|
@ -695,14 +688,15 @@ class ProtocolMixin(object):
|
||||||
msg.public_key = binascii.unhexlify(transfer["message"]["publicKey"])
|
msg.public_key = binascii.unhexlify(transfer["message"]["publicKey"])
|
||||||
|
|
||||||
if "mosaics" in transfer:
|
if "mosaics" in transfer:
|
||||||
msg.mosaics.extend(types.NEMMosaic(
|
msg._extend_mosaics(proto.NEMMosaic(
|
||||||
namespace=mosaic["mosaicId"]["namespaceId"],
|
namespace=mosaic["mosaicId"]["namespaceId"],
|
||||||
mosaic=mosaic["mosaicId"]["name"],
|
mosaic=mosaic["mosaicId"]["name"],
|
||||||
quantity=mosaic["quantity"],
|
quantity=mosaic["quantity"],
|
||||||
) for mosaic in transfer["mosaics"])
|
) for mosaic in transfer["mosaics"])
|
||||||
|
return msg
|
||||||
|
|
||||||
def aggregate_modification_to_proto(aggregate_modification, msg):
|
def aggregate_modification_to_proto(aggregate_modification, msg):
|
||||||
msg.modifications.extend(types.NEMCosignatoryModification(
|
msg._extend_modifications(proto.NEMCosignatoryModification(
|
||||||
type=modification["modificationType"],
|
type=modification["modificationType"],
|
||||||
public_key=binascii.unhexlify(modification["cosignatoryAccount"]),
|
public_key=binascii.unhexlify(modification["cosignatoryAccount"]),
|
||||||
) for modification in aggregate_modification["modifications"])
|
) for modification in aggregate_modification["modifications"])
|
||||||
|
@ -719,7 +713,8 @@ class ProtocolMixin(object):
|
||||||
msg.sink = provision_namespace["rentalFeeSink"]
|
msg.sink = provision_namespace["rentalFeeSink"]
|
||||||
msg.fee = provision_namespace["rentalFee"]
|
msg.fee = provision_namespace["rentalFee"]
|
||||||
|
|
||||||
def mosaic_creation_to_proto(mosaic_creation, msg):
|
def mosaic_creation_to_proto(mosaic_creation):
|
||||||
|
msg = proto.NEMMosaicCreation()
|
||||||
msg.definition.namespace = mosaic_creation["mosaicDefinition"]["id"]["namespaceId"]
|
msg.definition.namespace = mosaic_creation["mosaicDefinition"]["id"]["namespaceId"]
|
||||||
msg.definition.mosaic = mosaic_creation["mosaicDefinition"]["id"]["name"]
|
msg.definition.mosaic = mosaic_creation["mosaicDefinition"]["id"]["name"]
|
||||||
|
|
||||||
|
@ -747,36 +742,38 @@ class ProtocolMixin(object):
|
||||||
|
|
||||||
msg.sink = mosaic_creation["creationFeeSink"]
|
msg.sink = mosaic_creation["creationFeeSink"]
|
||||||
msg.fee = mosaic_creation["creationFee"]
|
msg.fee = mosaic_creation["creationFee"]
|
||||||
|
return msg
|
||||||
|
|
||||||
def mosaic_supply_change_to_proto(mosaic_supply_change, msg):
|
def mosaic_supply_change_to_proto(mosaic_supply_change):
|
||||||
|
msg = proto.NEMMosaicSupplyChange()
|
||||||
msg.namespace = mosaic_supply_change["mosaicId"]["namespaceId"]
|
msg.namespace = mosaic_supply_change["mosaicId"]["namespaceId"]
|
||||||
msg.mosaic = mosaic_supply_change["mosaicId"]["name"]
|
msg.mosaic = mosaic_supply_change["mosaicId"]["name"]
|
||||||
msg.type = mosaic_supply_change["supplyType"]
|
msg.type = mosaic_supply_change["supplyType"]
|
||||||
msg.delta = mosaic_supply_change["delta"]
|
msg.delta = mosaic_supply_change["delta"]
|
||||||
|
return msg
|
||||||
|
|
||||||
msg = proto.NEMSignTx()
|
msg = proto.NEMSignTx()
|
||||||
|
|
||||||
common_to_proto(transaction, msg.transaction)
|
msg.transaction = common_to_proto(transaction)
|
||||||
msg.transaction.address_n.extend(n)
|
msg.transaction._extend_address_n(n)
|
||||||
|
|
||||||
msg.cosigning = (transaction["type"] == 0x1002)
|
msg.cosigning = (transaction["type"] == 0x1002)
|
||||||
|
|
||||||
if msg.cosigning or transaction["type"] == 0x1004:
|
if msg.cosigning or transaction["type"] == 0x1004:
|
||||||
transaction = transaction["otherTrans"]
|
transaction = transaction["otherTrans"]
|
||||||
common_to_proto(transaction, msg.multisig)
|
msg.multisig = common_to_proto(transaction)
|
||||||
elif "otherTrans" in transaction:
|
elif "otherTrans" in transaction:
|
||||||
raise CallException("Transaction does not support inner transaction")
|
raise CallException("Transaction does not support inner transaction")
|
||||||
|
|
||||||
if transaction["type"] == 0x0101:
|
if transaction["type"] == 0x0101:
|
||||||
transfer_to_proto(transaction, msg.transfer)
|
msg.transfer = transfer_to_proto(transaction)
|
||||||
elif transaction["type"] == 0x1001:
|
elif transaction["type"] == 0x1001:
|
||||||
aggregate_modification_to_proto(transaction, msg.aggregate_modification)
|
aggregate_modification_to_proto(transaction, msg.aggregate_modification)
|
||||||
elif transaction["type"] == 0x2001:
|
elif transaction["type"] == 0x2001:
|
||||||
provision_namespace_to_proto(transaction, msg.provision_namespace)
|
provision_namespace_to_proto(transaction, msg.provision_namespace)
|
||||||
elif transaction["type"] == 0x4001:
|
elif transaction["type"] == 0x4001:
|
||||||
mosaic_creation_to_proto(transaction, msg.mosaic_creation)
|
msg = mosaic_creation_to_proto(transaction)
|
||||||
elif transaction["type"] == 0x4002:
|
elif transaction["type"] == 0x4002:
|
||||||
mosaic_supply_change_to_proto(transaction, msg.mosaic_supply_change)
|
msg.mosaic_supply_change = mosaic_supply_change_to_proto(transaction)
|
||||||
else:
|
else:
|
||||||
raise CallException("Unknown transaction type")
|
raise CallException("Unknown transaction type")
|
||||||
|
|
||||||
|
@ -830,37 +827,14 @@ class ProtocolMixin(object):
|
||||||
ask_on_decrypt=ask_on_decrypt,
|
ask_on_decrypt=ask_on_decrypt,
|
||||||
iv=iv))
|
iv=iv))
|
||||||
|
|
||||||
def _prepare_simple_sign_tx(self, coin_name, inputs, outputs):
|
|
||||||
msg = proto.SimpleSignTx()
|
|
||||||
msg.coin_name = coin_name
|
|
||||||
msg.inputs.extend(inputs)
|
|
||||||
msg.outputs.extend(outputs)
|
|
||||||
|
|
||||||
known_hashes = []
|
|
||||||
for inp in inputs:
|
|
||||||
if inp.prev_hash in known_hashes:
|
|
||||||
continue
|
|
||||||
|
|
||||||
tx = msg.transactions.add()
|
|
||||||
if self.tx_api:
|
|
||||||
tx.CopyFrom(self.tx_api.get_tx(binascii.hexlify(inp.prev_hash).decode('utf-8')))
|
|
||||||
else:
|
|
||||||
raise RuntimeError('TX_API not defined')
|
|
||||||
known_hashes.append(inp.prev_hash)
|
|
||||||
|
|
||||||
return msg
|
|
||||||
|
|
||||||
def simple_sign_tx(self, coin_name, inputs, outputs):
|
|
||||||
msg = self._prepare_simple_sign_tx(coin_name, inputs, outputs)
|
|
||||||
return self.call(msg).serialized.serialized_tx
|
|
||||||
|
|
||||||
def _prepare_sign_tx(self, coin_name, inputs, outputs):
|
def _prepare_sign_tx(self, coin_name, inputs, outputs):
|
||||||
tx = types.TransactionType()
|
tx = proto.TransactionType()
|
||||||
tx.inputs.extend(inputs)
|
tx._extend_inputs(inputs)
|
||||||
tx.outputs.extend(outputs)
|
tx._extend_outputs(outputs)
|
||||||
|
tx._fill_missing()
|
||||||
|
|
||||||
txes = {}
|
txes = {}
|
||||||
txes[b''] = tx
|
txes[None] = tx
|
||||||
|
|
||||||
known_hashes = []
|
known_hashes = []
|
||||||
for inp in inputs:
|
for inp in inputs:
|
||||||
|
@ -869,6 +843,7 @@ class ProtocolMixin(object):
|
||||||
|
|
||||||
if self.tx_api:
|
if self.tx_api:
|
||||||
txes[inp.prev_hash] = self.tx_api.get_tx(binascii.hexlify(inp.prev_hash).decode('utf-8'))
|
txes[inp.prev_hash] = self.tx_api.get_tx(binascii.hexlify(inp.prev_hash).decode('utf-8'))
|
||||||
|
txes[inp.prev_hash]._fill_missing()
|
||||||
else:
|
else:
|
||||||
raise RuntimeError('TX_API not defined')
|
raise RuntimeError('TX_API not defined')
|
||||||
known_hashes.append(inp.prev_hash)
|
known_hashes.append(inp.prev_hash)
|
||||||
|
@ -907,24 +882,27 @@ class ProtocolMixin(object):
|
||||||
raise CallException("Unexpected message")
|
raise CallException("Unexpected message")
|
||||||
|
|
||||||
# If there's some part of signed transaction, let's add it
|
# If there's some part of signed transaction, let's add it
|
||||||
if res.HasField('serialized') and res.serialized.HasField('serialized_tx'):
|
if res.serialized and res.serialized.serialized_tx:
|
||||||
log("RECEIVED PART OF SERIALIZED TX (%d BYTES)" % len(res.serialized.serialized_tx))
|
log("RECEIVED PART OF SERIALIZED TX (%d BYTES)" % len(res.serialized.serialized_tx))
|
||||||
serialized_tx += res.serialized.serialized_tx
|
serialized_tx += res.serialized.serialized_tx
|
||||||
|
|
||||||
if res.HasField('serialized') and res.serialized.HasField('signature_index'):
|
if res.serialized and res.serialized.signature_index is not None:
|
||||||
if signatures[res.serialized.signature_index] is not None:
|
if signatures[res.serialized.signature_index] is not None:
|
||||||
raise ValueError("Signature for index %d already filled" % res.serialized.signature_index)
|
raise ValueError("Signature for index %d already filled" % res.serialized.signature_index)
|
||||||
signatures[res.serialized.signature_index] = res.serialized.signature
|
signatures[res.serialized.signature_index] = res.serialized.signature
|
||||||
|
|
||||||
if res.request_type == types.TXFINISHED:
|
if res.request_type == proto.RequestType.TXFINISHED:
|
||||||
# Device didn't ask for more information, finish workflow
|
# Device didn't ask for more information, finish workflow
|
||||||
break
|
break
|
||||||
|
|
||||||
# Device asked for one more information, let's process it.
|
# Device asked for one more information, let's process it.
|
||||||
current_tx = txes[res.details.tx_hash]
|
if not res.details.tx_hash:
|
||||||
|
current_tx = txes[None]
|
||||||
|
else:
|
||||||
|
current_tx = txes[bytes(res.details.tx_hash)]
|
||||||
|
|
||||||
if res.request_type == types.TXMETA:
|
if res.request_type == proto.RequestType.TXMETA:
|
||||||
msg = types.TransactionType()
|
msg = proto.TransactionType()
|
||||||
msg.version = current_tx.version
|
msg.version = current_tx.version
|
||||||
msg.lock_time = current_tx.lock_time
|
msg.lock_time = current_tx.lock_time
|
||||||
msg.inputs_cnt = len(current_tx.inputs)
|
msg.inputs_cnt = len(current_tx.inputs)
|
||||||
|
@ -932,13 +910,13 @@ class ProtocolMixin(object):
|
||||||
msg.outputs_cnt = len(current_tx.bin_outputs)
|
msg.outputs_cnt = len(current_tx.bin_outputs)
|
||||||
else:
|
else:
|
||||||
msg.outputs_cnt = len(current_tx.outputs)
|
msg.outputs_cnt = len(current_tx.outputs)
|
||||||
msg.extra_data_len = len(current_tx.extra_data)
|
msg.extra_data_len = len(current_tx.extra_data) if current_tx.extra_data else 0
|
||||||
res = self.call(proto.TxAck(tx=msg))
|
res = self.call(proto.TxAck(tx=msg))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
elif res.request_type == types.TXINPUT:
|
elif res.request_type == proto.RequestType.TXINPUT:
|
||||||
msg = types.TransactionType()
|
msg = proto.TransactionType()
|
||||||
msg.inputs.extend([current_tx.inputs[res.details.request_index], ])
|
msg._extend_inputs([current_tx.inputs[res.details.request_index], ])
|
||||||
if debug_processor is not None:
|
if debug_processor is not None:
|
||||||
# If debug_processor function is provided,
|
# If debug_processor function is provided,
|
||||||
# pass thru it the request and prepared response.
|
# pass thru it the request and prepared response.
|
||||||
|
@ -948,12 +926,12 @@ class ProtocolMixin(object):
|
||||||
res = self.call(proto.TxAck(tx=msg))
|
res = self.call(proto.TxAck(tx=msg))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
elif res.request_type == types.TXOUTPUT:
|
elif res.request_type == proto.RequestType.TXOUTPUT:
|
||||||
msg = types.TransactionType()
|
msg = proto.TransactionType()
|
||||||
if res.details.tx_hash:
|
if res.details.tx_hash:
|
||||||
msg.bin_outputs.extend([current_tx.bin_outputs[res.details.request_index], ])
|
msg._extend_bin_outputs([current_tx.bin_outputs[res.details.request_index], ])
|
||||||
else:
|
else:
|
||||||
msg.outputs.extend([current_tx.outputs[res.details.request_index], ])
|
msg._extend_outputs([current_tx.outputs[res.details.request_index], ])
|
||||||
|
|
||||||
if debug_processor is not None:
|
if debug_processor is not None:
|
||||||
# If debug_processor function is provided,
|
# If debug_processor function is provided,
|
||||||
|
@ -964,9 +942,9 @@ class ProtocolMixin(object):
|
||||||
res = self.call(proto.TxAck(tx=msg))
|
res = self.call(proto.TxAck(tx=msg))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
elif res.request_type == types.TXEXTRADATA:
|
elif res.request_type == proto.RequestType.TXEXTRADATA:
|
||||||
o, l = res.details.extra_data_offset, res.details.extra_data_len
|
o, l = res.details.extra_data_offset, res.details.extra_data_len
|
||||||
msg = types.TransactionType()
|
msg = proto.TransactionType()
|
||||||
msg.extra_data = current_tx.extra_data[o:o + l]
|
msg.extra_data = current_tx.extra_data[o:o + l]
|
||||||
res = self.call(proto.TxAck(tx=msg))
|
res = self.call(proto.TxAck(tx=msg))
|
||||||
continue
|
continue
|
||||||
|
@ -988,7 +966,7 @@ class ProtocolMixin(object):
|
||||||
|
|
||||||
@field('message')
|
@field('message')
|
||||||
@expect(proto.Success)
|
@expect(proto.Success)
|
||||||
def recovery_device(self, word_count, passphrase_protection, pin_protection, label, language, type=types.RecoveryDeviceType_ScrambledWords, expand=False, dry_run=False):
|
def recovery_device(self, word_count, passphrase_protection, pin_protection, label, language, type=proto.RecoveryDeviceType.ScrambledWords, expand=False, dry_run=False):
|
||||||
if self.features.initialized and not dry_run:
|
if self.features.initialized and not dry_run:
|
||||||
raise RuntimeError("Device is initialized already. Call wipe_device() and try again.")
|
raise RuntimeError("Device is initialized already. Call wipe_device() and try again.")
|
||||||
|
|
||||||
|
@ -1088,7 +1066,7 @@ class ProtocolMixin(object):
|
||||||
if len(xprv) < 100 and len(xprv) > 112:
|
if len(xprv) < 100 and len(xprv) > 112:
|
||||||
raise ValueError("Invalid length of xprv")
|
raise ValueError("Invalid length of xprv")
|
||||||
|
|
||||||
node = types.HDNodeType()
|
node = proto.HDNodeType()
|
||||||
data = binascii.hexlify(tools.b58decode(xprv, None))
|
data = binascii.hexlify(tools.b58decode(xprv, None))
|
||||||
|
|
||||||
if data[90:92] != b'00':
|
if data[90:92] != b'00':
|
||||||
|
@ -1128,7 +1106,7 @@ class ProtocolMixin(object):
|
||||||
data = fp.read()
|
data = fp.read()
|
||||||
|
|
||||||
resp = self.call(proto.FirmwareErase(length=len(data)))
|
resp = self.call(proto.FirmwareErase(length=len(data)))
|
||||||
if isinstance(resp, proto.Failure) and resp.code == types.Failure_FirmwareError:
|
if isinstance(resp, proto.Failure) and resp.code == proto.FailureType.FirmwareError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# TREZORv1 method
|
# TREZORv1 method
|
||||||
|
@ -1138,7 +1116,7 @@ class ProtocolMixin(object):
|
||||||
resp = self.call(proto.FirmwareUpload(payload=data))
|
resp = self.call(proto.FirmwareUpload(payload=data))
|
||||||
if isinstance(resp, proto.Success):
|
if isinstance(resp, proto.Success):
|
||||||
return True
|
return True
|
||||||
elif isinstance(resp, proto.Failure) and resp.code == types.Failure_FirmwareError:
|
elif isinstance(resp, proto.Failure) and resp.code == proto.FailureType.FirmwareError:
|
||||||
return False
|
return False
|
||||||
raise RuntimeError("Unexpected result %s" % resp)
|
raise RuntimeError("Unexpected result %s" % resp)
|
||||||
|
|
||||||
|
@ -1153,7 +1131,7 @@ class ProtocolMixin(object):
|
||||||
continue
|
continue
|
||||||
elif isinstance(resp, proto.Success):
|
elif isinstance(resp, proto.Success):
|
||||||
return True
|
return True
|
||||||
elif isinstance(resp, proto.Failure) and resp.code == types.Failure_FirmwareError:
|
elif isinstance(resp, proto.Failure) and resp.code == proto.FailureType.FirmwareError:
|
||||||
return False
|
return False
|
||||||
raise RuntimeError("Unexpected result %s" % resp)
|
raise RuntimeError("Unexpected result %s" % resp)
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
from . import messages_pb2 as proto
|
from . import messages as proto
|
||||||
|
|
||||||
|
|
||||||
def pin_info(pin):
|
def pin_info(pin):
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#
|
#
|
||||||
# Copyright (C) 2012-2016 Marek Palatinus <slush@satoshilabs.com>
|
# Copyright (C) 2012-2016 Marek Palatinus <slush@satoshilabs.com>
|
||||||
# Copyright (C) 2012-2016 Pavol Rusnak <stick@satoshilabs.com>
|
# Copyright (C) 2012-2016 Pavol Rusnak <stick@satoshilabs.com>
|
||||||
|
# Copyright (C) 2016 Jochen Hoenicke <hoenicke@gmail.com>
|
||||||
#
|
#
|
||||||
# This library is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
@ -16,19 +17,28 @@
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from . import messages_pb2 as proto
|
from . import messages
|
||||||
|
from . import protobuf
|
||||||
|
|
||||||
map_type_to_class = {}
|
map_type_to_class = {}
|
||||||
map_class_to_type = {}
|
map_class_to_type = {}
|
||||||
|
|
||||||
|
|
||||||
def build_map():
|
def build_map():
|
||||||
for msg_type, i in proto.MessageType.items():
|
for msg_name in dir(messages.MessageType):
|
||||||
msg_name = msg_type.replace('MessageType_', '')
|
if msg_name.startswith('__'):
|
||||||
msg_class = getattr(proto, msg_name)
|
continue
|
||||||
|
|
||||||
map_type_to_class[i] = msg_class
|
try:
|
||||||
map_class_to_type[msg_class] = i
|
msg_class = getattr(messages, msg_name)
|
||||||
|
except AttributeError:
|
||||||
|
raise
|
||||||
|
raise ValueError("Implementation of protobuf message '%s' is missing" % msg_name)
|
||||||
|
|
||||||
|
wire_type = getattr(messages.MessageType, msg_name)
|
||||||
|
|
||||||
|
map_type_to_class[wire_type] = msg_class
|
||||||
|
map_class_to_type[msg_class] = wire_type
|
||||||
|
|
||||||
|
|
||||||
def get_type(msg):
|
def get_type(msg):
|
||||||
|
@ -39,17 +49,4 @@ def get_class(t):
|
||||||
return map_type_to_class[t]
|
return map_type_to_class[t]
|
||||||
|
|
||||||
|
|
||||||
def check_missing():
|
|
||||||
from google.protobuf import reflection
|
|
||||||
|
|
||||||
types = [getattr(proto, item) for item in dir(proto)
|
|
||||||
if issubclass(getattr(proto, item).__class__, reflection.GeneratedProtocolMessageType)]
|
|
||||||
|
|
||||||
missing = list(set(types) - set(map_type_to_class.values()))
|
|
||||||
|
|
||||||
if len(missing):
|
|
||||||
raise ValueError("Following protobuf messages are not defined in mapping: %s" % missing)
|
|
||||||
|
|
||||||
|
|
||||||
build_map()
|
build_map()
|
||||||
check_missing()
|
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class Address(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('address', p.UnicodeType, 0), # required
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 30
|
|
@ -0,0 +1,10 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class ApplyFlags(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('flags', p.UVarintType, 0),
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 28
|
|
@ -0,0 +1,13 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class ApplySettings(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('language', p.UnicodeType, 0),
|
||||||
|
2: ('label', p.UnicodeType, 0),
|
||||||
|
3: ('use_passphrase', p.BoolType, 0),
|
||||||
|
4: ('homescreen', p.BytesType, 0),
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 25
|
|
@ -0,0 +1,7 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class BackupDevice(p.MessageType):
|
||||||
|
MESSAGE_WIRE_TYPE = 34
|
|
@ -0,0 +1,7 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class ButtonAck(p.MessageType):
|
||||||
|
MESSAGE_WIRE_TYPE = 27
|
|
@ -0,0 +1,11 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class ButtonRequest(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('code', p.UVarintType, 0),
|
||||||
|
2: ('data', p.UnicodeType, 0),
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 26
|
|
@ -0,0 +1,12 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
Other = 1
|
||||||
|
FeeOverThreshold = 2
|
||||||
|
ConfirmOutput = 3
|
||||||
|
ResetDevice = 4
|
||||||
|
ConfirmWord = 5
|
||||||
|
WipeDevice = 6
|
||||||
|
ProtectCall = 7
|
||||||
|
SignTx = 8
|
||||||
|
FirmwareCheck = 9
|
||||||
|
Address = 10
|
||||||
|
PublicKey = 11
|
|
@ -0,0 +1,7 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class Cancel(p.MessageType):
|
||||||
|
MESSAGE_WIRE_TYPE = 20
|
|
@ -0,0 +1,10 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class ChangePin(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('remove', p.BoolType, 0),
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 4
|
|
@ -0,0 +1,16 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class CipherKeyValue(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('address_n', p.UVarintType, p.FLAG_REPEATED),
|
||||||
|
2: ('key', p.UnicodeType, 0),
|
||||||
|
3: ('value', p.BytesType, 0),
|
||||||
|
4: ('encrypt', p.BoolType, 0),
|
||||||
|
5: ('ask_on_encrypt', p.BoolType, 0),
|
||||||
|
6: ('ask_on_decrypt', p.BoolType, 0),
|
||||||
|
7: ('iv', p.BytesType, 0),
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 23
|
|
@ -0,0 +1,10 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class CipheredKeyValue(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('value', p.BytesType, 0),
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 48
|
|
@ -0,0 +1,7 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class ClearSession(p.MessageType):
|
||||||
|
MESSAGE_WIRE_TYPE = 24
|
|
@ -0,0 +1,19 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class CoinType(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('coin_name', p.UnicodeType, 0),
|
||||||
|
2: ('coin_shortcut', p.UnicodeType, 0),
|
||||||
|
3: ('address_type', p.UVarintType, 0), # default=0
|
||||||
|
4: ('maxfee_kb', p.UVarintType, 0),
|
||||||
|
5: ('address_type_p2sh', p.UVarintType, 0), # default=5
|
||||||
|
8: ('signed_message_header', p.UnicodeType, 0),
|
||||||
|
9: ('xpub_magic', p.UVarintType, 0), # default=76067358
|
||||||
|
10: ('xprv_magic', p.UVarintType, 0), # default=76066276
|
||||||
|
11: ('segwit', p.BoolType, 0),
|
||||||
|
12: ('forkid', p.UVarintType, 0),
|
||||||
|
13: ('force_bip143', p.BoolType, 0),
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class CosiCommit(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('address_n', p.UVarintType, p.FLAG_REPEATED),
|
||||||
|
2: ('data', p.BytesType, 0),
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 71
|
|
@ -0,0 +1,11 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class CosiCommitment(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('commitment', p.BytesType, 0),
|
||||||
|
2: ('pubkey', p.BytesType, 0),
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 72
|
|
@ -0,0 +1,13 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class CosiSign(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('address_n', p.UVarintType, p.FLAG_REPEATED),
|
||||||
|
2: ('data', p.BytesType, 0),
|
||||||
|
3: ('global_commitment', p.BytesType, 0),
|
||||||
|
4: ('global_pubkey', p.BytesType, 0),
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 73
|
|
@ -0,0 +1,10 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class CosiSignature(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('signature', p.BytesType, 0),
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 74
|
|
@ -0,0 +1,10 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class DebugLinkDecision(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('yes_no', p.BoolType, 0), # required
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 100
|
|
@ -0,0 +1,10 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class DebugLinkFlashErase(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('sector', p.UVarintType, 0),
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 113
|
|
@ -0,0 +1,7 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class DebugLinkGetState(p.MessageType):
|
||||||
|
MESSAGE_WIRE_TYPE = 101
|
|
@ -0,0 +1,12 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class DebugLinkLog(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('level', p.UVarintType, 0),
|
||||||
|
2: ('bucket', p.UnicodeType, 0),
|
||||||
|
3: ('text', p.UnicodeType, 0),
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 104
|
|
@ -0,0 +1,10 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class DebugLinkMemory(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('memory', p.BytesType, 0),
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 111
|
|
@ -0,0 +1,11 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class DebugLinkMemoryRead(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('address', p.UVarintType, 0),
|
||||||
|
2: ('length', p.UVarintType, 0),
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 110
|
|
@ -0,0 +1,12 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class DebugLinkMemoryWrite(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('address', p.UVarintType, 0),
|
||||||
|
2: ('memory', p.BytesType, 0),
|
||||||
|
3: ('flash', p.BoolType, 0),
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 112
|
|
@ -0,0 +1,20 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
from .HDNodeType import HDNodeType
|
||||||
|
|
||||||
|
|
||||||
|
class DebugLinkState(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('layout', p.BytesType, 0),
|
||||||
|
2: ('pin', p.UnicodeType, 0),
|
||||||
|
3: ('matrix', p.UnicodeType, 0),
|
||||||
|
4: ('mnemonic', p.UnicodeType, 0),
|
||||||
|
5: ('node', HDNodeType, 0),
|
||||||
|
6: ('passphrase_protection', p.BoolType, 0),
|
||||||
|
7: ('reset_word', p.UnicodeType, 0),
|
||||||
|
8: ('reset_entropy', p.BytesType, 0),
|
||||||
|
9: ('recovery_fake_word', p.UnicodeType, 0),
|
||||||
|
10: ('recovery_word_pos', p.UVarintType, 0),
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 102
|
|
@ -0,0 +1,7 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class DebugLinkStop(p.MessageType):
|
||||||
|
MESSAGE_WIRE_TYPE = 103
|
|
@ -0,0 +1,13 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class DecryptMessage(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('address_n', p.UVarintType, p.FLAG_REPEATED),
|
||||||
|
2: ('nonce', p.BytesType, 0),
|
||||||
|
3: ('message', p.BytesType, 0),
|
||||||
|
4: ('hmac', p.BytesType, 0),
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 51
|
|
@ -0,0 +1,11 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class DecryptedMessage(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('message', p.BytesType, 0),
|
||||||
|
2: ('address', p.UnicodeType, 0),
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 52
|
|
@ -0,0 +1,10 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class ECDHSessionKey(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('session_key', p.BytesType, 0),
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 62
|
|
@ -0,0 +1,14 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class EncryptMessage(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('pubkey', p.BytesType, 0),
|
||||||
|
2: ('message', p.BytesType, 0),
|
||||||
|
3: ('display_only', p.BoolType, 0),
|
||||||
|
4: ('address_n', p.UVarintType, p.FLAG_REPEATED),
|
||||||
|
5: ('coin_name', p.UnicodeType, 0), # default='Bitcoin'
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 49
|
|
@ -0,0 +1,12 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class EncryptedMessage(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('nonce', p.BytesType, 0),
|
||||||
|
2: ('message', p.BytesType, 0),
|
||||||
|
3: ('hmac', p.BytesType, 0),
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 50
|
|
@ -0,0 +1,10 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class Entropy(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('entropy', p.BytesType, 0), # required
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 10
|
|
@ -0,0 +1,10 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class EntropyAck(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('entropy', p.BytesType, 0),
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 36
|
|
@ -0,0 +1,7 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class EntropyRequest(p.MessageType):
|
||||||
|
MESSAGE_WIRE_TYPE = 35
|
|
@ -0,0 +1,12 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class EstimateTxSize(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('outputs_count', p.UVarintType, 0), # required
|
||||||
|
2: ('inputs_count', p.UVarintType, 0), # required
|
||||||
|
3: ('coin_name', p.UnicodeType, 0), # default='Bitcoin'
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 43
|
|
@ -0,0 +1,10 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class EthereumAddress(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('address', p.BytesType, 0), # required
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 57
|
|
@ -0,0 +1,11 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class EthereumGetAddress(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('address_n', p.UVarintType, p.FLAG_REPEATED),
|
||||||
|
2: ('show_display', p.BoolType, 0),
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 56
|
|
@ -0,0 +1,11 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class EthereumMessageSignature(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('address', p.BytesType, 0),
|
||||||
|
2: ('signature', p.BytesType, 0),
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 66
|
|
@ -0,0 +1,11 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class EthereumSignMessage(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('address_n', p.UVarintType, p.FLAG_REPEATED),
|
||||||
|
2: ('message', p.BytesType, 0), # required
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 64
|
|
@ -0,0 +1,18 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class EthereumSignTx(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('address_n', p.UVarintType, p.FLAG_REPEATED),
|
||||||
|
2: ('nonce', p.BytesType, 0),
|
||||||
|
3: ('gas_price', p.BytesType, 0),
|
||||||
|
4: ('gas_limit', p.BytesType, 0),
|
||||||
|
5: ('to', p.BytesType, 0),
|
||||||
|
6: ('value', p.BytesType, 0),
|
||||||
|
7: ('data_initial_chunk', p.BytesType, 0),
|
||||||
|
8: ('data_length', p.UVarintType, 0),
|
||||||
|
9: ('chain_id', p.UVarintType, 0),
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 58
|
|
@ -0,0 +1,10 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class EthereumTxAck(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('data_chunk', p.BytesType, 0),
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 60
|
|
@ -0,0 +1,13 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class EthereumTxRequest(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('data_length', p.UVarintType, 0),
|
||||||
|
2: ('signature_v', p.UVarintType, 0),
|
||||||
|
3: ('signature_r', p.BytesType, 0),
|
||||||
|
4: ('signature_s', p.BytesType, 0),
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 59
|
|
@ -0,0 +1,12 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class EthereumVerifyMessage(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('address', p.BytesType, 0),
|
||||||
|
2: ('signature', p.BytesType, 0),
|
||||||
|
3: ('message', p.BytesType, 0),
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 65
|
|
@ -0,0 +1,11 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class Failure(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('code', p.UVarintType, 0),
|
||||||
|
2: ('message', p.UnicodeType, 0),
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 3
|
|
@ -0,0 +1,13 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
UnexpectedMessage = 1
|
||||||
|
ButtonExpected = 2
|
||||||
|
DataError = 3
|
||||||
|
ActionCancelled = 4
|
||||||
|
PinExpected = 5
|
||||||
|
PinCancelled = 6
|
||||||
|
PinInvalid = 7
|
||||||
|
InvalidSignature = 8
|
||||||
|
ProcessError = 9
|
||||||
|
NotEnoughFunds = 10
|
||||||
|
NotInitialized = 11
|
||||||
|
FirmwareError = 99
|
|
@ -0,0 +1,31 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
from .CoinType import CoinType
|
||||||
|
|
||||||
|
|
||||||
|
class Features(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('vendor', p.UnicodeType, 0),
|
||||||
|
2: ('major_version', p.UVarintType, 0),
|
||||||
|
3: ('minor_version', p.UVarintType, 0),
|
||||||
|
4: ('patch_version', p.UVarintType, 0),
|
||||||
|
5: ('bootloader_mode', p.BoolType, 0),
|
||||||
|
6: ('device_id', p.UnicodeType, 0),
|
||||||
|
7: ('pin_protection', p.BoolType, 0),
|
||||||
|
8: ('passphrase_protection', p.BoolType, 0),
|
||||||
|
9: ('language', p.UnicodeType, 0),
|
||||||
|
10: ('label', p.UnicodeType, 0),
|
||||||
|
11: ('coins', CoinType, p.FLAG_REPEATED),
|
||||||
|
12: ('initialized', p.BoolType, 0),
|
||||||
|
13: ('revision', p.BytesType, 0),
|
||||||
|
14: ('bootloader_hash', p.BytesType, 0),
|
||||||
|
15: ('imported', p.BoolType, 0),
|
||||||
|
16: ('pin_cached', p.BoolType, 0),
|
||||||
|
17: ('passphrase_cached', p.BoolType, 0),
|
||||||
|
18: ('firmware_present', p.BoolType, 0),
|
||||||
|
19: ('needs_backup', p.BoolType, 0),
|
||||||
|
20: ('flags', p.UVarintType, 0),
|
||||||
|
21: ('model', p.UnicodeType, 0),
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 17
|
|
@ -0,0 +1,10 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class FirmwareErase(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('length', p.UVarintType, 0),
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 6
|
|
@ -0,0 +1,11 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class FirmwareRequest(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('offset', p.UVarintType, 0),
|
||||||
|
2: ('length', p.UVarintType, 0),
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 8
|
|
@ -0,0 +1,11 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class FirmwareUpload(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('payload', p.BytesType, 0), # required
|
||||||
|
2: ('hash', p.BytesType, 0),
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 7
|
|
@ -0,0 +1,15 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
from .MultisigRedeemScriptType import MultisigRedeemScriptType
|
||||||
|
|
||||||
|
|
||||||
|
class GetAddress(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('address_n', p.UVarintType, p.FLAG_REPEATED),
|
||||||
|
2: ('coin_name', p.UnicodeType, 0), # default='Bitcoin'
|
||||||
|
3: ('show_display', p.BoolType, 0),
|
||||||
|
4: ('multisig', MultisigRedeemScriptType, 0),
|
||||||
|
5: ('script_type', p.UVarintType, 0), # default=0
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 29
|
|
@ -0,0 +1,13 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
from .IdentityType import IdentityType
|
||||||
|
|
||||||
|
|
||||||
|
class GetECDHSessionKey(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('identity', IdentityType, 0),
|
||||||
|
2: ('peer_public_key', p.BytesType, 0),
|
||||||
|
3: ('ecdsa_curve_name', p.UnicodeType, 0),
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 61
|
|
@ -0,0 +1,10 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class GetEntropy(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('size', p.UVarintType, 0), # required
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 9
|
|
@ -0,0 +1,7 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class GetFeatures(p.MessageType):
|
||||||
|
MESSAGE_WIRE_TYPE = 55
|
|
@ -0,0 +1,13 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class GetPublicKey(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('address_n', p.UVarintType, p.FLAG_REPEATED),
|
||||||
|
2: ('ecdsa_curve_name', p.UnicodeType, 0),
|
||||||
|
3: ('show_display', p.BoolType, 0),
|
||||||
|
4: ('coin_name', p.UnicodeType, 0), # default='Bitcoin'
|
||||||
|
}
|
||||||
|
MESSAGE_WIRE_TYPE = 11
|
|
@ -0,0 +1,11 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
from .HDNodeType import HDNodeType
|
||||||
|
|
||||||
|
|
||||||
|
class HDNodePathType(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('node', HDNodeType, 0), # required
|
||||||
|
2: ('address_n', p.UVarintType, p.FLAG_REPEATED),
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
# Automatically generated by pb2py
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .. import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
|
class HDNodeType(p.MessageType):
|
||||||
|
FIELDS = {
|
||||||
|
1: ('depth', p.UVarintType, 0), # required
|
||||||
|
2: ('fingerprint', p.UVarintType, 0), # required
|
||||||
|
3: ('child_num', p.UVarintType, 0), # required
|
||||||
|
4: ('chain_code', p.BytesType, 0), # required
|
||||||
|
5: ('private_key', p.BytesType, 0),
|
||||||
|
6: ('public_key', p.BytesType, 0),
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue