From a6d8c2122cdafe620efbe0e23ab154296317e61a Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Tue, 27 Mar 2018 15:52:32 +0300 Subject: [PATCH] Allow specifying 'state' at ProtocolMixin c-tor --- trezorctl | 2 +- trezorlib/client.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/trezorctl b/trezorctl index 115993ee..b9ad180c 100755 --- a/trezorctl +++ b/trezorctl @@ -87,7 +87,7 @@ def cli(ctx, path, verbose, is_json): if path is not None: click.echo("Using path: {}".format(path)) sys.exit(1) - return cls(device) + return cls(transport=device) ctx.obj = get_device diff --git a/trezorlib/client.py b/trezorlib/client.py index 68e259ac..f6918189 100644 --- a/trezorlib/client.py +++ b/trezorlib/client.py @@ -496,8 +496,9 @@ class ProtocolMixin(object): PRIME_DERIVATION_FLAG = 0x80000000 VENDORS = ('bitcointrezor.com', 'trezor.io') - def __init__(self, *args, **kwargs): + def __init__(self, state=None, *args, **kwargs): super(ProtocolMixin, self).__init__(*args, **kwargs) + self.state = state self.init_device() self.tx_api = None @@ -505,7 +506,10 @@ def set_tx_api(self, tx_api): self.tx_api = tx_api 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: raise RuntimeError("Unsupported device")