|
|
@ -80,14 +80,11 @@ from electrum.commands import get_parser, known_commands, Commands, config_varia |
|
|
|
# get password routine |
|
|
|
def prompt_password(prompt, confirm=True): |
|
|
|
import getpass |
|
|
|
if sys.stdin.isatty(): |
|
|
|
password = getpass.getpass(prompt) |
|
|
|
if password and confirm: |
|
|
|
password2 = getpass.getpass("Confirm: ") |
|
|
|
if password != password2: |
|
|
|
sys.exit("Error: Passwords do not match.") |
|
|
|
else: |
|
|
|
password = raw_input(prompt) |
|
|
|
password = getpass.getpass(prompt) |
|
|
|
if password and confirm: |
|
|
|
password2 = getpass.getpass("Confirm: ") |
|
|
|
if password != password2: |
|
|
|
sys.exit("Error: Passwords do not match.") |
|
|
|
if not password: |
|
|
|
password = None |
|
|
|
return password |
|
|
@ -204,6 +201,20 @@ def run_cmdline(config): |
|
|
|
# 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 |
|
|
|
storage = WalletStorage(config.get_wallet_path()) |
|
|
|
|
|
|
@ -272,14 +283,16 @@ def run_cmdline(config): |
|
|
|
always_hook('cmdline_load_wallet', wallet) |
|
|
|
|
|
|
|
# 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("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.") |
|
|
|
|
|
|
|
# commands needing password |
|
|
|
if cmd.requires_password: |
|
|
|
if wallet.use_encryption: |
|
|
|
if cmd.requires_password and wallet.use_encryption: |
|
|
|
if config.get('password'): |
|
|
|
password = config.get('password') |
|
|
|
else: |
|
|
|
password = prompt_password('Password:', False) |
|
|
|
if not password: |
|
|
|
print_msg("Error: Password required") |
|
|
@ -290,8 +303,6 @@ def run_cmdline(config): |
|
|
|
except InvalidPassword: |
|
|
|
print_msg("Error: This password does not decode this wallet.") |
|
|
|
sys.exit(1) |
|
|
|
else: |
|
|
|
password = None |
|
|
|
else: |
|
|
|
password = None |
|
|
|
|
|
|
|