electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 2f6e2ebcd2c098e69ca4053cce624e22c9f901b1
parent 6178f5a28f16a4dac052313139e0d9c0f9fd1c4e
Author: ThomasV <thomasv@electrum.org>
Date:   Wed, 13 Jan 2016 14:30:09 +0100

test if wizard is needed in daemon

Diffstat:
Mlib/daemon.py | 12+++++++++---
Mlib/wizard.py | 30+++++++++---------------------
2 files changed, 18 insertions(+), 24 deletions(-)

diff --git a/lib/daemon.py b/lib/daemon.py @@ -125,11 +125,17 @@ class Daemon(DaemonThread): if path in self.wallets: wallet = self.wallets[path] else: + storage = WalletStorage(path) if get_wizard: - wallet = WizardBase.open_wallet(self.network, path, - self.config, get_wizard) + if storage.file_exists: + wallet = Wallet(storage) + action = wallet.get_action() + else: + action = 'new' + if action: + wizard = get_wizard() + wallet = wizard.run(self.network, storage) else: - storage = WalletStorage(path) wallet = Wallet(storage) wallet.start_threads(self.network) if wallet: diff --git a/lib/wizard.py b/lib/wizard.py @@ -123,27 +123,19 @@ class WizardBase(PrintError): """Called when the wizard is done.""" pass - @classmethod - def open_wallet(self, network, filename, config, create_wizard): + def run(self, network, storage): '''The main entry point of the wizard. Open a wallet from the given filename. If the file doesn't exist launch the GUI-specific install wizard proper, created by calling create_wizard().''' - storage = WalletStorage(filename) need_sync = False is_restore = False - self.my_wizard = None - - def wizard(): - if self.my_wizard is None: - self.my_wizard = create_wizard() - return self.my_wizard if storage.file_exists: wallet = Wallet(storage) if wallet.imported_keys: - wizard().update_wallet_format(wallet) + self.update_wallet_format(wallet) else: - cr, wallet = wizard().create_or_restore(storage) + cr, wallet = self.create_or_restore(storage) if not wallet: return need_sync = True @@ -154,30 +146,26 @@ class WizardBase(PrintError): if not action: break need_sync = True - wizard().run_wallet_action(wallet, action) + self.run_wallet_action(wallet, action) # Save the wallet after each action wallet.storage.write() if network: # Show network dialog if config does not exist - if config.get('auto_connect') is None: - wizard().choose_server(network) + if self.config.get('auto_connect') is None: + self.choose_server(network) else: - wizard().show_warning(_('You are offline')) + self.show_warning(_('You are offline')) if need_sync: - wizard().create_addresses(wallet) + self.create_addresses(wallet) # start wallet threads if network: wallet.start_threads(network) if is_restore: - wizard().show_restore(wallet, network) - - if self.my_wizard: - self.my_wizard.finished() - self.my_wizard = None + self.show_restore(wallet, network) return wallet