commit 7797af6ffa1f584377bbc16e1aee4736f610508a
parent ecf6ace975a2393696c43df6d00f46e6387fddcc
Author: ghost43 <somber.night@protonmail.com>
Date: Wed, 20 Jun 2018 15:58:37 +0200
Qt: show WIF help in import(x2) and sweep dialogs (#4425)
Diffstat:
5 files changed, 53 insertions(+), 15 deletions(-)
diff --git a/gui/qt/installwizard.py b/gui/qt/installwizard.py
@@ -25,6 +25,12 @@ MSG_HW_STORAGE_ENCRYPTION = _("Set wallet file encryption.") + '\n'\
+ _("Your wallet file does not contain secrets, mostly just metadata. ") \
+ _("It also contains your master public key that allows watching your addresses.") + '\n\n'\
+ _("Note: If you enable this setting, you will need your hardware device to open your wallet.")
+WIF_HELP_TEXT = (_('WIF keys are typed in Electrum, based on script type.') + '\n\n' +
+ _('A few examples') + ':\n' +
+ 'p2pkh:KxZcY47uGp9a... \t\t-> 1DckmggQM...\n' +
+ 'p2wpkh-p2sh:KxZcY47uGp9a... \t-> 3NhNeZQXF...\n' +
+ 'p2wpkh:KxZcY47uGp9a... \t\t-> bc1q3fjfk...')
+# note: full key is KxZcY47uGp9aVQAb6VVvuBs8SwHKgkSR2DbZUzjDzXf2N2GPhG9n
class CosignWidget(QWidget):
@@ -356,7 +362,7 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
self.config.remove_from_recently_open(filename)
def text_input(self, title, message, is_valid, allow_multi=False):
- slayout = KeysLayout(parent=self, title=message, is_valid=is_valid,
+ slayout = KeysLayout(parent=self, header_layout=message, is_valid=is_valid,
allow_multi=allow_multi)
self.exec_layout(slayout, title, next_enabled=False)
return slayout.get_text()
@@ -367,8 +373,14 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
return slayout.get_seed(), slayout.is_bip39, slayout.is_ext
@wizard_dialog
- def add_xpub_dialog(self, title, message, is_valid, run_next, allow_multi=False):
- return self.text_input(title, message, is_valid, allow_multi)
+ def add_xpub_dialog(self, title, message, is_valid, run_next, allow_multi=False, show_wif_help=False):
+ header_layout = QHBoxLayout()
+ label = WWLabel(message)
+ label.setMinimumWidth(400)
+ header_layout.addWidget(label)
+ if show_wif_help:
+ header_layout.addWidget(InfoButton(WIF_HELP_TEXT), alignment=Qt.AlignRight)
+ return self.text_input(title, header_layout, is_valid, allow_multi)
@wizard_dialog
def add_cosigner_dialog(self, run_next, index, is_valid):
diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py
@@ -61,6 +61,7 @@ from .qrtextedit import ShowQRTextEdit, ScanQRTextEdit
from .transaction_dialog import show_transaction
from .fee_slider import FeeSlider
from .util import *
+from .installwizard import WIF_HELP_TEXT
class StatusBarButton(QPushButton):
@@ -2497,7 +2498,11 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
d.setMinimumSize(600, 300)
vbox = QVBoxLayout(d)
- vbox.addWidget(QLabel(_("Enter private keys:")))
+
+ hbox_top = QHBoxLayout()
+ hbox_top.addWidget(QLabel(_("Enter private keys:")))
+ hbox_top.addWidget(InfoButton(WIF_HELP_TEXT), alignment=Qt.AlignRight)
+ vbox.addLayout(hbox_top)
keys_e = ScanQRTextEdit(allow_multi=True)
keys_e.setTabChangesFocus(True)
@@ -2548,9 +2553,8 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
return
self.warn_if_watching_only()
- def _do_import(self, title, msg, func):
- text = text_dialog(self, title, msg + ' :', _('Import'),
- allow_multi=True)
+ def _do_import(self, title, header_layout, func):
+ text = text_dialog(self, title, header_layout, _('Import'), allow_multi=True)
if not text:
return
bad = []
@@ -2572,15 +2576,18 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
def import_addresses(self):
if not self.wallet.can_import_address():
return
- title, msg = _('Import addresses'), _("Enter addresses")
+ title, msg = _('Import addresses'), _("Enter addresses")+':'
self._do_import(title, msg, self.wallet.import_address)
@protected
def do_import_privkey(self, password):
if not self.wallet.can_import_privkey():
return
- title, msg = _('Import private keys'), _("Enter private keys")
- self._do_import(title, msg, lambda x: self.wallet.import_private_key(x, password))
+ title = _('Import private keys')
+ header_layout = QHBoxLayout()
+ header_layout.addWidget(QLabel(_("Enter private keys")+':'))
+ header_layout.addWidget(InfoButton(WIF_HELP_TEXT), alignment=Qt.AlignRight)
+ self._do_import(title, header_layout, lambda x: self.wallet.import_private_key(x, password))
def update_fiat(self):
b = self.fx and self.fx.is_enabled()
diff --git a/gui/qt/seed_dialog.py b/gui/qt/seed_dialog.py
@@ -178,13 +178,16 @@ class SeedLayout(QVBoxLayout):
self.seed_e.enable_suggestions()
class KeysLayout(QVBoxLayout):
- def __init__(self, parent=None, title=None, is_valid=None, allow_multi=False):
+ def __init__(self, parent=None, header_layout=None, is_valid=None, allow_multi=False):
QVBoxLayout.__init__(self)
self.parent = parent
self.is_valid = is_valid
self.text_e = ScanQRTextEdit(allow_multi=allow_multi)
self.text_e.textChanged.connect(self.on_edit)
- self.addWidget(WWLabel(title))
+ if isinstance(header_layout, str):
+ self.addWidget(WWLabel(header_layout))
+ else:
+ self.addLayout(header_layout)
self.addWidget(self.text_e)
def get_text(self):
diff --git a/gui/qt/util.py b/gui/qt/util.py
@@ -128,6 +128,19 @@ class HelpButton(QPushButton):
def onclick(self):
QMessageBox.information(self, 'Help', self.help_text)
+
+class InfoButton(QPushButton):
+ def __init__(self, text):
+ QPushButton.__init__(self, 'Info')
+ self.help_text = text
+ self.setFocusPolicy(Qt.NoFocus)
+ self.setFixedWidth(60)
+ self.clicked.connect(self.onclick)
+
+ def onclick(self):
+ QMessageBox.information(self, 'Info', self.help_text)
+
+
class Buttons(QHBoxLayout):
def __init__(self, *buttons):
QHBoxLayout.__init__(self)
@@ -263,13 +276,16 @@ def line_dialog(parent, title, label, ok_label, default=None):
if dialog.exec_():
return txt.text()
-def text_dialog(parent, title, label, ok_label, default=None, allow_multi=False):
+def text_dialog(parent, title, header_layout, ok_label, default=None, allow_multi=False):
from .qrtextedit import ScanQRTextEdit
dialog = WindowModalDialog(parent, title)
dialog.setMinimumWidth(600)
l = QVBoxLayout()
dialog.setLayout(l)
- l.addWidget(QLabel(label))
+ if isinstance(header_layout, str):
+ l.addWidget(QLabel(header_layout))
+ else:
+ l.addLayout(header_layout)
txt = ScanQRTextEdit(allow_multi=allow_multi)
if default:
txt.setText(default)
diff --git a/lib/base_wizard.py b/lib/base_wizard.py
@@ -166,7 +166,7 @@ class BaseWizard(object):
title = _("Import Bitcoin Addresses")
message = _("Enter a list of Bitcoin addresses (this will create a watching-only wallet), or a list of private keys.")
self.add_xpub_dialog(title=title, message=message, run_next=self.on_import,
- is_valid=v, allow_multi=True)
+ is_valid=v, allow_multi=True, show_wif_help=True)
def on_import(self, text):
# create a temporary wallet and exploit that modifications