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.
This commit is contained in:
parent
d8c080b87d
commit
8598f9ef9c
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue