diff --git a/python/src/trezorlib/cli/trezorctl.py b/python/src/trezorlib/cli/trezorctl.py index b3a885e4c8..b94ee5af72 100755 --- a/python/src/trezorlib/cli/trezorctl.py +++ b/python/src/trezorlib/cli/trezorctl.py @@ -226,7 +226,6 @@ def cli_main( except ValueError: raise click.ClickException(f"Not a valid session id: {session_id}") - # ctx.obj = TrezorConnection(path, bytes_session_id, passphrase_on_host, script) ctx.obj = TrezorConnection(path, bytes_session_id, passphrase_on_host, script) # Optionally record the screen into a specified directory. @@ -299,7 +298,7 @@ def list_devices(no_resolve: bool) -> Optional[Iterable["Transport"]]: """List connected Trezor devices.""" if no_resolve: for d in enumerate_devices(): - print(d.get_path()) + click.echo(d.get_path()) return from . import get_client @@ -358,7 +357,6 @@ def get_session( obj.session_id = None with obj.client_context() as client: - if client.features.model == "1" and client.version < (1, 9, 0): raise click.ClickException( "Upgrade your firmware to enable session support." diff --git a/python/src/trezorlib/debuglink.py b/python/src/trezorlib/debuglink.py index db4531885b..3b99ac94b5 100644 --- a/python/src/trezorlib/debuglink.py +++ b/python/src/trezorlib/debuglink.py @@ -1,6 +1,6 @@ # This file is part of the Trezor project. # -# Copyright (C) 2012-2024 SatoshiLabs and contributors +# Copyright (C) 2012-2022 SatoshiLabs and contributors # # This library is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License version 3 @@ -111,9 +111,7 @@ class UnstructuredJSONReader: def top_level_value(self, key: str) -> t.Any: return self.dict.get(key) - def find_objects_with_key_and_value( - self, key: str, value: t.Any - ) -> list["AnyDict"]: + def find_objects_with_key_and_value(self, key: str, value: t.Any) -> list[AnyDict]: def recursively_find(data: t.Any) -> t.Iterator[t.Any]: if isinstance(data, dict): if data.get(key) == value: @@ -430,7 +428,6 @@ def _make_input_func( class DebugLink: - def __init__(self, transport: "Transport", auto_interact: bool = True) -> None: self.transport = transport self.allow_interactions = auto_interact @@ -536,10 +533,7 @@ class DebugLink: self._write(msg) return self._read() - def state( - self, - wait_type: DebugWaitType | None = None, - ) -> messages.DebugLinkState: + def state(self, wait_type: DebugWaitType | None = None) -> messages.DebugLinkState: if wait_type is None: wait_type = ( DebugWaitType.CURRENT_LAYOUT @@ -1040,7 +1034,6 @@ class MessageFilter: class MessageFilterGenerator: - def __getattr__(self, key: str) -> t.Callable[..., "MessageFilter"]: message_type = getattr(messages, key) return MessageFilter(message_type).update_fields @@ -1320,6 +1313,7 @@ class TrezorClientDebugLink(TrezorClient): self.reset_debug_features(new_management_session=True) self.sync_responses() + # So that we can choose right screenshotting logic (T1 vs TT) # and know the supported debug capabilities self.debug.model = self.model @@ -1340,7 +1334,6 @@ class TrezorClientDebugLink(TrezorClient): Clears all debugging state that might have been modified by a testcase. """ self.ui: DebugUI = DebugUI(self.debug) - # self.pin_callback = self.ui.debug_callback_button self.in_with_statement = False self.expected_responses: list[MessageFilter] | None = None self.actual_responses: list[protobuf.MessageType] | None = None diff --git a/python/src/trezorlib/tools.py b/python/src/trezorlib/tools.py index 260a61aed2..f753e68a33 100644 --- a/python/src/trezorlib/tools.py +++ b/python/src/trezorlib/tools.py @@ -389,23 +389,6 @@ def _return_success(msg: "Success") -> str | None: return _deprecation_retval_helper(msg.message, stacklevel=1) -# def session( -# f: "Callable[Concatenate[TrezorClient, P], R]", -# ) -> "Callable[Concatenate[TrezorClient, P], R]": -# # Decorator wraps a BaseClient method -# # with session activation / deactivation -# @functools.wraps(f) -# def wrapped_f(client: "TrezorClient", *args: "P.args", **kwargs: "P.kwargs") -> "R": -# __tracebackhide__ = True # for pytest # pylint: disable=W0612 -# client.open() -# try: -# return f(client, *args, **kwargs) -# finally: -# client.close() - -# return wrapped_f - - # de-camelcasifier # https://stackoverflow.com/a/1176023/222189 diff --git a/python/src/trezorlib/transport/__init__.py b/python/src/trezorlib/transport/__init__.py index 45d05150c2..2c208be36d 100644 --- a/python/src/trezorlib/transport/__init__.py +++ b/python/src/trezorlib/transport/__init__.py @@ -1,6 +1,6 @@ # This file is part of the Trezor project. # -# Copyright (C) 2012-2024 SatoshiLabs and contributors +# Copyright (C) 2012-2022 SatoshiLabs and contributors # # This library is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License version 3 diff --git a/python/src/trezorlib/transport/bridge.py b/python/src/trezorlib/transport/bridge.py index 8d69e5b253..7f136608b0 100644 --- a/python/src/trezorlib/transport/bridge.py +++ b/python/src/trezorlib/transport/bridge.py @@ -1,6 +1,6 @@ # This file is part of the Trezor project. # -# Copyright (C) 2012-2024 SatoshiLabs and contributors +# Copyright (C) 2012-2022 SatoshiLabs and contributors # # This library is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License version 3 diff --git a/python/src/trezorlib/transport/hid.py b/python/src/trezorlib/transport/hid.py index 995fd6960c..65e2cddf7d 100644 --- a/python/src/trezorlib/transport/hid.py +++ b/python/src/trezorlib/transport/hid.py @@ -1,6 +1,6 @@ # This file is part of the Trezor project. # -# Copyright (C) 2012-2024 SatoshiLabs and contributors +# Copyright (C) 2012-2022 SatoshiLabs and contributors # # This library is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License version 3 diff --git a/python/src/trezorlib/transport/thp/protocol_v2.py b/python/src/trezorlib/transport/thp/protocol_v2.py index 17f463d49b..a2a930d07f 100644 --- a/python/src/trezorlib/transport/thp/protocol_v2.py +++ b/python/src/trezorlib/transport/thp/protocol_v2.py @@ -6,7 +6,6 @@ import logging import os import typing as t from binascii import hexlify -from enum import IntEnum import click from cryptography.hazmat.primitives.ciphers.aead import AESGCM @@ -468,10 +467,3 @@ class ProtocolV2(ProtocolAndChannel): ) return False return True - - class ControlByteType(IntEnum): - CHANNEL_ALLOCATION_RES = 1 - HANDSHAKE_INIT_RES = 2 - HANDSHAKE_COMP_RES = 3 - ACK = 4 - ENCRYPTED_TRANSPORT = 5 diff --git a/python/src/trezorlib/transport/udp.py b/python/src/trezorlib/transport/udp.py index 2960df8994..e17d6f4500 100644 --- a/python/src/trezorlib/transport/udp.py +++ b/python/src/trezorlib/transport/udp.py @@ -1,6 +1,6 @@ # This file is part of the Trezor project. # -# Copyright (C) 2012-2024 SatoshiLabs and contributors +# Copyright (C) 2012-2022 SatoshiLabs and contributors # # This library is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License version 3 diff --git a/python/src/trezorlib/transport/webusb.py b/python/src/trezorlib/transport/webusb.py index 023ed5f245..872d961960 100644 --- a/python/src/trezorlib/transport/webusb.py +++ b/python/src/trezorlib/transport/webusb.py @@ -1,6 +1,6 @@ # This file is part of the Trezor project. # -# Copyright (C) 2012-2024 SatoshiLabs and contributors +# Copyright (C) 2012-2022 SatoshiLabs and contributors # # This library is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License version 3 diff --git a/python/tools/helloworld.py b/python/tools/helloworld.py index b8711dbb00..2403bb4bc2 100755 --- a/python/tools/helloworld.py +++ b/python/tools/helloworld.py @@ -24,14 +24,14 @@ from trezorlib.tools import parse_path def main() -> None: # Use first connected device client = get_default_client() - session = client.get_session(derive_cardano=True) + session = client.get_session() # Print out Trezor's features and settings print(session.features) # Get the first address of first BIP44 account bip32_path = parse_path("44h/0h/0h/0/0") - address = btc.get_address(session, "Bitcoin", bip32_path, False) + address = btc.get_address(session, "Bitcoin", bip32_path, True) print("Bitcoin address:", address) diff --git a/tests/translations.py b/tests/translations.py index 34f79888ba..ad5747d320 100644 --- a/tests/translations.py +++ b/tests/translations.py @@ -71,7 +71,7 @@ def set_language(session: Session, lang: str): language_data = build_and_sign_blob(lang, session) with session: device.change_language(session, language_data) # type: ignore - + _CURRENT_TRANSLATION.TR = TRANSLATIONS[lang] def get_lang_json(lang: str) -> translations.JsonDef: assert lang in LANGUAGES