2016-07-01 23:58:56 -07:00
|
|
|
from .plugin import TrezorCompatiblePlugin, TrezorCompatibleKeyStore
|
2014-07-10 12:44:28 -07:00
|
|
|
|
2015-03-05 08:09:39 -08:00
|
|
|
|
2016-07-01 23:58:56 -07:00
|
|
|
class TrezorKeyStore(TrezorCompatibleKeyStore):
|
2016-08-21 13:15:17 -07:00
|
|
|
hw_type = 'trezor'
|
2016-01-29 05:58:51 -08:00
|
|
|
device = 'TREZOR'
|
2015-11-23 05:15:25 -08:00
|
|
|
|
2015-12-26 02:42:57 -08:00
|
|
|
class TrezorPlugin(TrezorCompatiblePlugin):
|
2017-12-02 09:34:04 -08:00
|
|
|
firmware_URL = 'https://wallet.trezor.io'
|
2015-12-26 20:56:50 -08:00
|
|
|
libraries_URL = 'https://github.com/trezor/python-trezor'
|
2017-12-02 09:34:04 -08:00
|
|
|
minimum_firmware = (1, 5, 2)
|
2016-07-01 23:58:56 -07:00
|
|
|
keystore_class = TrezorKeyStore
|
2016-08-15 03:28:31 -07:00
|
|
|
|
|
|
|
def __init__(self, *args):
|
|
|
|
try:
|
2017-03-15 04:13:20 -07:00
|
|
|
from . import client
|
2016-08-15 03:28:31 -07:00
|
|
|
import trezorlib
|
|
|
|
import trezorlib.ckd_public
|
2017-12-29 11:31:03 -08:00
|
|
|
import trezorlib.messages
|
2018-02-06 10:11:14 -08:00
|
|
|
import trezorlib.device
|
2016-08-15 03:28:31 -07:00
|
|
|
self.client_class = client.TrezorClient
|
|
|
|
self.ckd_public = trezorlib.ckd_public
|
2017-12-29 11:31:03 -08:00
|
|
|
self.types = trezorlib.messages
|
2018-02-06 10:11:14 -08:00
|
|
|
self.DEVICE_IDS = ('TREZOR',)
|
2016-08-15 03:28:31 -07:00
|
|
|
self.libraries_available = True
|
|
|
|
except ImportError:
|
|
|
|
self.libraries_available = False
|
|
|
|
TrezorCompatiblePlugin.__init__(self, *args)
|
|
|
|
|
2018-02-06 10:11:14 -08:00
|
|
|
def enumerate(self):
|
|
|
|
from trezorlib.device import TrezorDevice
|
|
|
|
from electrum.plugins import Device
|
|
|
|
return [Device(str(d), -1, str(d), 'TREZOR', 0) for d in TrezorDevice.enumerate()]
|
2016-08-15 03:28:31 -07:00
|
|
|
|
2018-02-06 10:11:14 -08:00
|
|
|
def transport(self, device):
|
|
|
|
from trezorlib.device import TrezorDevice
|
|
|
|
return TrezorDevice.find_by_path(device.path)
|