electrum

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

commit 8598f9ef9c8b012b8bc1aae5ad6a517ab3b44b5b
parent d8c080b87db333aab711b9ba7b242d200d94728b
Author: Neil Booth <kyuupichan@gmail.com>
Date:   Mon, 21 Dec 2015 23:52:48 +0900

Permit sweep of private keys for watch-only wallet

Fixes #1585
Warn user if watching-only.
Introduce new helper class WindowModalDialog and use it in a couple
of places.  This is better than process-modal dialogs for our
multi-window daemon setup.

Diffstat:
Mgui/qt/main_window.py | 15++++++++-------
Mgui/qt/util.py | 8++++++++
2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py @@ -269,7 +269,7 @@ class ElectrumWindow(QMainWindow, PrintError): self.update_account_selector() # update menus self.new_account_menu.setVisible(self.wallet.can_create_accounts()) - self.private_keys_menu.setEnabled(not self.wallet.is_watching_only()) + self.export_menu.setEnabled(not self.wallet.is_watching_only()) self.password_menu.setEnabled(self.wallet.can_change_password()) self.seed_menu.setEnabled(self.wallet.has_seed()) self.mpk_menu.setEnabled(self.wallet.is_deterministic()) @@ -2009,10 +2009,8 @@ class ElectrumWindow(QMainWindow, PrintError): self.show_message(str(e)) return - d = QDialog(self) + d = WindowModalDialog(self, _("Private key")) d.setMinimumSize(600, 200) - d.setModal(1) - d.setWindowTitle(_("Private key")) vbox = QVBoxLayout() vbox.addWidget( QLabel(_("Address") + ': ' + address)) vbox.addWidget( QLabel(_("Private key") + ':')) @@ -2457,12 +2455,11 @@ class ElectrumWindow(QMainWindow, PrintError): def sweep_key_dialog(self): - d = QDialog(self) - d.setWindowTitle(_('Sweep private keys')) + d = WindowModalDialog(self, title=_('Sweep private keys')) d.setMinimumSize(600, 300) vbox = QVBoxLayout(d) - vbox.addWidget(QLabel(_("Enter private keys"))) + vbox.addWidget(QLabel(_("Enter private keys:"))) keys_e = QTextEdit() keys_e.setTabChangesFocus(True) @@ -2493,6 +2490,10 @@ class ElectrumWindow(QMainWindow, PrintError): if not d.exec_(): return + if self.wallet.is_watching_only(): + if not self.question(_("Warning: this wallet is watching only. You will be UNABLE to spend the swept funds directly. Continue only if you have access to the private keys in another way.\n\nAre you SURE you want to sweep?")): + return + fee = self.wallet.fee_per_kb(self.config) tx = Transaction.sweep(get_pk(), self.network, get_address(), fee) if not tx: diff --git a/gui/qt/util.py b/gui/qt/util.py @@ -192,6 +192,14 @@ class CancelButton(QPushButton): QPushButton.__init__(self, label or _("Cancel")) self.clicked.connect(dialog.reject) +class WindowModalDialog(QDialog): + '''Handy wrapper; window modal dialogs are better for our multi-window + daemon model as other wallet windows can still be accessed.''' + def __init__(self, parent, title=None): + QDialog.__init__(self, parent) + self.setWindowModality(Qt.WindowModal) + if title: + self.setWindowTitle(title) def line_dialog(parent, title, label, ok_label, default=None): dialog = QDialog(parent)