2015-12-25 23:25:10 -08:00
|
|
|
from electrum.wallet import BIP32_Hardware_Wallet
|
2015-12-26 02:42:57 -08:00
|
|
|
|
2015-12-26 01:48:07 -08:00
|
|
|
from plugins.trezor.gui_mixin import GuiMixin
|
2015-12-26 02:42:57 -08:00
|
|
|
from plugins.trezor.plugin_generic import TrezorCompatiblePlugin
|
2015-08-10 23:27:42 -07:00
|
|
|
|
|
|
|
try:
|
|
|
|
from keepkeylib.client import proto, BaseClient, ProtocolMixin
|
|
|
|
from keepkeylib.transport import ConnectionError
|
|
|
|
from keepkeylib.transport_hid import HidTransport
|
|
|
|
KEEPKEY = True
|
|
|
|
except ImportError:
|
|
|
|
KEEPKEY = False
|
|
|
|
|
|
|
|
|
2015-12-25 23:25:10 -08:00
|
|
|
class KeepKeyWallet(BIP32_Hardware_Wallet):
|
2015-11-23 05:15:25 -08:00
|
|
|
wallet_type = 'keepkey'
|
|
|
|
root_derivation = "m/44'/0'"
|
2015-12-25 23:25:10 -08:00
|
|
|
device = 'KeepKey'
|
2015-11-23 05:15:25 -08:00
|
|
|
|
|
|
|
|
2015-12-26 02:42:57 -08:00
|
|
|
class KeepKeyPlugin(TrezorCompatiblePlugin):
|
|
|
|
wallet_type = 'keepkey'
|
|
|
|
import keepkeylib.ckd_public as ckd_public
|
|
|
|
from keepkeylib.client import types
|
2015-08-10 23:27:42 -07:00
|
|
|
|
2015-12-26 02:42:57 -08:00
|
|
|
@staticmethod
|
|
|
|
def libraries_available():
|
|
|
|
return KEEPKEY
|
2015-08-10 23:27:42 -07:00
|
|
|
|
|
|
|
def constructor(self, s):
|
|
|
|
return KeepKeyWallet(s)
|
|
|
|
|
|
|
|
def get_client(self):
|
|
|
|
if not KEEPKEY:
|
|
|
|
give_error('please install github.com/keepkey/python-keepkey')
|
|
|
|
|
|
|
|
if not self.client or self.client.bad:
|
|
|
|
d = HidTransport.enumerate()
|
|
|
|
if not d:
|
|
|
|
give_error('Could not connect to your KeepKey. Please verify the cable is connected and that no other app is using it.')
|
|
|
|
self.transport = HidTransport(d[0])
|
|
|
|
self.client = QtGuiKeepKeyClient(self.transport)
|
|
|
|
self.client.handler = self.handler
|
|
|
|
self.client.set_tx_api(self)
|
|
|
|
self.client.bad = False
|
|
|
|
if not self.atleast_version(1, 0, 0):
|
|
|
|
self.client = None
|
|
|
|
give_error('Outdated KeepKey firmware. Please update the firmware from https://www.keepkey.com')
|
|
|
|
return self.client
|
|
|
|
|
|
|
|
|
|
|
|
if KEEPKEY:
|
2015-12-26 01:48:07 -08:00
|
|
|
class QtGuiKeepKeyClient(ProtocolMixin, GuiMixin, BaseClient):
|
|
|
|
protocol = proto
|
|
|
|
device = 'KeepKey'
|
|
|
|
|
2015-08-10 23:27:42 -07:00
|
|
|
def call_raw(self, msg):
|
|
|
|
try:
|
|
|
|
resp = BaseClient.call_raw(self, msg)
|
|
|
|
except ConnectionError:
|
|
|
|
self.bad = True
|
|
|
|
raise
|
2015-08-30 05:18:10 -07:00
|
|
|
|
2015-08-10 23:27:42 -07:00
|
|
|
return resp
|