tMerge pull request #315 from rofl0r/bug308d - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit fae1b1d32cc025eef33f22db73a5acec2f2fef9b DIR parent 0dce31eedf59b98696a0ac2c040188aef952d9a1 HTML Author: ThomasV <thomasv1@gmx.de> Date: Thu, 19 Sep 2013 12:16:00 -0700 Merge pull request #315 from rofl0r/bug308d make it possible to create wallet non-interactively Diffstat: M electrum | 37 ++++++++++++++++--------------- 1 file changed, 19 insertions(+), 18 deletions(-) --- DIR diff --git a/electrum b/electrum t@@ -84,6 +84,7 @@ def arg_parser(): parser.add_option("-L", "--lang", dest="language", default=None, help="defaut language used in GUI") parser.add_option("-u", "--usb", dest="bitkey", action="store_true", help="Turn on support for hardware wallets (EXPERIMENTAL)") parser.add_option("-G", "--gap", dest="gap_limit", default=None, help="gap limit") + parser.add_option("-W", "--password", dest="password", default=None, help="set password for usage with commands (currently only implemented for create command, do not use it for longrunning gui session since the password is visible in /proc)") return parser def print_help(parser): t@@ -185,22 +186,22 @@ if __name__ == '__main__': if cmd in ['create', 'restore']: if wallet.storage.file_exists: sys.exit("Error: Remove the existing wallet first!") - password = prompt_password("Password (hit return if you do not wish to encrypt your wallet):") - - server = config.get('server') - if not server: server = pick_random_server() - w_host, w_port, w_protocol = server.split(':') - host = raw_input("server (default:%s):"%w_host) - port = raw_input("port (default:%s):"%w_port) - protocol = raw_input("protocol [t=tcp;h=http] (default:%s):"%w_protocol) - fee = raw_input("fee (default:%s):"%( str(Decimal(wallet.fee)/100000000)) ) - gap = raw_input("gap limit (default 5):") - if host: w_host = host - if port: w_port = port - if protocol: w_protocol = protocol - config.set_key('server', w_host + ':' + w_port + ':' +w_protocol) - if fee: wallet.fee = float(fee) - if gap: wallet.gap_limit = int(gap) + if options.password != None: + password = options.password + else: + password = prompt_password("Password (hit return if you do not wish to encrypt your wallet):") + + # if config.server is set, the user either passed the server on command line + # or chose it previously already. if he didn't pass a server on the command line, + # we just pick up a random one. + if not config.get('server'): + config.set_key('server', pick_random_server()) + + fee = options.tx_fee if options.tx_fee else raw_input("fee (default:%s):"%( str(Decimal(wallet.fee)/100000000)) ) + gap = options.gap_limit if options.gap_limit else raw_input("gap limit (default 5):") + + if fee: wallet.set_fee(float(fee)*100000000) + if gap: wallet.change_gap_limit(int(gap)) if cmd == 'restore': seed = raw_input("seed:") t@@ -225,7 +226,6 @@ if __name__ == '__main__': else: print_msg("Warning: Found no history for this wallet") - print_msg("Wallet saved in '%s'"%config.path) else: wallet.init_seed(None) wallet.save_seed() t@@ -235,7 +235,8 @@ if __name__ == '__main__': print_msg("Please keep it in a safe place; if you lose it, you will not be able to restore your wallet.") print_msg("Equivalently, your wallet seed can be stored and recovered with the following mnemonic code:") print_msg("\""+' '.join(mnemonic_encode(wallet.seed))+"\"") - print_msg("Wallet saved in '%s'"%config.path) + + print_msg("Wallet saved in '%s'"%wallet.storage.path) if password: wallet.update_password(wallet.seed, None, password)