|
@ -80,14 +80,11 @@ 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 |
|
|
if sys.stdin.isatty(): |
|
|
password = getpass.getpass(prompt) |
|
|
password = getpass.getpass(prompt) |
|
|
if password and confirm: |
|
|
if password and confirm: |
|
|
password2 = getpass.getpass("Confirm: ") |
|
|
password2 = getpass.getpass("Confirm: ") |
|
|
if password != password2: |
|
|
if password != password2: |
|
|
sys.exit("Error: Passwords do not match.") |
|
|
sys.exit("Error: Passwords do not match.") |
|
|
|
|
|
else: |
|
|
|
|
|
password = raw_input(prompt) |
|
|
|
|
|
if not password: |
|
|
if not password: |
|
|
password = None |
|
|
password = None |
|
|
return password |
|
|
return password |
|
@ -204,6 +201,20 @@ def run_cmdline(config): |
|
|
# options |
|
|
# options |
|
|
args += map(lambda x: config.get(x), cmd.options) |
|
|
args += map(lambda x: config.get(x), cmd.options) |
|
|
|
|
|
|
|
|
|
|
|
# pipe data |
|
|
|
|
|
for i, arg in enumerate(args): |
|
|
|
|
|
if arg == '-': |
|
|
|
|
|
if not sys.stdin.isatty(): |
|
|
|
|
|
pipe_data = sys.stdin.read() |
|
|
|
|
|
try: |
|
|
|
|
|
pipe_data = json.loads(pipe_data) |
|
|
|
|
|
except: |
|
|
|
|
|
pass |
|
|
|
|
|
args[i] = pipe_data |
|
|
|
|
|
break |
|
|
|
|
|
else: |
|
|
|
|
|
raise BaseException('Cannot get argument from stdin') |
|
|
|
|
|
|
|
|
# instanciate wallet for command-line |
|
|
# instanciate wallet for command-line |
|
|
storage = WalletStorage(config.get_wallet_path()) |
|
|
storage = WalletStorage(config.get_wallet_path()) |
|
|
|
|
|
|
|
@ -272,14 +283,16 @@ def run_cmdline(config): |
|
|
always_hook('cmdline_load_wallet', wallet) |
|
|
always_hook('cmdline_load_wallet', wallet) |
|
|
|
|
|
|
|
|
# important warning |
|
|
# important warning |
|
|
if cmd.name in ['dumpprivkey', 'dumpprivkeys']: |
|
|
if cmd.name in ['getprivatekeys', 'dumpprivkeys']: |
|
|
print_stderr("WARNING: ALL your private keys are secret.") |
|
|
print_stderr("WARNING: ALL your private keys are secret.") |
|
|
print_stderr("Exposing a single private key can compromise your entire wallet!") |
|
|
print_stderr("Exposing a single private key can compromise your entire wallet!") |
|
|
print_stderr("In particular, DO NOT use 'redeem private key' services proposed by third parties.") |
|
|
print_stderr("In particular, DO NOT use 'redeem private key' services proposed by third parties.") |
|
|
|
|
|
|
|
|
# commands needing password |
|
|
# commands needing password |
|
|
if cmd.requires_password: |
|
|
if cmd.requires_password and wallet.use_encryption: |
|
|
if wallet.use_encryption: |
|
|
if config.get('password'): |
|
|
|
|
|
password = config.get('password') |
|
|
|
|
|
else: |
|
|
password = prompt_password('Password:', False) |
|
|
password = prompt_password('Password:', False) |
|
|
if not password: |
|
|
if not password: |
|
|
print_msg("Error: Password required") |
|
|
print_msg("Error: Password required") |
|
@ -290,8 +303,6 @@ def run_cmdline(config): |
|
|
except InvalidPassword: |
|
|
except InvalidPassword: |
|
|
print_msg("Error: This password does not decode this wallet.") |
|
|
print_msg("Error: This password does not decode this wallet.") |
|
|
sys.exit(1) |
|
|
sys.exit(1) |
|
|
else: |
|
|
|
|
|
password = None |
|
|
|
|
|
else: |
|
|
else: |
|
|
password = None |
|
|
password = None |
|
|
|
|
|
|
|
|