Skip to content
This repository has been archived by the owner on Jun 5, 2019. It is now read-only.

Commit

Permalink
Allow specifying 'state' at ProtocolMixin c-tor
Browse files Browse the repository at this point in the history
  • Loading branch information
romanz committed Mar 27, 2018
1 parent 8d296ed commit a6d8c21
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion trezorctl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 6 additions & 2 deletions trezorlib/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,16 +496,20 @@ 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

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")

Expand Down

0 comments on commit a6d8c21

Please sign in to comment.