Files
pallectrum/plugins/ledger/qt.py

47 lines
1.6 KiB
Python
Raw Normal View History

import threading
from PyQt4.Qt import (QDialog, QInputDialog, QLineEdit,
QVBoxLayout, QLabel, SIGNAL)
import PyQt4.QtCore as QtCore
2015-12-01 10:00:39 +01:00
from electrum.i18n import _
from electrum.plugins import hook
2016-08-18 11:34:37 +02:00
from .ledger import LedgerPlugin, Ledger_KeyStore
from ..hw_wallet.qt import QtHandlerBase
class Plugin(LedgerPlugin):
@hook
def load_wallet(self, wallet, window):
2016-08-18 11:34:37 +02:00
keystore = wallet.get_keystore()
if type(keystore) != self.keystore_class:
return
2016-08-18 11:34:37 +02:00
keystore.handler = BTChipQTHandler(window)
if self.btchip_is_connected(keystore):
if not keystore.check_proper_device():
2015-12-23 20:42:30 +09:00
window.show_error(_("This wallet does not match your Ledger device"))
wallet.force_watching_only = True
else:
2015-12-23 20:42:30 +09:00
window.show_error(_("Ledger device not detected.\nContinuing in watching-only mode."))
wallet.force_watching_only = True
2016-08-18 11:34:37 +02:00
def on_create_wallet(self, keystore, wizard):
assert type(keystore) == self.keystore_class
keystore.handler = BTChipQTHandler(wizard)
keystore.init_xpub()
print keystore.xpub
wizard.create_wallet(keystore, None)
2016-01-30 07:46:19 +01:00
class BTChipQTHandler(QtHandlerBase):
def __init__(self, win):
2016-01-30 07:46:19 +01:00
super(BTChipQTHandler, self).__init__(win, 'Ledger')
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])
2016-08-18 11:34:37 +02:00
self.done.set()