mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-29 16:31:29 +00:00
keepkey: support v6.0.0+ firmwares (webusb)
This commit is contained in:
parent
a62bf2a53a
commit
ef7af73bd3
1 changed files with 23 additions and 2 deletions
|
@ -85,10 +85,12 @@ class KeepKeyPlugin(HW_PluginBase):
|
||||||
import keepkeylib
|
import keepkeylib
|
||||||
import keepkeylib.ckd_public
|
import keepkeylib.ckd_public
|
||||||
import keepkeylib.transport_hid
|
import keepkeylib.transport_hid
|
||||||
|
import keepkeylib.transport_webusb
|
||||||
self.client_class = client.KeepKeyClient
|
self.client_class = client.KeepKeyClient
|
||||||
self.ckd_public = keepkeylib.ckd_public
|
self.ckd_public = keepkeylib.ckd_public
|
||||||
self.types = keepkeylib.client.types
|
self.types = keepkeylib.client.types
|
||||||
self.DEVICE_IDS = keepkeylib.transport_hid.DEVICE_IDS
|
self.DEVICE_IDS = (keepkeylib.transport_hid.DEVICE_IDS +
|
||||||
|
keepkeylib.transport_webusb.DEVICE_IDS)
|
||||||
self.device_manager().register_devices(self.DEVICE_IDS)
|
self.device_manager().register_devices(self.DEVICE_IDS)
|
||||||
self.libraries_available = True
|
self.libraries_available = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -98,6 +100,13 @@ class KeepKeyPlugin(HW_PluginBase):
|
||||||
from keepkeylib.transport_hid import HidTransport
|
from keepkeylib.transport_hid import HidTransport
|
||||||
return HidTransport(pair)
|
return HidTransport(pair)
|
||||||
|
|
||||||
|
def webusb_transport(self, device):
|
||||||
|
from keepkeylib.transport_webusb import WebUsbTransport
|
||||||
|
for d in WebUsbTransport.enumerate():
|
||||||
|
if device.id_.startswith(d.getSerialNumber()):
|
||||||
|
return WebUsbTransport(d)
|
||||||
|
return WebUsbTransport(device)
|
||||||
|
|
||||||
def _try_hid(self, device):
|
def _try_hid(self, device):
|
||||||
self.print_error("Trying to connect over USB...")
|
self.print_error("Trying to connect over USB...")
|
||||||
if device.interface_number == 1:
|
if device.interface_number == 1:
|
||||||
|
@ -113,8 +122,20 @@ class KeepKeyPlugin(HW_PluginBase):
|
||||||
self.print_error("cannot connect at", device.path, str(e))
|
self.print_error("cannot connect at", device.path, str(e))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def _try_webusb(self, device):
|
||||||
|
self.print_error("Trying to connect over WebUSB...")
|
||||||
|
try:
|
||||||
|
return self.webusb_transport(device)
|
||||||
|
except BaseException as e:
|
||||||
|
self.print_error("cannot connect at", device.path, str(e))
|
||||||
|
return None
|
||||||
|
|
||||||
def create_client(self, device, handler):
|
def create_client(self, device, handler):
|
||||||
|
if device.product_key[1] == 2:
|
||||||
|
transport = self._try_webusb(device)
|
||||||
|
else:
|
||||||
transport = self._try_hid(device)
|
transport = self._try_hid(device)
|
||||||
|
|
||||||
if not transport:
|
if not transport:
|
||||||
self.print_error("cannot connect to device")
|
self.print_error("cannot connect to device")
|
||||||
return
|
return
|
||||||
|
|
Loading…
Add table
Reference in a new issue