Exchange rate update
[electrum-nvc.git] / electrum
index 90de2ea..e834e08 100755 (executable)
--- a/electrum
+++ b/electrum
@@ -91,6 +91,7 @@ def arg_parser():
     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)")
     parser.add_option("-1", "--oneserver", action="store_true", dest="oneserver", default=False, help="connect to one server only")
     parser.add_option("--bip32", action="store_true", dest="bip32", default=False, help="bip32 (not final)")
+    parser.add_option("--2of3", action="store_true", dest="2of3", default=False, help="create 2of3 wallet")
     parser.add_option("--mpk", dest="mpk", default=False, help="restore from master public key")
     return parser
 
@@ -110,38 +111,13 @@ def print_help_cb(self, opt, value, parser):
 def run_command(cmd, password=None, args=[]):
     import socket
     if cmd.requires_network and not options.offline:
-        daemon_started = False
-        while True:
-            try:
-                network = NetworkProxy(config)
-                break
-            except socket.error:
-                if cmd != 'daemon':
-                    if not daemon_started:
-                        print "Starting daemon [%s]"%config.get('server')
-                        daemon_started = True
-                        pid = os.fork()
-                        if (pid == 0): # The first child.
-                            os.chdir("/")
-                            os.setsid()
-                            os.umask(0)
-                            pid2 = os.fork()
-                            if (pid2 == 0):  # Second child
-                                server = NetworkServer(config)
-                                try:
-                                    server.main_loop()
-                                except KeyboardInterrupt:
-                                    print "Ctrl C - Stopping server"
-                                sys.exit(1)
-                            sys.exit(0)
-                    else:
-                        time.sleep(0.1)
-                else:
-                    print "Daemon not running"
-                    sys.exit(1)
+        network = NetworkProxy(config)
+        if not network.start(start_daemon= (True if cmd.name!='daemon' else False)):
+            print "Daemon not running"
+            sys.exit(1)
+
+
 
-        network = network
-        network.start()
         if wallet:
             wallet.start_threads(network)
             wallet.update()
@@ -154,7 +130,6 @@ def run_command(cmd, password=None, args=[]):
     try:
         result = func(*args[1:])
     except Exception:
-        print "ecxeption"
         traceback.print_exc(file=sys.stdout)
         sys.exit(1)
 
@@ -279,6 +254,7 @@ if __name__ == '__main__':
                 if not wallet:
                     sys.exit("Error: Invalid seed")
                 wallet.save_seed(password)
+                wallet.create_accounts(password)
 
             if not options.offline:
                 network = Network(config)
@@ -295,12 +271,21 @@ if __name__ == '__main__':
                 print_msg("Warning: This wallet was restored offline. It may contain more addresses than displayed.")
 
         else:
-            wallet = Wallet(storage)
-            wallet.init_seed(None)
-            wallet.save_seed(password)
-            wallet.synchronize()
-            print_msg("Your wallet generation seed is:\n\"%s\"" % wallet.get_mnemonic(password))
-            print_msg("Please keep it in a safe place; if you lose it, you will not be able to restore your wallet.")
+            if not config.get('2of3'):
+                wallet = Wallet(storage)
+                wallet.init_seed(None)
+                wallet.save_seed(password)
+                wallet.synchronize()
+                print_msg("Your wallet generation seed is:\n\"%s\"" % wallet.get_mnemonic(password))
+                print_msg("Please keep it in a safe place; if you lose it, you will not be able to restore your wallet.")
+            else:
+                wallet = Wallet_2of3(storage)
+                cold_seed = wallet.init_cold_seed()
+                wallet.save_cold_seed()
+                print_msg("Your cold seed is:\n\"%s\"" % cold_seed)
+                print_msg("Please store it on paper. ")
+                print_msg("Open this file on your online computer to complete your wallet creation.")
+
 
         print_msg("Wallet saved in '%s'" % wallet.storage.path)