Check minversion before loading the rest of the wallet
[novacoin.git] / src / db.cpp
index 0344c79..f6cabda 100644 (file)
@@ -771,6 +771,14 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
     //// todo: shouldn't we catch exceptions and try to recover and continue?
     CRITICAL_BLOCK(pwallet->cs_wallet)
     {
+        int nMinVersion = 0;
+        if (Read((string)"minversion", nMinVersion))
+        {
+            if (nMinVersion > CLIENT_VERSION)
+                return DB_TOO_NEW;
+            pwallet->LoadMinVersion(nMinVersion);
+        }
+
         // Get cursor
         Dbc* pcursor = GetCursor();
         if (!pcursor)
@@ -940,14 +948,6 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
                 if (nFileVersion == 10300)
                     nFileVersion = 300;
             }
-            else if (strType == "minversion")
-            {
-                int nMinVersion = 0;
-                ssValue >> nMinVersion;
-                if (nMinVersion > CLIENT_VERSION)
-                    return DB_TOO_NEW;
-                pwallet->LoadMinVersion(nMinVersion);
-            }
             else if (strType == "cscript")
             {
                 uint160 hash;