From 834033967805c19d68c3facd3f45d3cf888f0e43 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Sun, 13 May 2012 10:19:28 +0200 Subject: [PATCH] offline option for command line --- electrum | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/electrum b/electrum index a975cb218..c1d7dde6b 100755 --- a/electrum +++ b/electrum @@ -34,6 +34,7 @@ if __name__ == '__main__': parser = OptionParser(usage=usage) parser.add_option("-g", "--gui", dest="gui", default="qt", help="gui") parser.add_option("-w", "--wallet", dest="wallet_path", help="wallet path (default: electrum.dat)") + parser.add_option("-o", "--offline", action="store_true", dest="offline", default=False, help="remain offline") parser.add_option("-a", "--all", action="store_true", dest="show_all", default=False, help="show all addresses") parser.add_option("-b", "--balance", action="store_true", dest="show_balance", default=False, help="show the balance at listed addresses") parser.add_option("-k", "--keys",action="store_true", dest="show_keys",default=False, help="show the private keys of listed addresses") @@ -135,18 +136,20 @@ if __name__ == '__main__': sys.exit(1) wallet.seed = str(seed) - WalletSynchronizer(wallet).start() - print "recovering wallet..." wallet.init_mpk( wallet.seed ) - wallet.up_to_date_event.clear() - wallet.up_to_date = False - wallet.update() - if wallet.is_found(): - wallet.fill_addressbook() - wallet.save() - print "recovery successful" - else: - print "found no history for this wallet" + if not options.offline: + WalletSynchronizer(wallet).start() + print "recovering wallet..." + wallet.up_to_date_event.clear() + wallet.up_to_date = False + wallet.update() + if wallet.is_found(): + print "recovery successful" + else: + print "found no history for this wallet" + wallet.fill_addressbook() + wallet.save() + print "Wallet saved in '%s'"%options.wallet_path else: wallet.new_seed(None) wallet.init_mpk( wallet.seed ) @@ -156,6 +159,7 @@ if __name__ == '__main__': print "Please keep it in a safe place; if you lose it, you will not be able to restore your wallet." print "Equivalently, your wallet seed can be stored and recovered with the following mnemonic code:" print "\""+' '.join(mnemonic.mn_encode(wallet.seed))+"\"" + print "Wallet saved in '%s'"%options.wallet_path # check syntax if cmd in ['payto', 'mktx']: @@ -171,7 +175,7 @@ if __name__ == '__main__': cmd = 'help' # open session - if cmd not in offline_commands: + if cmd not in offline_commands and not options.offline: WalletSynchronizer(wallet).start() wallet.update() wallet.save() @@ -288,7 +292,6 @@ if __name__ == '__main__': else: print "error: master public key does not match" - elif cmd == 'validateaddress': addr = args[1] print wallet.is_valid(addr)