command line: Require 'text' argument for 'restore'. Replace 'concealed' option with ':' magic word

This commit is contained in:
ThomasV 2015-10-28 09:33:35 +01:00
parent 65f20895df
commit 94ac0db91f
2 changed files with 9 additions and 8 deletions

View file

@ -87,7 +87,7 @@ from electrum.commands import get_parser, known_commands, Commands, config_varia
# get password routine # get password routine
def prompt_password(prompt, confirm=True): def prompt_password(prompt, confirm=True):
import getpass import getpass
password = getpass.getpass(prompt) password = getpass.getpass(prompt, stream=None)
if password and confirm: if password and confirm:
password2 = getpass.getpass("Confirm: ") password2 = getpass.getpass("Confirm: ")
if password != password2: if password != password2:
@ -141,8 +141,7 @@ def init_cmdline(config):
return prompt_password("Password (hit return if you do not wish to encrypt your wallet):") return prompt_password("Password (hit return if you do not wish to encrypt your wallet):")
if cmd.name == 'restore': if cmd.name == 'restore':
import getpass text = config.get('text')
text = getpass.getpass(prompt="seed:", stream=None) if config.get('concealed') else raw_input("seed or key(s):")
try: try:
wallet = Wallet.from_text(text, password_dialog, storage) wallet = Wallet.from_text(text, password_dialog, storage)
except BaseException as e: except BaseException as e:
@ -425,6 +424,8 @@ if __name__ == '__main__':
else: else:
raise BaseException('Cannot get argument from stdin') raise BaseException('Cannot get argument from stdin')
elif arg == '?': elif arg == '?':
sys.argv[i] = raw_input("Enter argument:")
elif arg == ':':
sys.argv[i] = prompt_password('Enter argument (will not echo):', False) sys.argv[i] = prompt_password('Enter argument (will not echo):', False)
# parse command line # parse command line

View file

@ -103,10 +103,11 @@ class Commands:
"""Create a new wallet""" """Create a new wallet"""
@command('') @command('')
def restore(self, concealed=False): def restore(self, text):
"""Restore a wallet. A wallet can be restored from a seed phrase, a """Restore a wallet from text. Text can be a seed phrase, a master
master public key, a master private key, a list of bitcoin addresses public key, a master private key, a list of bitcoin addresses
or bitcoin private keys.""" or bitcoin private keys. If you want to be prompted for your
seed, type '?' or ':' (concealed) """
@command('w') @command('w')
def deseed(self): def deseed(self):
@ -615,7 +616,6 @@ param_descriptions = {
command_options = { command_options = {
'password': ("-W", "--password", "Password"), 'password': ("-W", "--password", "Password"),
'concealed': ("-C", "--concealed", "Don't echo seed to console when restoring"),
'receiving': (None, "--receiving", "Show only receiving addresses"), 'receiving': (None, "--receiving", "Show only receiving addresses"),
'change': (None, "--change", "Show only change addresses"), 'change': (None, "--change", "Show only change addresses"),
'frozen': (None, "--frozen", "Show only frozen addresses"), 'frozen': (None, "--frozen", "Show only frozen addresses"),