wizard: small tweaks, fix show_restore

This commit is contained in:
ThomasV 2016-01-09 10:35:10 +01:00
parent 2f1d6b2379
commit 9ad4d63ad1
2 changed files with 27 additions and 21 deletions

View File

@ -131,22 +131,24 @@ class InstallWizard(WindowModalDialog, WizardBase):
return self.pw_dialog(msg or MSG_ENTER_PASSWORD, PasswordDialog.PW_NEW)
def choose_server(self, network):
# Show network dialog if config does not exist
if self.config.get('server') is None:
self.network_dialog(network)
self.network_dialog(network)
def show_restore(self, wallet, network, action):
def on_finished(b):
if action == 'restore':
if network:
if wallet.is_found():
msg = _("Recovery successful")
else:
msg = _("No transactions found for this seed")
def show_restore(self, wallet, network):
if network:
def task():
wallet.wait_until_synchronized()
if wallet.is_found():
msg = _("Recovery successful")
else:
msg = _("This wallet was restored offline. It may "
"contain more addresses than displayed.")
self.show_message(msg)
msg = _("No transactions found for this seed")
self.emit(QtCore.SIGNAL('synchronized'), msg)
self.connect(self, QtCore.SIGNAL('synchronized'), self.show_message)
t = threading.Thread(target = task)
t.start()
else:
msg = _("This wallet was restored offline. It may "
"contain more addresses than displayed.")
self.show_message(msg)
def create_addresses(self, wallet):
def task():

View File

@ -115,7 +115,7 @@ class WizardBase(PrintError):
"""Choose a server if one is not set in the config anyway."""
raise NotImplementedError
def show_restore(self, wallet, network, action):
def show_restore(self, wallet, network):
"""Show restore result"""
pass
@ -124,17 +124,19 @@ class WizardBase(PrintError):
filename. If the file doesn't exist launch the GUI-specific
install wizard proper.'''
storage = WalletStorage(filename)
need_sync = False
is_restore = False
if storage.file_exists:
wallet = Wallet(storage)
self.update_wallet_format(wallet)
task = None
else:
cr, wallet = self.create_or_restore(storage)
if not wallet:
return
task = lambda: self.show_restore(wallet, network, cr)
need_sync = True
is_restore = (cr == 'restore')
need_sync = False
while True:
action = wallet.get_action()
if not action:
@ -145,7 +147,9 @@ class WizardBase(PrintError):
wallet.storage.write()
if network:
self.choose_server(network)
# Show network dialog if config does not exist
if self.config.get('server') is None:
self.choose_server(network)
else:
self.show_warning(_('You are offline'))
@ -156,8 +160,8 @@ class WizardBase(PrintError):
if network:
wallet.start_threads(network)
if task:
task()
if is_restore:
self.show_restore(wallet, network)
return wallet