move network dialog in a new class; simplify interface.get_servers
[electrum-nvc.git] / electrum
index d543116..0cd3539 100755 (executable)
--- a/electrum
+++ b/electrum
@@ -64,7 +64,7 @@ def prompt_password(prompt, confirm=True):
     return password
 
 def arg_parser():
-    usage = "usage: %prog [options] command\nCommands: "+ (', '.join(known_commands))
+    usage = "%prog [options] command" 
     parser = optparse.OptionParser(prog=usage)
     parser.add_option("-g", "--gui", dest="gui", help="User interface: qt, lite, gtk or text")
     parser.add_option("-w", "--wallet", dest="wallet_path", help="wallet path (default: electrum.dat)")
@@ -89,7 +89,7 @@ if __name__ == '__main__':
     parser = arg_parser()
     options, args = parser.parse_args()
     if options.portable and options.wallet_path is None:
-        options.wallet_path = os.path.dirname(os.path.realpath(__file__)) + '/electrum.dat'
+        options.wallet_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'electrum.dat')
     set_verbosity(options.verbose)
 
     # config is an object passed to the various constructors (wallet, interface, gui)
@@ -219,7 +219,7 @@ if __name__ == '__main__':
         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;n=native] (default:%s):"%w_protocol)
+        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
@@ -244,11 +244,12 @@ if __name__ == '__main__':
                 wallet.init_sequence(str(seed))
             else:
                 wallet.init_seed( str(seed) )
+                wallet.save_seed()
 
+            interface = Interface(config)
             if not options.offline:
-                interface = Interface(config)
                 if not interface.start(wait=True):
-                    print_msg("Not connected, aborting.")
+                    print_msg("Not connected, aborting. Try option -o if you want to restore offline.")
                     sys.exit(1)
                 wallet.interface = interface
                 verifier = WalletVerifier(interface, config)
@@ -263,12 +264,14 @@ if __name__ == '__main__':
                 else:
                     print_msg("Warning: Found no history for this wallet")
             else:
+                interface.start(wait=False)
                 wallet.synchronize()
             wallet.fill_addressbook()
             wallet.save()
             print_msg("Wallet saved in '%s'"%wallet.config.path)
         else:
             wallet.init_seed(None)
+            wallet.save_seed()
             wallet.synchronize() # there is no wallet thread 
             wallet.save()
             print_msg("Your wallet generation seed is: " + wallet.seed)