hww: mark device_model_name(self) as @abstractmethod and override in hww clients that did not define it.
This commit is contained in:
@@ -72,6 +72,9 @@ class BitBox02Client(HardwareClientBase):
|
|||||||
if self.bitbox_hid_info is None:
|
if self.bitbox_hid_info is None:
|
||||||
raise Exception("No BitBox02 detected")
|
raise Exception("No BitBox02 detected")
|
||||||
|
|
||||||
|
def device_model_name(self) -> Optional[str]:
|
||||||
|
return 'BitBox02'
|
||||||
|
|
||||||
def is_initialized(self) -> bool:
|
def is_initialized(self) -> bool:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ CKCC_SIMULATED_PID = CKCC_PID ^ 0x55aa
|
|||||||
|
|
||||||
|
|
||||||
class CKCCClient(HardwareClientBase):
|
class CKCCClient(HardwareClientBase):
|
||||||
|
|
||||||
def __init__(self, plugin, handler, dev_path, *, is_simulator=False):
|
def __init__(self, plugin, handler, dev_path, *, is_simulator=False):
|
||||||
HardwareClientBase.__init__(self, plugin=plugin)
|
HardwareClientBase.__init__(self, plugin=plugin)
|
||||||
self.device = plugin.device
|
self.device = plugin.device
|
||||||
@@ -80,6 +79,9 @@ class CKCCClient(HardwareClientBase):
|
|||||||
# NOTE: MiTM test is delayed until we have a hint as to what XPUB we
|
# NOTE: MiTM test is delayed until we have a hint as to what XPUB we
|
||||||
# should expect. It's also kinda slow.
|
# should expect. It's also kinda slow.
|
||||||
|
|
||||||
|
def device_model_name(self) -> Optional[str]:
|
||||||
|
return 'Coldcard'
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<CKCCClient: xfp=%s label=%r>' % (xfp2str(self.dev.master_fingerprint),
|
return '<CKCCClient: xfp=%s label=%r>' % (xfp2str(self.dev.master_fingerprint),
|
||||||
self.label())
|
self.label())
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import struct
|
|||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import copy
|
import copy
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING, Optional
|
||||||
|
|
||||||
from electrum.crypto import sha256d, EncodeAES_bytes, DecodeAES_bytes, hmac_oneshot
|
from electrum.crypto import sha256d, EncodeAES_bytes, DecodeAES_bytes, hmac_oneshot
|
||||||
from electrum.bitcoin import public_key_to_p2pkh
|
from electrum.bitcoin import public_key_to_p2pkh
|
||||||
@@ -69,8 +69,8 @@ MIN_MAJOR_VERSION = 5
|
|||||||
ENCRYPTION_PRIVKEY_KEY = 'encryptionprivkey'
|
ENCRYPTION_PRIVKEY_KEY = 'encryptionprivkey'
|
||||||
CHANNEL_ID_KEY = 'comserverchannelid'
|
CHANNEL_ID_KEY = 'comserverchannelid'
|
||||||
|
|
||||||
class DigitalBitbox_Client(HardwareClientBase):
|
|
||||||
|
|
||||||
|
class DigitalBitbox_Client(HardwareClientBase):
|
||||||
def __init__(self, plugin, hidDevice):
|
def __init__(self, plugin, hidDevice):
|
||||||
HardwareClientBase.__init__(self, plugin=plugin)
|
HardwareClientBase.__init__(self, plugin=plugin)
|
||||||
self.dbb_hid = hidDevice
|
self.dbb_hid = hidDevice
|
||||||
@@ -80,6 +80,9 @@ class DigitalBitbox_Client(HardwareClientBase):
|
|||||||
self.setupRunning = False
|
self.setupRunning = False
|
||||||
self.usbReportSize = 64 # firmware > v2.0.0
|
self.usbReportSize = 64 # firmware > v2.0.0
|
||||||
|
|
||||||
|
def device_model_name(self) -> Optional[str]:
|
||||||
|
return 'Digital BitBox'
|
||||||
|
|
||||||
@runs_in_hwd_thread
|
@runs_in_hwd_thread
|
||||||
def close(self):
|
def close(self):
|
||||||
if self.opened:
|
if self.opened:
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
# SOFTWARE.
|
# SOFTWARE.
|
||||||
|
from abc import abstractmethod
|
||||||
from typing import TYPE_CHECKING, Sequence, Optional, Type, Iterable, Any
|
from typing import TYPE_CHECKING, Sequence, Optional, Type, Iterable, Any
|
||||||
|
|
||||||
from electrum.plugin import (BasePlugin, hook, Device, DeviceMgr,
|
from electrum.plugin import (BasePlugin, hook, Device, DeviceMgr,
|
||||||
@@ -249,6 +249,7 @@ class HardwareClientBase:
|
|||||||
password = Xpub.get_pubkey_from_xpub(xpub, ()).hex()
|
password = Xpub.get_pubkey_from_xpub(xpub, ()).hex()
|
||||||
return password
|
return password
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
def device_model_name(self) -> Optional[str]:
|
def device_model_name(self) -> Optional[str]:
|
||||||
"""Return the name of the model of this device, which might be displayed in the UI.
|
"""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".
|
E.g. for Trezor, "Trezor One" or "Trezor T".
|
||||||
|
|||||||
@@ -117,6 +117,9 @@ class SafeTClientBase(HardwareClientBase, GuiMixin, Logger):
|
|||||||
Logger.__init__(self)
|
Logger.__init__(self)
|
||||||
self.used()
|
self.used()
|
||||||
|
|
||||||
|
def device_model_name(self) -> Optional[str]:
|
||||||
|
return 'Safe-T'
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%s/%s" % (self.label(), self.features.device_id)
|
return "%s/%s" % (self.label(), self.features.device_id)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user