hww: show model name in device enum lists (e.g. "Trezor T")
This commit is contained in:
@@ -228,6 +228,12 @@ class HardwareClientBase:
|
||||
password = Xpub.get_pubkey_from_xpub(xpub, ()).hex()
|
||||
return password
|
||||
|
||||
def device_model_name(self) -> Optional[str]:
|
||||
"""Return the name of the model of this device, which might be displayed in the UI.
|
||||
E.g. for Trezor, "Trezor One" or "Trezor T".
|
||||
"""
|
||||
return None
|
||||
|
||||
|
||||
class HardwareHandlerBase:
|
||||
"""An interface between the GUI and the device handling logic for handling I/O."""
|
||||
|
||||
@@ -2,7 +2,7 @@ from struct import pack, unpack
|
||||
import hashlib
|
||||
import sys
|
||||
import traceback
|
||||
from typing import Optional
|
||||
from typing import Optional, Tuple
|
||||
|
||||
from electrum import ecc
|
||||
from electrum import bip32
|
||||
@@ -62,10 +62,10 @@ def test_pin_unlocked(func):
|
||||
|
||||
|
||||
class Ledger_Client(HardwareClientBase):
|
||||
def __init__(self, hidDevice, *, is_hw1: bool = False):
|
||||
def __init__(self, hidDevice, *, product_key: Tuple[int, int]):
|
||||
self.dongleObject = btchip(hidDevice)
|
||||
self.preflightDone = False
|
||||
self._is_hw1 = is_hw1
|
||||
self._product_key = product_key
|
||||
self._soft_device_id = None
|
||||
|
||||
def is_pairable(self):
|
||||
@@ -92,7 +92,18 @@ class Ledger_Client(HardwareClientBase):
|
||||
return self._soft_device_id
|
||||
|
||||
def is_hw1(self) -> bool:
|
||||
return self._is_hw1
|
||||
return self._product_key[0] == 0x2581
|
||||
|
||||
def device_model_name(self):
|
||||
if self.is_hw1():
|
||||
return "Ledger HW.1"
|
||||
if self._product_key == (0x2c97, 0x0000):
|
||||
return "Ledger Blue"
|
||||
if self._product_key == (0x2c97, 0x0001):
|
||||
return "Ledger Nano S"
|
||||
if self._product_key == (0x2c97, 0x0004):
|
||||
return "Ledger Nano X"
|
||||
return None
|
||||
|
||||
def has_usable_connection_with_device(self):
|
||||
try:
|
||||
@@ -594,8 +605,7 @@ class LedgerPlugin(HW_PluginBase):
|
||||
|
||||
client = self.get_btchip_device(device)
|
||||
if client is not None:
|
||||
is_hw1 = device.product_key[0] == 0x2581
|
||||
client = Ledger_Client(client, is_hw1=is_hw1)
|
||||
client = Ledger_Client(client, product_key=device.product_key)
|
||||
return client
|
||||
|
||||
def setup_device(self, device_info, wizard, purpose):
|
||||
|
||||
@@ -196,6 +196,14 @@ class TrezorClientBase(HardwareClientBase, Logger):
|
||||
"""Returns '1' for Trezor One, 'T' for Trezor T."""
|
||||
return self.features.model
|
||||
|
||||
def device_model_name(self):
|
||||
model = self.get_trezor_model()
|
||||
if model == '1':
|
||||
return "Trezor One"
|
||||
elif model == 'T':
|
||||
return "Trezor T"
|
||||
return None
|
||||
|
||||
def show_address(self, address_str, script_type, multisig=None):
|
||||
coin_name = self.plugin.get_coin_name()
|
||||
address_n = parse_path(address_str)
|
||||
|
||||
Reference in New Issue
Block a user