Added migration to APPDATA from LOCALAPPDATA for windows based Electrum installations
[electrum-nvc.git] / electrum
index 5eebe71..0d7aab4 100755 (executable)
--- a/electrum
+++ b/electrum
@@ -19,6 +19,7 @@
 import re
 import sys, os, time
 import optparse
+import platform
 
 try:
     import ecdsa  
@@ -71,7 +72,7 @@ options:\n  --fee, -f: set transaction fee\n  --fromaddr, -s: send from address
     'seed':
             "Print the generation seed of your wallet.",
     'importprivkey': 
-            'Imports a key pair\nSyntax: import <address>:<privatekey>',
+            'Import a private key\nSyntax: importprivkey <privatekey>',
     'signmessage':
             'Signs a message with a key\nSyntax: signmessage <address> <message>\nIf you want to lead or end a message with spaces, or want double spaces inside the message make sure you quote the string. I.e. " Hello  This is a weird String "',
     'verifymessage':
@@ -157,6 +158,11 @@ if __name__ == '__main__':
         for k, v in config_options.items():
             if v is None: config_options.pop(k)
 
+    # Wallet migration on Electrum 1.7
+    # Todo: In time we could remove this again
+    if platform.system() == "Windows":
+        util.check_windows_wallet_migration()
+
     config = SimpleConfig(config_options)
     wallet = Wallet(config)
 
@@ -174,6 +180,7 @@ if __name__ == '__main__':
     #right GUI toolkit based the GUI command line option given 
     if cmd == 'gui':
         pref_gui = config.get('gui','classic')
+
         if pref_gui == 'gtk':
             try:
                 import lib.gui as gui
@@ -220,8 +227,7 @@ if __name__ == '__main__':
             s = gui.network_dialog()
 
             if a =='create':
-                wallet.new_seed(None)
-                wallet.init_mpk( wallet.seed )
+                wallet.init_seed(None)
             else:
                 # ask for seed and gap.
                 sg = gui.seed_dialog()
@@ -230,11 +236,10 @@ if __name__ == '__main__':
                 if not seed: exit()
                 wallet.gap_limit = gap
                 if len(seed) == 128:
-                    wallet.seed = None
+                    wallet.seed = ''
                     wallet.master_public_key = seed
                 else:
-                    wallet.seed = str(seed)
-                    wallet.init_mpk( wallet.seed )
+                    wallet.init_seed(str(seed))
             
 
             # generate the first addresses, in case we are offline
@@ -315,10 +320,14 @@ if __name__ == '__main__':
             if not seed:
                 sys.exit("Error: No seed")
 
-            wallet.seed = str(seed)
-            wallet.init_mpk( wallet.seed )
-            if not options.offline:
+            if len(seed) == 128:
+                wallet.seed = None
+                wallet.master_public_key = seed
+            else:
+                wallet.seed = str(seed)
+                wallet.init_mpk( wallet.seed )
 
+            if not options.offline:
                 interface = Interface(config)
                 interface.start()
                 wallet.interface = interface
@@ -339,8 +348,7 @@ if __name__ == '__main__':
             wallet.save()
             print_msg("Wallet saved in '%s'"%wallet.config.path)
         else:
-            wallet.new_seed(None)
-            wallet.init_mpk( wallet.seed )
+            wallet.init_seed(None)
             wallet.synchronize() # there is no wallet thread 
             wallet.save()
             print_msg("Your wallet generation seed is: " + wallet.seed)