Files
purple-electrumwallet/plugins/ledger/qt.py
T

46 lines
1.5 KiB
Python
Raw Normal View History

2016-01-11 15:08:12 +09:00
import threading
2016-01-11 14:38:45 +09:00
from PyQt4.Qt import (QDialog, QInputDialog, QLineEdit,
QVBoxLayout, QLabel, SIGNAL)
2015-11-23 19:38:48 +01:00
import PyQt4.QtCore as QtCore
2015-12-01 10:00:39 +01:00
2016-01-11 15:08:12 +09:00
from electrum.i18n import _
from electrum.plugins import hook
from .ledger import LedgerPlugin, BTChipWallet
2016-01-30 13:48:52 +01:00
from ..hw_wallet.qt import QtHandlerBase
2015-11-23 19:38:48 +01:00
class Plugin(LedgerPlugin):
@hook
def load_wallet(self, wallet, window):
2015-12-30 17:03:26 +09:00
if type(wallet) != BTChipWallet:
return
2016-01-11 14:38:45 +09:00
wallet.handler = BTChipQTHandler(window)
2015-12-30 17:03:26 +09:00
if self.btchip_is_connected(wallet):
if not wallet.check_proper_device():
2015-12-23 20:42:30 +09:00
window.show_error(_("This wallet does not match your Ledger device"))
2015-12-30 17:03:26 +09:00
wallet.force_watching_only = True
2015-11-23 19:38:48 +01:00
else:
2015-12-23 20:42:30 +09:00
window.show_error(_("Ledger device not detected.\nContinuing in watching-only mode."))
2015-12-30 17:03:26 +09:00
wallet.force_watching_only = True
2015-11-23 19:38:48 +01:00
def on_create_wallet(self, wallet, wizard):
assert type(wallet) == self.wallet_class
2016-01-11 14:38:45 +09:00
wallet.handler = BTChipQTHandler(wizard)
# self.select_device(wallet)
wallet.create_hd_account(None)
2015-11-23 19:38:48 +01:00
2016-01-30 07:46:19 +01:00
class BTChipQTHandler(QtHandlerBase):
2015-11-23 19:38:48 +01:00
def __init__(self, win):
2016-01-30 07:46:19 +01:00
super(BTChipQTHandler, self).__init__(win, 'Ledger')
2015-11-23 19:38:48 +01:00
2016-01-30 08:11:41 +01:00
def word_dialog(self, msg):
response = QInputDialog.getText(self.top_level_window(), "Ledger Wallet Authentication", msg, QLineEdit.Password)
if not response[1]:
self.word = None
else:
self.word = str(response[0])
self.done.set()