Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: hwilib.devices.trezorlib.transport.bridge #601

Closed
k9ert opened this issue May 2, 2022 · 5 comments
Closed

ModuleNotFoundError: hwilib.devices.trezorlib.transport.bridge #601

k9ert opened this issue May 2, 2022 · 5 comments

Comments

@k9ert
Copy link
Contributor

k9ert commented May 2, 2022

This looks like this in one of my tests:

.env/lib/python3.8/site-packages/hwilib/devices/trezorlib/transport/__init__.py:133: in get_transport
    return next(iter(enumerate_devices()))
.env/lib/python3.8/site-packages/hwilib/devices/trezorlib/transport/__init__.py:116: in enumerate_devices
    for transport in all_transports():
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    def all_transports() -> Iterable[Type[Transport]]:
>       from .bridge import BridgeTransport
E       ModuleNotFoundError: No module named 'hwilib.devices.trezorlib.transport.bridge'

.env/lib/python3.8/site-packages/hwilib/devices/trezorlib/transport/__init__.py:102: ModuleNotFoundError

Here is a linkk to that code:
https://github.com/bitcoin-core/HWI/blob/master/hwilib/devices/trezorlib/transport/__init__.py#L102

I can't see any module like this?!

@prusnak
Copy link
Collaborator

prusnak commented May 3, 2022

It seems that HWI copy of trezorlib does not contain this module: https://github.com/trezor/trezor-firmware/blob/master/python/src/trezorlib/transport/bridge.py

@achow101
Copy link
Member

achow101 commented May 3, 2022

Are you accessing HWI's built-in trezorlib directly? AFAICT HWI does not use anything that reaches this line so we don't see this error.

If you are, this kind of usage is not supported.

@k9ert
Copy link
Contributor Author

k9ert commented May 4, 2022

This issue occurs while instantiating the TrezorClient like this:

TrezorClient(device["path"], passphrase, transport=get_transport())

In HWI 2.0.2 the TrezorClient got instantiated like this:

TrezorClient(device["path"], passphrase)

which results in this issue in 2.1.0:

tests/test_hwi_rpc.py:41: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
src/cryptoadvance/specter/helpers.py:81: in wrapper_fn
    return fn(*args, **kwargs)
src/cryptoadvance/specter/hwi_rpc.py:182: in prompt_pin
    with self._get_client(
/usr/lib/python3.8/contextlib.py:113: in __enter__
    return next(self.gen)
src/cryptoadvance/specter/hwi_rpc.py:420: in _get_client
    client = devcls.get_client(
src/cryptoadvance/specter/devices/trezor.py:16: in get_client
    return TrezorClient(*args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <hwilib.devices.trezorlib.client.TrezorClient object at 0x7f3bdfb7b6d0>, transport = 'webusb:003:1:1:4', ui = '', session_id = None

    def __init__(
        self,
        transport,
        ui,
        session_id=None,
    ):
>       LOG.info("creating client instance for device: {}".format(transport.get_path()))
E       AttributeError: 'str' object has no attribute 'get_path'

.env/lib/python3.8/site-packages/hwilib/devices/trezorlib/client.py:91: AttributeError

So i did what's written in the documentation of the class:

    You have to provide a transport, i.e., a raw connection to the device. You can use
    `trezorlib.transport.get_transport` to find one.

@achow101
Copy link
Member

achow101 commented May 4, 2022

hwilib.devices.trezorlib.client.TrezorClient is trezorlib's TrezorClient, not HWI's TrezorClient. So you're trying to use the underlying library objects directly, which is not supported by HWI.

@k9ert
Copy link
Contributor Author

k9ert commented May 5, 2022

Ok, got it instead of:

from hwilib.devices.trezorlib.client import TrezorClient

i did

from hwilib.devices.trezor import TrezorClient

and it now works. It was not obvious to me. Thanks.

@k9ert k9ert closed this as completed May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants