mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-04-21 01:46:59 +08:00
Merge branch 'develop-wallet-cli-improvements' into develop
This commit is contained in:
@@ -350,7 +350,7 @@ def cli_setup(args, config_path=CONFIG_PATH, password=None):
|
||||
interactive = get_default_interactive(True)
|
||||
|
||||
ret = {}
|
||||
|
||||
|
||||
log.debug("Set up config file")
|
||||
|
||||
# are we configured?
|
||||
@@ -362,7 +362,7 @@ def cli_setup(args, config_path=CONFIG_PATH, password=None):
|
||||
pass
|
||||
|
||||
wallet_args = WalletSetupArgs()
|
||||
|
||||
|
||||
# is our wallet ready?
|
||||
res = cli_setup_wallet(wallet_args, interactive=interactive, config_path=config_path, password=password)
|
||||
if 'error' in res:
|
||||
|
||||
@@ -40,7 +40,8 @@ def exit_with_error(error_message, help_message=None):
|
||||
|
||||
if help_message is not None:
|
||||
result['help'] = help_message
|
||||
print_result(result, file=sys.stderr)
|
||||
friendly_newlines = sys.stderr.isatty()
|
||||
print_result(result, friendly_newlines=friendly_newlines, file=sys.stderr)
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
@@ -84,9 +85,14 @@ def pretty_print(data):
|
||||
print pretty_dump(data)
|
||||
|
||||
|
||||
def print_result(json_str, file=sys.stdout):
|
||||
def print_result(json_str, friendly_newlines = False, file=sys.stdout):
|
||||
data = pretty_dump(json_str)
|
||||
|
||||
if friendly_newlines:
|
||||
# note: this makes the produced output INVALID json.
|
||||
# which is why it only does this on error exits.
|
||||
data = data.replace("\\n", "\n")
|
||||
|
||||
if data != "{}":
|
||||
print >> file, data
|
||||
|
||||
|
||||
@@ -753,23 +753,20 @@ def initialize_wallet(password='', wallet_path=None, interactive=True, config_di
|
||||
result['wallet'] = wallet
|
||||
result['wallet_password'] = password
|
||||
|
||||
if not interactive:
|
||||
return result
|
||||
|
||||
if interactive:
|
||||
print('Wallet created. Make sure to backup the following:')
|
||||
output = {
|
||||
'wallet_password': password,
|
||||
'wallet': wallet
|
||||
}
|
||||
print_result(output)
|
||||
print('Wallet created.')
|
||||
input_prompt = 'Would you like us to print out your password and encrypted private key for backup purposes? (y/n): '
|
||||
user_input = raw_input(input_prompt)
|
||||
user_input = user_input.lower()
|
||||
if user_input == 'y':
|
||||
output = {
|
||||
'wallet_password': password,
|
||||
'wallet': wallet
|
||||
}
|
||||
print_result(output)
|
||||
|
||||
input_prompt = 'Have you backed up the above information? (y/n): '
|
||||
user_input = raw_input(input_prompt)
|
||||
user_input = user_input.lower()
|
||||
|
||||
if user_input != 'y':
|
||||
return {'error': 'Please back up your private key first'}
|
||||
print('Wallet is encrypted using your password and stored ' +
|
||||
' at "{}", please make sure you create a backup.'.format(wallet_path))
|
||||
|
||||
except KeyboardInterrupt:
|
||||
return {'error': 'Interrupted'}
|
||||
|
||||
Reference in New Issue
Block a user