diff --git a/libagent/device/keepkey_defs.py b/libagent/device/keepkey_defs.py index 5ecf127..9791ad0 100644 --- a/libagent/device/keepkey_defs.py +++ b/libagent/device/keepkey_defs.py @@ -5,5 +5,10 @@ from keepkeylib.client import CallException, PinException from keepkeylib.client import KeepKeyClient as Client from keepkeylib.messages_pb2 import PassphraseAck, PinMatrixAck -from keepkeylib.transport_hid import HidTransport as Transport +from keepkeylib.transport_hid import HidTransport from keepkeylib.types_pb2 import IdentityType + + +def enumerate_transports(): + """Returns USB HID transports.""" + return [HidTransport(p) for p in HidTransport.enumerate()] diff --git a/libagent/device/trezor.py b/libagent/device/trezor.py index 04db53a..c5a5906 100644 --- a/libagent/device/trezor.py +++ b/libagent/device/trezor.py @@ -115,14 +115,14 @@ class Trezor(interface.Device): current_version)) def connect(self): - """Enumerate and connect to the first USB HID interface.""" - transport = self._defs.TrezorDevice.enumerate() - if not transport: + """Enumerate and connect to the first available interface.""" + transports = self._defs.enumerate_transports() + if not transports: raise interface.NotFoundError('{} not connected'.format(self)) - log.debug('transports: %s', transport) + log.debug('transports: %s', transports) for _ in range(5): - connection = self._defs.Client(transport[0]) + connection = self._defs.Client(transports[0]) self._override_pin_handler(connection) self._override_passphrase_handler(connection) self._verify_version(connection) diff --git a/libagent/device/trezor_defs.py b/libagent/device/trezor_defs.py index 5804e4b..a4daf81 100644 --- a/libagent/device/trezor_defs.py +++ b/libagent/device/trezor_defs.py @@ -6,3 +6,8 @@ from trezorlib.client import CallException, PinException from trezorlib.client import TrezorClient as Client from trezorlib.messages import IdentityType, PassphraseAck, PinMatrixAck from trezorlib.device import TrezorDevice + + +def enumerate_transports(): + """Returns all available transports.""" + return TrezorDevice.enumerate()