1
0

hide seed options in a popup dialog. simplify seed_dialog classes

This commit is contained in:
ThomasV
2016-10-12 15:00:10 +02:00
parent f225a26952
commit f8aaa4a50f
2 changed files with 113 additions and 147 deletions

View File

@@ -11,7 +11,7 @@ from electrum.util import UserCancelled
from electrum.base_wizard import BaseWizard
from electrum.i18n import _
from seed_dialog import SeedDisplayLayout, CreateSeedLayout, SeedInputLayout, TextInputLayout
from seed_dialog import SeedLayout, TextInputLayout
from network_dialog import NetworkChoiceLayout
from util import *
from password_dialog import PasswordLayout, PW_NEW
@@ -248,42 +248,10 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
self.set_main_layout(slayout.layout(), title, next_enabled=False)
return slayout.get_text()
def seed_input(self, title, message, is_seed):
slayout = SeedInputLayout(self, message, is_seed)
vbox = QVBoxLayout()
vbox.addLayout(slayout.layout())
if self.opt_ext or self.opt_bip39:
vbox.addStretch(1)
vbox.addWidget(QLabel(_('Options') + ':'))
if self.opt_ext:
cb_pass = QCheckBox(_('Extend this seed with custom words'))
vbox.addWidget(cb_pass)
if self.opt_bip39:
def f(b):
if b:
msg = ' '.join([
'<b>' + _('Warning') + '</b>' + ': ',
_('BIP39 seeds may not be supported in the future.'),
'<br/><br/>',
_('As technology matures, Bitcoin address generation may change.'),
_('However, BIP39 seeds do not include a version number.'),
_('As a result, it is not possible to infer your wallet type from a BIP39 seed.'),
'<br/><br/>',
_('We do not guarantee that BIP39 seeds will be supported in future versions of Electrum.'),
_('We recommend to use seeds generated by Electrum or compatible wallets.'),
])
self.show_warning(msg)
slayout.seed_type_label.setVisible(not b)
slayout.is_seed = (lambda x: bool(x)) if b else is_seed
slayout.on_edit()
cb_bip39 = QCheckBox(_('BIP39 seed'))
cb_bip39.toggled.connect(f)
vbox.addWidget(cb_bip39)
self.set_main_layout(vbox, title, next_enabled=False)
seed = slayout.get_seed()
is_bip39 = cb_bip39.isChecked() if self.opt_bip39 else False
is_ext = cb_pass.isChecked() if self.opt_ext else False
return seed, is_bip39, is_ext
def seed_input(self, title, message, is_seed, options):
slayout = SeedLayout(title=message, is_seed=is_seed, options=options, parent=self)
self.set_main_layout(slayout, title, next_enabled=False)
return slayout.get_seed(), slayout.is_bip39, slayout.is_ext
@wizard_dialog
def add_xpub_dialog(self, title, message, is_valid, run_next):
@@ -302,7 +270,7 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
def restore_seed_dialog(self, run_next, test):
title = _('Enter Seed')
message = _('Please enter your seed phrase in order to restore your wallet.')
return self.seed_input(title, message, test)
return self.seed_input(title, message, test, ['ext', 'bip39'])
@wizard_dialog
def confirm_seed_dialog(self, run_next, test):
@@ -313,22 +281,15 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
_('If you lose your seed, your money will be permanently lost.'),
_('To make sure that you have properly saved your seed, please retype it here.')
])
self.opt_ext = False
self.opt_bip39 = False
seed, is_bip39, is_ext = self.seed_input(title, message, test)
seed, is_bip39, is_ext = self.seed_input(title, message, test, None)
return seed
@wizard_dialog
def show_seed_dialog(self, run_next, seed_text):
vbox = QVBoxLayout()
slayout = CreateSeedLayout(seed_text)
vbox.addLayout(slayout.layout())
vbox.addStretch(1)
vbox.addWidget(QLabel(_('Option') + ':'))
cb_pass = QCheckBox(_('Extend this seed with custom words'))
vbox.addWidget(cb_pass)
self.set_main_layout(vbox)
return cb_pass.isChecked()
title = _("Your wallet generation seed is:")
slayout = SeedLayout(seed=seed_text, title=title, msg=True, options=['ext'])
self.set_main_layout(slayout)
return slayout.is_ext
def pw_layout(self, msg, kind):
playout = PasswordLayout(None, msg, kind, self.next_button)
@@ -425,7 +386,7 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
_("Please share it with your cosigners.")
])
vbox = QVBoxLayout()
layout = SeedDisplayLayout(xpub, title=msg, icon=False)
layout = SeedLayout(xpub, title=msg, icon=False)
vbox.addLayout(layout.layout())
self.set_main_layout(vbox, _('Master Public Key'))
return None