Qt: show WIF help in import(x2) and sweep dialogs (#4425)
This commit is contained in:
@@ -25,6 +25,12 @@ MSG_HW_STORAGE_ENCRYPTION = _("Set wallet file encryption.") + '\n'\
|
|||||||
+ _("Your wallet file does not contain secrets, mostly just metadata. ") \
|
+ _("Your wallet file does not contain secrets, mostly just metadata. ") \
|
||||||
+ _("It also contains your master public key that allows watching your addresses.") + '\n\n'\
|
+ _("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.")
|
+ _("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):
|
class CosignWidget(QWidget):
|
||||||
@@ -356,7 +362,7 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
|
|||||||
self.config.remove_from_recently_open(filename)
|
self.config.remove_from_recently_open(filename)
|
||||||
|
|
||||||
def text_input(self, title, message, is_valid, allow_multi=False):
|
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)
|
allow_multi=allow_multi)
|
||||||
self.exec_layout(slayout, title, next_enabled=False)
|
self.exec_layout(slayout, title, next_enabled=False)
|
||||||
return slayout.get_text()
|
return slayout.get_text()
|
||||||
@@ -367,8 +373,14 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
|
|||||||
return slayout.get_seed(), slayout.is_bip39, slayout.is_ext
|
return slayout.get_seed(), slayout.is_bip39, slayout.is_ext
|
||||||
|
|
||||||
@wizard_dialog
|
@wizard_dialog
|
||||||
def add_xpub_dialog(self, title, message, is_valid, run_next, allow_multi=False):
|
def add_xpub_dialog(self, title, message, is_valid, run_next, allow_multi=False, show_wif_help=False):
|
||||||
return self.text_input(title, message, is_valid, allow_multi)
|
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
|
@wizard_dialog
|
||||||
def add_cosigner_dialog(self, run_next, index, is_valid):
|
def add_cosigner_dialog(self, run_next, index, is_valid):
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ from .qrtextedit import ShowQRTextEdit, ScanQRTextEdit
|
|||||||
from .transaction_dialog import show_transaction
|
from .transaction_dialog import show_transaction
|
||||||
from .fee_slider import FeeSlider
|
from .fee_slider import FeeSlider
|
||||||
from .util import *
|
from .util import *
|
||||||
|
from .installwizard import WIF_HELP_TEXT
|
||||||
|
|
||||||
|
|
||||||
class StatusBarButton(QPushButton):
|
class StatusBarButton(QPushButton):
|
||||||
@@ -2497,7 +2498,11 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
|||||||
d.setMinimumSize(600, 300)
|
d.setMinimumSize(600, 300)
|
||||||
|
|
||||||
vbox = QVBoxLayout(d)
|
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 = ScanQRTextEdit(allow_multi=True)
|
||||||
keys_e.setTabChangesFocus(True)
|
keys_e.setTabChangesFocus(True)
|
||||||
@@ -2548,9 +2553,8 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
|||||||
return
|
return
|
||||||
self.warn_if_watching_only()
|
self.warn_if_watching_only()
|
||||||
|
|
||||||
def _do_import(self, title, msg, func):
|
def _do_import(self, title, header_layout, func):
|
||||||
text = text_dialog(self, title, msg + ' :', _('Import'),
|
text = text_dialog(self, title, header_layout, _('Import'), allow_multi=True)
|
||||||
allow_multi=True)
|
|
||||||
if not text:
|
if not text:
|
||||||
return
|
return
|
||||||
bad = []
|
bad = []
|
||||||
@@ -2572,15 +2576,18 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
|||||||
def import_addresses(self):
|
def import_addresses(self):
|
||||||
if not self.wallet.can_import_address():
|
if not self.wallet.can_import_address():
|
||||||
return
|
return
|
||||||
title, msg = _('Import addresses'), _("Enter addresses")
|
title, msg = _('Import addresses'), _("Enter addresses")+':'
|
||||||
self._do_import(title, msg, self.wallet.import_address)
|
self._do_import(title, msg, self.wallet.import_address)
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
def do_import_privkey(self, password):
|
def do_import_privkey(self, password):
|
||||||
if not self.wallet.can_import_privkey():
|
if not self.wallet.can_import_privkey():
|
||||||
return
|
return
|
||||||
title, msg = _('Import private keys'), _("Enter private keys")
|
title = _('Import private keys')
|
||||||
self._do_import(title, msg, lambda x: self.wallet.import_private_key(x, password))
|
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):
|
def update_fiat(self):
|
||||||
b = self.fx and self.fx.is_enabled()
|
b = self.fx and self.fx.is_enabled()
|
||||||
|
|||||||
@@ -178,13 +178,16 @@ class SeedLayout(QVBoxLayout):
|
|||||||
self.seed_e.enable_suggestions()
|
self.seed_e.enable_suggestions()
|
||||||
|
|
||||||
class KeysLayout(QVBoxLayout):
|
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)
|
QVBoxLayout.__init__(self)
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.is_valid = is_valid
|
self.is_valid = is_valid
|
||||||
self.text_e = ScanQRTextEdit(allow_multi=allow_multi)
|
self.text_e = ScanQRTextEdit(allow_multi=allow_multi)
|
||||||
self.text_e.textChanged.connect(self.on_edit)
|
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)
|
self.addWidget(self.text_e)
|
||||||
|
|
||||||
def get_text(self):
|
def get_text(self):
|
||||||
|
|||||||
@@ -128,6 +128,19 @@ class HelpButton(QPushButton):
|
|||||||
def onclick(self):
|
def onclick(self):
|
||||||
QMessageBox.information(self, 'Help', self.help_text)
|
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):
|
class Buttons(QHBoxLayout):
|
||||||
def __init__(self, *buttons):
|
def __init__(self, *buttons):
|
||||||
QHBoxLayout.__init__(self)
|
QHBoxLayout.__init__(self)
|
||||||
@@ -263,13 +276,16 @@ def line_dialog(parent, title, label, ok_label, default=None):
|
|||||||
if dialog.exec_():
|
if dialog.exec_():
|
||||||
return txt.text()
|
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
|
from .qrtextedit import ScanQRTextEdit
|
||||||
dialog = WindowModalDialog(parent, title)
|
dialog = WindowModalDialog(parent, title)
|
||||||
dialog.setMinimumWidth(600)
|
dialog.setMinimumWidth(600)
|
||||||
l = QVBoxLayout()
|
l = QVBoxLayout()
|
||||||
dialog.setLayout(l)
|
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)
|
txt = ScanQRTextEdit(allow_multi=allow_multi)
|
||||||
if default:
|
if default:
|
||||||
txt.setText(default)
|
txt.setText(default)
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ class BaseWizard(object):
|
|||||||
title = _("Import Bitcoin Addresses")
|
title = _("Import Bitcoin Addresses")
|
||||||
message = _("Enter a list of Bitcoin addresses (this will create a watching-only wallet), or a list of private keys.")
|
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,
|
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):
|
def on_import(self, text):
|
||||||
# create a temporary wallet and exploit that modifications
|
# create a temporary wallet and exploit that modifications
|
||||||
|
|||||||
Reference in New Issue
Block a user