electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 32af83b7aede02f0b9bb3e8294ef2dc0481fb6de
parent eba97f74b41b0e647aaf600f7cdd3bf643a40fee
Author: SomberNight <somber.night@protonmail.com>
Date:   Fri, 16 Nov 2018 19:03:25 +0100

wizard/hw: show transport type when listing HWDs

Diffstat:
Melectrum/base_wizard.py | 3+--
Melectrum/plugin.py | 9+++++++--
Melectrum/plugins/coldcard/coldcard.py | 8++++++--
Melectrum/plugins/safe_t/safe_t.py | 8+++++++-
Melectrum/plugins/trezor/trezor.py | 8+++++++-
5 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/electrum/base_wizard.py b/electrum/base_wizard.py @@ -283,8 +283,7 @@ class BaseWizard(object): for name, info in devices: state = _("initialized") if info.initialized else _("wiped") label = info.label or _("An unnamed {}").format(name) - descr = f"{label} [{name}, {state}]" - # TODO maybe expose info.device.path (mainly for transport type) + descr = f"{label} [{name}, {state}, {info.device.transport_ui_string}]" choices.append(((name, info), descr)) msg = _('Select a device') + ':' self.choice_dialog(title=title, message=msg, choices=choices, run_next= lambda *args: self.on_device(*args, purpose=purpose)) diff --git a/electrum/plugin.py b/electrum/plugin.py @@ -291,6 +291,7 @@ class Device(NamedTuple): id_: str product_key: Any # when using hid, often Tuple[int, int] usage_page: int + transport_ui_string: str class DeviceInfo(NamedTuple): @@ -576,8 +577,12 @@ class DeviceMgr(ThreadJob, PrintError): if len(id_) == 0: id_ = str(d['path']) id_ += str(interface_number) + str(usage_page) - devices.append(Device(d['path'], interface_number, - id_, product_key, usage_page)) + devices.append(Device(path=d['path'], + interface_number=interface_number, + id_=id_, + product_key=product_key, + usage_page=usage_page, + transport_ui_string='hid')) return devices def scan_devices(self): diff --git a/electrum/plugins/coldcard/coldcard.py b/electrum/plugins/coldcard/coldcard.py @@ -625,10 +625,14 @@ class ColdcardPlugin(HW_PluginBase): fn = CKCC_SIMULATOR_PATH if os.path.exists(fn): - return [Device(fn, -1, fn, (COINKITE_VID, CKCC_SIMULATED_PID), 0)] + return [Device(path=fn, + interface_number=-1, + id_=fn, + product_key=(COINKITE_VID, CKCC_SIMULATED_PID), + usage_page=0, + transport_ui_string='simulator')] return [] - def create_client(self, device, handler): if handler: diff --git a/electrum/plugins/safe_t/safe_t.py b/electrum/plugins/safe_t/safe_t.py @@ -105,7 +105,13 @@ class SafeTPlugin(HW_PluginBase): def enumerate(self): devices = self.transport_handler.enumerate_devices() - return [Device(d.get_path(), -1, d.get_path(), 'Safe-T mini', 0) for d in devices] + return [Device(path=d.get_path(), + interface_number=-1, + id_=d.get_path(), + product_key='Safe-T mini', + usage_page=0, + transport_ui_string=d.get_path()) + for d in devices] def create_client(self, device, handler): try: diff --git a/electrum/plugins/trezor/trezor.py b/electrum/plugins/trezor/trezor.py @@ -106,7 +106,13 @@ class TrezorPlugin(HW_PluginBase): def enumerate(self): devices = self.transport_handler.enumerate_devices() - return [Device(d.get_path(), -1, d.get_path(), 'TREZOR', 0) for d in devices] + return [Device(path=d.get_path(), + interface_number=-1, + id_=d.get_path(), + product_key='TREZOR', + usage_page=0, + transport_ui_string=d.get_path()) + for d in devices] def create_client(self, device, handler): try: