1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 15:38:11 +00:00

Allow specifying 'state' at ProtocolMixin c-tor

This commit is contained in:
Roman Zeyde 2018-03-27 15:52:32 +03:00 committed by matejcik
parent 5d0b5632b3
commit bd3d014dd4
2 changed files with 7 additions and 3 deletions

View File

@ -87,7 +87,7 @@ def cli(ctx, path, verbose, is_json):
if path is not None: if path is not None:
click.echo("Using path: {}".format(path)) click.echo("Using path: {}".format(path))
sys.exit(1) sys.exit(1)
return cls(device) return cls(transport=device)
ctx.obj = get_device ctx.obj = get_device

View File

@ -496,8 +496,9 @@ class ProtocolMixin(object):
PRIME_DERIVATION_FLAG = 0x80000000 PRIME_DERIVATION_FLAG = 0x80000000
VENDORS = ('bitcointrezor.com', 'trezor.io') VENDORS = ('bitcointrezor.com', 'trezor.io')
def __init__(self, *args, **kwargs): def __init__(self, state=None, *args, **kwargs):
super(ProtocolMixin, self).__init__(*args, **kwargs) super(ProtocolMixin, self).__init__(*args, **kwargs)
self.state = state
self.init_device() self.init_device()
self.tx_api = None self.tx_api = None
@ -505,7 +506,10 @@ class ProtocolMixin(object):
self.tx_api = tx_api self.tx_api = tx_api
def init_device(self): def init_device(self):
self.features = expect(proto.Features)(self.call)(proto.Initialize()) init_msg = proto.Initialize()
if self.state is not None:
init_msg.state = self.state
self.features = expect(proto.Features)(self.call)(init_msg)
if str(self.features.vendor) not in self.VENDORS: if str(self.features.vendor) not in self.VENDORS:
raise RuntimeError("Unsupported device") raise RuntimeError("Unsupported device")