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
def prompt_password(prompt, confirm=True):
import getpass
password = getpass.getpass(prompt)
password = getpass.getpass(prompt, stream=None)
if password and confirm:
password2 = getpass.getpass("Confirm: ")
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):")
if cmd.name == 'restore':
import getpass
text = getpass.getpass(prompt="seed:", stream=None) if config.get('concealed') else raw_input("seed or key(s):")
text = config.get('text')
try:
wallet = Wallet.from_text(text, password_dialog, storage)
except BaseException as e:
@ -425,6 +424,8 @@ if __name__ == '__main__':
else:
raise BaseException('Cannot get argument from stdin')
elif arg == '?':
sys.argv[i] = raw_input("Enter argument:")
elif arg == ':':
sys.argv[i] = prompt_password('Enter argument (will not echo):', False)
# parse command line

View File

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