electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit d5f43610ed73cbe58c796d698929c67dbefbd598
parent afae9a097e2bf39280589f3d1a456c5f70adc170
Author: ThomasV <thomasv@electrum.org>
Date:   Tue,  1 Dec 2015 10:00:39 +0100

fix imports in hardware wallets

Diffstat:
Mplugins/keepkey/keepkey.py | 89++-----------------------------------------------------------------------------
Mplugins/keepkey/qt.py | 93++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Mplugins/ledger/ledger.py | 2+-
Mplugins/ledger/qt.py | 4++++
Mplugins/trezor/qt.py | 2+-
5 files changed, 100 insertions(+), 90 deletions(-)

diff --git a/plugins/keepkey/keepkey.py b/plugins/keepkey/keepkey.py @@ -420,7 +420,7 @@ class KeepKeyPlugin(BasePlugin): -class CmdlinePlugin(Plugin): +class CmdlinePlugin(KeepKeyPlugin): @hook def cmdline_load_wallet(self, wallet): @@ -499,92 +499,6 @@ class KeepKeyCmdLineHandler: print_msg(msg) -class KeepKeyQtHandler: - - def __init__(self, win): - self.win = win - self.win.connect(win, SIGNAL('keepkey_done'), self.dialog_stop) - self.win.connect(win, SIGNAL('message_dialog'), self.message_dialog) - self.win.connect(win, SIGNAL('pin_dialog'), self.pin_dialog) - self.win.connect(win, SIGNAL('passphrase_dialog'), self.passphrase_dialog) - self.done = threading.Event() - - def stop(self): - self.win.emit(SIGNAL('keepkey_done')) - - def show_message(self, msg_code, msg, client): - self.messsage_code = msg_code - self.message = msg - self.client = client - self.win.emit(SIGNAL('message_dialog')) - - def get_pin(self, msg): - self.done.clear() - self.message = msg - self.win.emit(SIGNAL('pin_dialog')) - self.done.wait() - return self.response - - def get_passphrase(self, msg): - self.done.clear() - self.message = msg - self.win.emit(SIGNAL('passphrase_dialog')) - self.done.wait() - return self.passphrase - - def pin_dialog(self): - d = QDialog(None) - d.setModal(1) - d.setWindowTitle(_("Enter PIN")) - d.setWindowFlags(d.windowFlags() | QtCore.Qt.WindowStaysOnTopHint) - matrix = PinMatrixWidget() - vbox = QVBoxLayout() - vbox.addWidget(QLabel(self.message)) - vbox.addWidget(matrix) - vbox.addLayout(Buttons(CancelButton(d), OkButton(d))) - d.setLayout(vbox) - if not d.exec_(): - self.response = None - self.response = str(matrix.get_value()) - self.done.set() - - def passphrase_dialog(self): - if type(self.win) is ElectrumWindow: - passphrase = self.win.password_dialog(_("Please enter your KeepKey passphrase")) - self.passphrase = unicodedata.normalize('NFKD', unicode(passphrase)) if passphrase else '' - else: - assert type(self.win) is InstallWizard - from electrum_gui.qt.password_dialog import make_password_dialog, run_password_dialog - d = QDialog() - d.setModal(1) - d.setLayout(make_password_dialog(d, None, self.message, False)) - confirmed, p, passphrase = run_password_dialog(d, None, None) - if not confirmed: - QMessageBox.critical(None, _('Error'), _("Password request canceled"), _('OK')) - self.passphrase = None - else: - self.passphrase = unicodedata.normalize('NFKD', unicode(passphrase)) if passphrase else '' - self.done.set() - - def message_dialog(self): - self.d = QDialog() - self.d.setModal(1) - self.d.setWindowTitle('Please Check KeepKey Device') - self.d.setWindowFlags(self.d.windowFlags() | QtCore.Qt.WindowStaysOnTopHint) - l = QLabel(self.message) - vbox = QVBoxLayout(self.d) - vbox.addWidget(l) - - if self.messsage_code in (3, 8): - vbox.addLayout(Buttons(CancelButton(self.d))) - self.d.connect(self.d, SIGNAL('rejected()'), self.client.cancel) - - self.d.show() - - def dialog_stop(self): - self.d.hide() - - if KEEPKEY: class QtGuiKeepKeyClient(ProtocolMixin, KeepKeyGuiMixin, BaseClient): def call_raw(self, msg): @@ -595,3 +509,4 @@ if KEEPKEY: raise return resp + diff --git a/plugins/keepkey/qt.py b/plugins/keepkey/qt.py @@ -5,7 +5,11 @@ from electrum_gui.qt.main_window import StatusBarButton, ElectrumWindow from electrum_gui.qt.installwizard import InstallWizard from keepkeylib.qt.pinmatrix import PinMatrixWidget -from keepkey import KeepKeyPlugin +from functools import partial + +from keepkey import KeepKeyPlugin, KeepKeyWallet +from electrum.plugins import hook +from electrum.i18n import _ class Plugin(KeepKeyPlugin): @@ -93,3 +97,90 @@ class Plugin(KeepKeyPlugin): layout.addWidget(change_label_button,3,1) d.exec_() + +class KeepKeyQtHandler: + + def __init__(self, win): + self.win = win + self.win.connect(win, SIGNAL('keepkey_done'), self.dialog_stop) + self.win.connect(win, SIGNAL('message_dialog'), self.message_dialog) + self.win.connect(win, SIGNAL('pin_dialog'), self.pin_dialog) + self.win.connect(win, SIGNAL('passphrase_dialog'), self.passphrase_dialog) + self.done = threading.Event() + + def stop(self): + self.win.emit(SIGNAL('keepkey_done')) + + def show_message(self, msg_code, msg, client): + self.messsage_code = msg_code + self.message = msg + self.client = client + self.win.emit(SIGNAL('message_dialog')) + + def get_pin(self, msg): + self.done.clear() + self.message = msg + self.win.emit(SIGNAL('pin_dialog')) + self.done.wait() + return self.response + + def get_passphrase(self, msg): + self.done.clear() + self.message = msg + self.win.emit(SIGNAL('passphrase_dialog')) + self.done.wait() + return self.passphrase + + def pin_dialog(self): + d = QDialog(None) + d.setModal(1) + d.setWindowTitle(_("Enter PIN")) + d.setWindowFlags(d.windowFlags() | QtCore.Qt.WindowStaysOnTopHint) + matrix = PinMatrixWidget() + vbox = QVBoxLayout() + vbox.addWidget(QLabel(self.message)) + vbox.addWidget(matrix) + vbox.addLayout(Buttons(CancelButton(d), OkButton(d))) + d.setLayout(vbox) + if not d.exec_(): + self.response = None + self.response = str(matrix.get_value()) + self.done.set() + + def passphrase_dialog(self): + if type(self.win) is ElectrumWindow: + passphrase = self.win.password_dialog(_("Please enter your KeepKey passphrase")) + self.passphrase = unicodedata.normalize('NFKD', unicode(passphrase)) if passphrase else '' + else: + assert type(self.win) is InstallWizard + from electrum_gui.qt.password_dialog import make_password_dialog, run_password_dialog + d = QDialog() + d.setModal(1) + d.setLayout(make_password_dialog(d, None, self.message, False)) + confirmed, p, passphrase = run_password_dialog(d, None, None) + if not confirmed: + QMessageBox.critical(None, _('Error'), _("Password request canceled"), _('OK')) + self.passphrase = None + else: + self.passphrase = unicodedata.normalize('NFKD', unicode(passphrase)) if passphrase else '' + self.done.set() + + def message_dialog(self): + self.d = QDialog() + self.d.setModal(1) + self.d.setWindowTitle('Please Check KeepKey Device') + self.d.setWindowFlags(self.d.windowFlags() | QtCore.Qt.WindowStaysOnTopHint) + l = QLabel(self.message) + vbox = QVBoxLayout(self.d) + vbox.addWidget(l) + + if self.messsage_code in (3, 8): + vbox.addLayout(Buttons(CancelButton(self.d))) + self.d.connect(self.d, SIGNAL('rejected()'), self.client.cancel) + + self.d.show() + + def dialog_stop(self): + self.d.hide() + + diff --git a/plugins/ledger/ledger.py b/plugins/ledger/ledger.py @@ -496,7 +496,7 @@ class LedgerPlugin(BasePlugin): tx.error = str(e) -class CmdlinePlugin(Plugin): +class CmdlinePlugin(LedgerPlugin): @hook def cmdline_load_wallet(self, wallet): self.wallet = wallet diff --git a/plugins/ledger/qt.py b/plugins/ledger/qt.py @@ -1,6 +1,10 @@ from PyQt4.Qt import QApplication, QMessageBox, QDialog, QInputDialog, QLineEdit, QVBoxLayout, QLabel, QThread, SIGNAL import PyQt4.QtCore as QtCore + from electrum_gui.qt.password_dialog import make_password_dialog, run_password_dialog +from electrum.plugins import BasePlugin, hook + +from ledger import LedgerPlugin class Plugin(LedgerPlugin): diff --git a/plugins/trezor/qt.py b/plugins/trezor/qt.py @@ -12,7 +12,7 @@ import unicodedata from electrum.i18n import _ from electrum.plugins import hook, always_hook, run_hook -from trezor import TrezorPlugin +from trezor import TrezorPlugin, TrezorWallet class TrezorQtHandler: