Put open_wallet back as class method.
This commit is contained in:
@@ -23,6 +23,7 @@ from jsonrpclib.SimpleJSONRPCServer import SimpleJSONRPCServer, SimpleJSONRPCReq
|
||||
|
||||
from util import json_decode, DaemonThread
|
||||
from wallet import WalletStorage, Wallet
|
||||
from wizard import WizardBase
|
||||
from commands import known_commands, Commands
|
||||
from simple_config import SimpleConfig
|
||||
|
||||
@@ -125,7 +126,8 @@ class Daemon(DaemonThread):
|
||||
wallet = self.wallets[path]
|
||||
else:
|
||||
if get_wizard:
|
||||
wallet = self.open_wallet_with_wizard(self.network, path, get_wizard)
|
||||
wallet = WizardBase.open_wallet(self.network, path,
|
||||
self.config, get_wizard)
|
||||
else:
|
||||
storage = WalletStorage(path)
|
||||
wallet = Wallet(storage)
|
||||
@@ -134,57 +136,6 @@ class Daemon(DaemonThread):
|
||||
self.wallets[path] = wallet
|
||||
return wallet
|
||||
|
||||
def open_wallet_with_wizard(self, network, filename, get_wizard):
|
||||
'''Instantiate wizard only if needed'''
|
||||
storage = WalletStorage(filename)
|
||||
need_sync = False
|
||||
is_restore = False
|
||||
self.wizard = None
|
||||
|
||||
def wizard():
|
||||
if self.wizard is None:
|
||||
self.wizard = get_wizard()
|
||||
return self.wizard
|
||||
|
||||
if storage.file_exists:
|
||||
wallet = Wallet(storage)
|
||||
#self.update_wallet_format(wallet)
|
||||
else:
|
||||
cr, wallet = wizard().create_or_restore(storage)
|
||||
if not wallet:
|
||||
return
|
||||
need_sync = True
|
||||
is_restore = (cr == 'restore')
|
||||
|
||||
while True:
|
||||
action = wallet.get_action()
|
||||
if not action:
|
||||
break
|
||||
need_sync = True
|
||||
wizard().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 self.config.get('server') is None:
|
||||
wizard().choose_server(network)
|
||||
else:
|
||||
wizard().show_warning(_('You are offline'))
|
||||
|
||||
if need_sync:
|
||||
wizard().create_addresses(wallet)
|
||||
|
||||
# start wallet threads
|
||||
if network:
|
||||
wallet.start_threads(network)
|
||||
|
||||
if is_restore:
|
||||
wizard().show_restore(wallet, network)
|
||||
|
||||
return wallet
|
||||
|
||||
|
||||
def run_cmdline(self, config_options):
|
||||
config = SimpleConfig(config_options)
|
||||
cmdname = config.get('cmd')
|
||||
|
||||
Reference in New Issue
Block a user