This commit is contained in:
ThomasV
2015-10-28 10:36:44 +01:00
parent 94ac0db91f
commit 052d8b236e
4 changed files with 40 additions and 55 deletions

View File

@@ -142,26 +142,12 @@ def init_cmdline(config):
if cmd.name == 'restore':
text = config.get('text')
password = password_dialog() if Wallet.is_seed(text) or Wallet.is_xprv(text) or Wallet.is_private_key(text) else None
try:
wallet = Wallet.from_text(text, password_dialog, storage)
wallet = Wallet.from_text(text, password, storage)
except BaseException as e:
sys.exit(str(e))
if not config.get('offline'):
network = Network(config)
network.start()
wallet.start_threads(network)
print_msg("Recovering wallet...")
wallet.restore(lambda x: x)
wallet.synchronize()
if wallet.is_found():
print_msg("Recovery successful")
else:
print_msg("Warning: Found no history for this wallet")
else:
wallet.synchronize()
print_msg("Warning: This wallet was restored offline. It may contain more addresses than displayed.")
wallet.synchronize()
else:
password = password_dialog()
wallet = Wallet(storage)
@@ -174,8 +160,6 @@ def init_cmdline(config):
print_msg("Please keep it in a safe place; if you lose it, you will not be able to restore your wallet.")
print_msg("Wallet saved in '%s'" % wallet.storage.path)
# terminate
sys.exit(0)
if cmd.name not in ['create', 'restore'] and cmd.requires_wallet and not storage.file_exists:
print_msg("Error: Wallet file not found.")
@@ -248,6 +232,9 @@ def run_command(config, network, password):
storage = WalletStorage(config.get_wallet_path())
# create wallet instance
wallet = Wallet(storage) if cmd.requires_wallet else None
# start threads
if network:
wallet.start_threads(network)
# arguments passed to function
args = map(lambda x: config.get(x), cmd.params)
# decode json arguments
@@ -264,10 +251,9 @@ def run_command(config, network, password):
cmd_runner.password = password
func = getattr(cmd_runner, cmd.name)
result = func(*args)
# stop threads
if wallet:
wallet.stop_threads()
return result