generic restore from command line
This commit is contained in:
29
electrum
29
electrum
@@ -136,26 +136,17 @@ def init_cmdline(config):
|
||||
if cmd.name in ['create', 'restore']:
|
||||
if storage.file_exists:
|
||||
sys.exit("Error: Remove the existing wallet first!")
|
||||
if config.get('password') is not None:
|
||||
password = config.get('password')
|
||||
elif cmd.name == 'restore' and config.get('mpk'):
|
||||
password = None
|
||||
else:
|
||||
password = prompt_password("Password (hit return if you do not wish to encrypt your wallet):")
|
||||
|
||||
def password_dialog():
|
||||
return prompt_password("Password (hit return if you do not wish to encrypt your wallet):")
|
||||
|
||||
if cmd.name == 'restore':
|
||||
mpk = config.get('mpk')
|
||||
if mpk:
|
||||
if Wallet.is_old_mpk(mpk):
|
||||
wallet = Wallet.from_old_mpk(mpk, storage)
|
||||
if Wallet.is_xpub(mpk):
|
||||
wallet = Wallet.from_xpub(mpk, storage)
|
||||
else:
|
||||
import getpass
|
||||
seed = getpass.getpass(prompt="seed:", stream=None) if config.get('concealed') else raw_input("seed:")
|
||||
if not Wallet.is_seed(seed):
|
||||
sys.exit("Error: Invalid seed")
|
||||
wallet = Wallet.from_seed(seed, password, storage)
|
||||
import getpass
|
||||
text = getpass.getpass(prompt="seed:", stream=None) if config.get('concealed') else raw_input("seed or key(s):")
|
||||
try:
|
||||
wallet = Wallet.from_text(text, password_dialog, storage)
|
||||
except BaseException as e:
|
||||
sys.exit(str(e))
|
||||
|
||||
if not config.get('offline'):
|
||||
network = Network(config)
|
||||
@@ -163,6 +154,7 @@ def init_cmdline(config):
|
||||
wallet.start_threads(network)
|
||||
print_msg("Recovering wallet...")
|
||||
wallet.restore(lambda x: x)
|
||||
wallet.synchronize()
|
||||
if wallet.is_found():
|
||||
print_msg("Recovery successful")
|
||||
else:
|
||||
@@ -172,6 +164,7 @@ def init_cmdline(config):
|
||||
print_msg("Warning: This wallet was restored offline. It may contain more addresses than displayed.")
|
||||
|
||||
else:
|
||||
password = password_dialog()
|
||||
wallet = Wallet(storage)
|
||||
seed = wallet.make_seed()
|
||||
wallet.add_seed(seed, password)
|
||||
|
||||
Reference in New Issue
Block a user