rebrand this branch as 1.9.8
authorThomasV <thomasv@gitorious>
Thu, 27 Feb 2014 09:21:41 +0000 (10:21 +0100)
committerThomasV <thomasv@gitorious>
Thu, 27 Feb 2014 09:21:41 +0000 (10:21 +0100)
electrum
gui/qt/installwizard.py
lib/__init__.py
lib/version.py
lib/wallet.py
lib/wallet_factory.py [deleted file]

index 8c100c1..5d3e270 100755 (executable)
--- a/electrum
+++ b/electrum
@@ -89,6 +89,7 @@ def arg_parser():
     parser.add_option("-G", "--gap", dest="gap_limit", default=None, help="gap limit")
     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")
     return parser
 
 
index 0852763..59aef35 100644 (file)
@@ -3,7 +3,7 @@ from PyQt4.QtCore import *
 import PyQt4.QtCore as QtCore
 
 from electrum.i18n import _
-from electrum import Wallet, mnemonic
+from electrum import Wallet
 
 from seed_dialog import SeedDialog
 from network_dialog import NetworkDialog
index af172f1..ddf27d5 100644 (file)
@@ -1,7 +1,7 @@
 from version import ELECTRUM_VERSION
 from util import format_satoshis, print_msg, print_json, print_error, set_verbosity
 from wallet import WalletSynchronizer, WalletStorage
-from wallet_factory import WalletFactory as Wallet
+from wallet import Wallet
 from verifier import TxVerifier
 from network import Network, DEFAULT_SERVERS, DEFAULT_PORTS, pick_random_server
 from interface import Interface
index 6c01df8..985b942 100644 (file)
@@ -1,4 +1,5 @@
-ELECTRUM_VERSION = "2.0"    # version of the client package
+ELECTRUM_VERSION = "1.9.8"  # version of the client package
 PROTOCOL_VERSION = '0.9'    # protocol version requested
-SEED_VERSION     = 6        # bump this every time the seed generation is modified
+NEW_SEED_VERSION = 6        # bip32 wallets
+OLD_SEED_VERSION = 4        # old electrum deterministic generation
 SEED_PREFIX      = '01'     # the hash of the mnemonic seed must begin with this
index 59ccf29..eeb55ec 100644 (file)
@@ -72,6 +72,7 @@ class WalletStorage:
 
     def __init__(self, config):
         self.lock = threading.Lock()
+        self.config = config
         self.data = {}
         self.file_exists = False
         self.path = self.init_path(config)
@@ -153,7 +154,7 @@ class WalletStorage:
 
     
 
-class Wallet:
+class NewWallet:
 
     def __init__(self, storage):
 
@@ -162,7 +163,7 @@ class Wallet:
         self.gap_limit_for_change = 3 # constant
 
         # saved fields
-        self.seed_version          = storage.get('seed_version', SEED_VERSION)
+        self.seed_version          = storage.get('seed_version', NEW_SEED_VERSION)
 
         self.gap_limit             = storage.get('gap_limit', 5)
         self.use_change            = storage.get('use_change',True)
@@ -299,14 +300,13 @@ class Wallet:
         if self.seed: 
             raise Exception("a seed exists")
 
+        self.seed_version = NEW_SEED_VERSION
+
         if not seed:
             self.seed = self.make_seed()
-            self.seed_version = SEED_VERSION
             return
 
-        self.seed_version = SEED_VERSION
         self.seed = unicodedata.normalize('NFC', unicode(seed.strip()))
-        return
 
             
 
@@ -1688,7 +1688,7 @@ class WalletSynchronizer(threading.Thread):
 
 
 
-class OldWallet(Wallet):
+class OldWallet(NewWallet):
 
     def init_seed(self, seed):
         import mnemonic
@@ -1697,9 +1697,9 @@ class OldWallet(Wallet):
             raise Exception("a seed exists")
 
         if not seed:
-            raise
+            seed = random_seed(128)
 
-        self.seed_version = 4
+        self.seed_version = OLD_SEED_VERSION
 
         # see if seed was entered as hex
         seed = seed.strip()
@@ -1738,7 +1738,7 @@ class OldWallet(Wallet):
         self.save_accounts()
 
     def create_watching_only_wallet(self, K0):
-        self.seed_version = 4
+        self.seed_version = OLD_SEED_VERSION
         self.storage.put('seed_version', self.seed_version, True)
         self.create_account(K0)
 
@@ -1777,3 +1777,66 @@ class OldWallet(Wallet):
         assert k == 0
         return 'Main account'
 
+
+
+
+# former WalletFactory
+class Wallet(object):
+
+    def __new__(self, storage):
+        config = storage.config
+        if config.get('bitkey', False):
+            # if user requested support for Bitkey device,
+            # import Bitkey driver
+            from wallet_bitkey import WalletBitkey
+            return WalletBitkey(config)
+
+        if not storage.file_exists:
+            seed_version = NEW_SEED_VERSION if config.get('bip32') is True else OLD_SEED_VERSION
+        else:
+            seed_version = storage.get('seed_version')
+
+        if seed_version == OLD_SEED_VERSION:
+            return OldWallet(storage)
+        elif seed_version == NEW_SEED_VERSION:
+            return NewWallet(storage)
+        else:
+            msg = "This wallet seed is not supported."
+            if seed_version in [5]:
+                msg += "\nTo open this wallet, try 'git checkout seed_v%d'"%seed_version
+            print msg
+            sys.exit(1)
+
+
+
+
+    @classmethod
+    def from_seed(self, seed, storage):
+        import mnemonic
+        if not seed:
+            return 
+
+        words = seed.strip().split()
+        try:
+            mnemonic.mn_decode(words)
+            uses_electrum_words = True
+        except Exception:
+            uses_electrum_words = False
+
+        try:
+            seed.decode('hex')
+            is_hex = True
+        except Exception:
+            is_hex = False
+         
+        if is_hex or (uses_electrum_words and len(words) != 13):
+            print "old style wallet", len(words), words
+            w = OldWallet(storage)
+            w.init_seed(seed) #hex
+        else:
+            #assert is_seed(seed)
+            w = Wallet(storage)
+            w.init_seed(seed)
+
+
+        return w
diff --git a/lib/wallet_factory.py b/lib/wallet_factory.py
deleted file mode 100644 (file)
index 2f0b035..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-from version import SEED_VERSION
-from wallet import OldWallet, Wallet
-
-class WalletFactory(object):
-    def __new__(self, storage):
-
-        if storage.get('bitkey', False):
-            # if user requested support for Bitkey device,
-            # import Bitkey driver
-            from wallet_bitkey import WalletBitkey
-            return WalletBitkey(config)
-        
-        seed_version = storage.get('seed_version', SEED_VERSION)
-        if seed_version not in [4, 6]:
-            msg = "This wallet seed is not supported."
-            if seed_version in [5]:
-                msg += "\nTo open this wallet, try 'git checkout seed_v%d'"%seed_version
-                print msg
-                sys.exit(1)
-
-
-        if seed_version == 4:
-            return OldWallet(storage)
-        else:
-            return Wallet(storage)
-
-
-    @classmethod
-    def from_seed(self, seed, storage):
-        import mnemonic
-        if not seed:
-            return 
-
-        words = seed.strip().split()
-        try:
-            mnemonic.mn_decode(words)
-            uses_electrum_words = True
-        except Exception:
-            uses_electrum_words = False
-
-        try:
-            seed.decode('hex')
-            is_hex = True
-        except Exception:
-            is_hex = False
-         
-        if is_hex or (uses_electrum_words and len(words) != 13):
-            print "old style wallet", len(words), words
-            w = OldWallet(storage)
-            w.init_seed(seed) #hex
-        else:
-            #assert is_seed(seed)
-            w = Wallet(storage)
-            w.init_seed(seed)
-
-
-        return w