electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 89677c47f78c0b762106c575df952376328805e1
parent fa9ce51685dda32b2e78444d8414946f6f0f8b93
Author: ThomasV <thomasv@gitorious>
Date:   Mon, 17 Aug 2015 09:46:50 +0200

cmdline: read all arguments before parsing

Diffstat:
Melectrum | 35+++++++++++++++++------------------
1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/electrum b/electrum @@ -201,20 +201,6 @@ 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()) @@ -383,6 +369,23 @@ if __name__ == '__main__': sys.argv.remove('help') sys.argv.append('-h') + # read arguments from stdin pipe and prompt + for i, arg in enumerate(sys.argv): + if arg == '-': + if not sys.stdin.isatty(): + pipe_data = sys.stdin.read() + try: + pipe_data = json.loads(pipe_data) + except: + pass + sys.argv[i] = pipe_data + break + else: + raise BaseException('Cannot get argument from stdin') + elif arg == '?': + sys.argv[i] = prompt_password('Enter argument (will not echo):', False) + + # parse cmd line parser = get_parser(run_gui, run_daemon, run_cmdline) args = parser.parse_args() @@ -404,10 +407,6 @@ if __name__ == '__main__': if config_options.get('portable'): config_options['electrum_path'] = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'electrum_data') - # If private key is passed on the command line, '?' triggers prompt. - if config_options.get('privkey') and config_options['privkey'] == '?': - config_options['privkey'] = prompt_password('Enter PrivateKey (will not echo):', False) - set_verbosity(config_options.get('verbose')) config = SimpleConfig(config_options)