Browse Source

wizard: make 'stack' private

sqlite_db
SomberNight 6 years ago
parent
commit
9013f6d59e
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 15
      electrum/base_wizard.py
  2. 2
      electrum/gui/qt/installwizard.py
  3. 5
      electrum/plugins/trustedcoin/qt.py
  4. 9
      electrum/plugins/trustedcoin/trustedcoin.py

15
electrum/base_wizard.py

@ -64,7 +64,7 @@ class BaseWizard(object):
self.plugins = plugins
self.storage = storage
self.wallet = None # type: Abstract_Wallet
self.stack = []
self._stack = []
self.plugin = None
self.keystores = []
self.is_kivy = config.get('gui') == 'kivy'
@ -76,7 +76,7 @@ class BaseWizard(object):
def run(self, *args):
action = args[0]
args = args[1:]
self.stack.append((action, args))
self._stack.append((action, args))
if not action:
return
if type(action) is tuple:
@ -91,15 +91,18 @@ class BaseWizard(object):
raise Exception("unknown action", action)
def can_go_back(self):
return len(self.stack)>1
return len(self._stack) > 1
def go_back(self):
if not self.can_go_back():
return
self.stack.pop()
action, args = self.stack.pop()
self._stack.pop()
action, args = self._stack.pop()
self.run(action, *args)
def reset_stack(self):
self._stack = []
def new(self):
name = os.path.basename(self.storage.path)
title = _("Create") + ' ' + name
@ -476,7 +479,7 @@ class BaseWizard(object):
self.keystores.append(k)
if len(self.keystores) == 1:
xpub = k.get_master_public_key()
self.stack = []
self.reset_stack()
self.run('show_xpub_and_add_cosigners', xpub)
elif len(self.keystores) < self.n:
self.run('choose_keystore')

2
electrum/gui/qt/installwizard.py

@ -272,7 +272,7 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
None, _('Error'),
_('Failed to decrypt using this hardware device.') + '\n' +
_('If you use a passphrase, make sure it is correct.'))
self.stack = []
self.reset_stack()
return self.run_and_get_wallet(get_wallet_from_daemon)
except BaseException as e:
traceback.print_exc(file=sys.stdout)

5
electrum/plugins/trustedcoin/qt.py

@ -36,6 +36,7 @@ from electrum.gui.qt.util import *
from electrum.gui.qt.qrcodewidget import QRCodeWidget
from electrum.gui.qt.amountedit import AmountEdit
from electrum.gui.qt.main_window import StatusBarButton
from electrum.gui.qt.installwizard import InstallWizard
from electrum.i18n import _
from electrum.plugin import hook
from electrum.util import PrintError, is_valid_email
@ -195,7 +196,7 @@ class Plugin(TrustedCoinPlugin):
vbox.addLayout(Buttons(CloseButton(d)))
d.exec_()
def go_online_dialog(self, wizard):
def go_online_dialog(self, wizard: InstallWizard):
msg = [
_("Your wallet file is: {}.").format(os.path.abspath(wizard.storage.path)),
_("You need to be online in order to complete the creation of "
@ -206,7 +207,7 @@ class Plugin(TrustedCoinPlugin):
_('If you are online, click on "{}" to continue.').format(_('Next'))
]
msg = '\n\n'.join(msg)
wizard.stack = []
wizard.reset_stack()
wizard.confirm_dialog(title='', message=msg, run_next = lambda x: wizard.run('accept_terms_of_use'))
def accept_terms_of_use(self, window):

9
electrum/plugins/trustedcoin/trustedcoin.py

@ -48,6 +48,7 @@ from electrum.plugin import BasePlugin, hook
from electrum.util import NotEnoughFunds, UserFacingException
from electrum.storage import STO_EV_USER_PW
from electrum.network import Network
from electrum.base_wizard import BaseWizard
def get_signing_xpub(xtype):
if not constants.net.TESTNET:
@ -491,9 +492,9 @@ class TrustedCoinPlugin(BasePlugin):
def do_clear(self, window):
window.wallet.is_billing = False
def show_disclaimer(self, wizard):
def show_disclaimer(self, wizard: BaseWizard):
wizard.set_icon('trustedcoin-wizard.png')
wizard.stack = []
wizard.reset_stack()
wizard.confirm_dialog(title='Disclaimer', message='\n\n'.join(self.disclaimer_msg), run_next = lambda x: wizard.run('choose_seed'))
def choose_seed(self, wizard):
@ -580,9 +581,9 @@ class TrustedCoinPlugin(BasePlugin):
f = lambda x: self.restore_choice(wizard, seed, x)
wizard.passphrase_dialog(run_next=f) if is_ext else f('')
def restore_choice(self, wizard, seed, passphrase):
def restore_choice(self, wizard: BaseWizard, seed, passphrase):
wizard.set_icon('trustedcoin-wizard.png')
wizard.stack = []
wizard.reset_stack()
title = _('Restore 2FA wallet')
msg = ' '.join([
'You are going to restore a wallet protected with two-factor authentication.',

Loading…
Cancel
Save