deprecate wallet.save() and 'eval' command
[electrum-nvc.git] / electrum
index e8ad324..206aa19 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)
@@ -188,9 +188,9 @@ if __name__ == '__main__':
         if not found:
             gui.password_dialog()
 
-        wallet.save()
+        #wallet.save()
         gui.main(url)
-        wallet.save()
+        #wallet.save()
 
         verifier.stop()
         synchronizer.stop()
@@ -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
@@ -246,10 +246,10 @@ if __name__ == '__main__':
                 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)
@@ -264,15 +264,15 @@ 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()
+            #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)
             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:")
@@ -380,7 +380,7 @@ if __name__ == '__main__':
         synchronizer = WalletSynchronizer(wallet, config)
         synchronizer.start()
         wallet.update()
-        wallet.save()
+        #wallet.save()
 
 
     # run the command
@@ -394,18 +394,15 @@ if __name__ == '__main__':
             if raw_input("Are you sure you want to continue? (y/n) ") in ['y','Y','yes']:
                 wallet.config.path = ns
                 wallet.seed = ''
+                wallet.config.set_key('seed', '', True)
                 wallet.use_encryption = False
-                wallet.config.set_key('seed','', True)
+                wallet.config.set_key('use_encryption', wallet.use_encryption, True)
                 for k in wallet.imported_keys.keys(): wallet.imported_keys[k] = ''
-                wallet.save()
+                wallet.config.set_key('imported_keys',wallet.imported_keys, True)
                 print_msg("Done.")
             else:
                 print_msg("Action canceled.")
 
-    elif cmd == 'eval':
-        print_msg(eval(args[1]))
-        wallet.save()
-
     elif cmd == 'getconfig':
         key = args[1]
         print_msg(wallet.config.get(key))