Browse Source

wizard/hw: show transport type when listing HWDs

3.3.3.1
SomberNight 6 years ago
parent
commit
32af83b7ae
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 3
      electrum/base_wizard.py
  2. 9
      electrum/plugin.py
  3. 8
      electrum/plugins/coldcard/coldcard.py
  4. 8
      electrum/plugins/safe_t/safe_t.py
  5. 8
      electrum/plugins/trezor/trezor.py

3
electrum/base_wizard.py

@ -283,8 +283,7 @@ class BaseWizard(object):
for name, info in devices: for name, info in devices:
state = _("initialized") if info.initialized else _("wiped") state = _("initialized") if info.initialized else _("wiped")
label = info.label or _("An unnamed {}").format(name) label = info.label or _("An unnamed {}").format(name)
descr = f"{label} [{name}, {state}]" descr = f"{label} [{name}, {state}, {info.device.transport_ui_string}]"
# TODO maybe expose info.device.path (mainly for transport type)
choices.append(((name, info), descr)) choices.append(((name, info), descr))
msg = _('Select a device') + ':' msg = _('Select a device') + ':'
self.choice_dialog(title=title, message=msg, choices=choices, run_next= lambda *args: self.on_device(*args, purpose=purpose)) self.choice_dialog(title=title, message=msg, choices=choices, run_next= lambda *args: self.on_device(*args, purpose=purpose))

9
electrum/plugin.py

@ -291,6 +291,7 @@ class Device(NamedTuple):
id_: str id_: str
product_key: Any # when using hid, often Tuple[int, int] product_key: Any # when using hid, often Tuple[int, int]
usage_page: int usage_page: int
transport_ui_string: str
class DeviceInfo(NamedTuple): class DeviceInfo(NamedTuple):
@ -576,8 +577,12 @@ class DeviceMgr(ThreadJob, PrintError):
if len(id_) == 0: if len(id_) == 0:
id_ = str(d['path']) id_ = str(d['path'])
id_ += str(interface_number) + str(usage_page) id_ += str(interface_number) + str(usage_page)
devices.append(Device(d['path'], interface_number, devices.append(Device(path=d['path'],
id_, product_key, usage_page)) interface_number=interface_number,
id_=id_,
product_key=product_key,
usage_page=usage_page,
transport_ui_string='hid'))
return devices return devices
def scan_devices(self): def scan_devices(self):

8
electrum/plugins/coldcard/coldcard.py

@ -625,10 +625,14 @@ class ColdcardPlugin(HW_PluginBase):
fn = CKCC_SIMULATOR_PATH fn = CKCC_SIMULATOR_PATH
if os.path.exists(fn): 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 [] return []
def create_client(self, device, handler): def create_client(self, device, handler):
if handler: if handler:

8
electrum/plugins/safe_t/safe_t.py

@ -105,7 +105,13 @@ class SafeTPlugin(HW_PluginBase):
def enumerate(self): def enumerate(self):
devices = self.transport_handler.enumerate_devices() 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): def create_client(self, device, handler):
try: try:

8
electrum/plugins/trezor/trezor.py

@ -106,7 +106,13 @@ class TrezorPlugin(HW_PluginBase):
def enumerate(self): def enumerate(self):
devices = self.transport_handler.enumerate_devices() 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): def create_client(self, device, handler):
try: try:

Loading…
Cancel
Save