Merge branch 'master' of github.com:novacoin-project/novacoin
[novacoin.git] / src / walletdb.cpp
index 2fe59ce..5c78ff2 100644 (file)
@@ -304,31 +304,31 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
         }
         else if (strType == "malpair")
         {
-            string strKey, strKeyView;
+            string strKeyView;
 
             CSecret vchSecret;
-            CMalleableKeyView keyView;
-
             ssKey >> strKeyView;
-            keyView.SetString(strKeyView);
             ssValue >> vchSecret;
 
-            CMalleableKey mKey = keyView.GetMalleableKey(vchSecret);
-
-            if (mKey.IsNull())
-            {
-                strErr = "Error reading wallet database: CMalleableKey is corrupt";
-                return false;
-            }
-            if (mKey.GetID() != keyView.GetID())
+            CMalleableKeyView keyView(strKeyView);
+            if (!pwallet->LoadMalleableKey(keyView, vchSecret))
             {
-                strErr = "Error reading wallet database: CMalleableKey view inconsistency";
+                strErr = "Error reading wallet database: LoadMalleableKey failed";
                 return false;
             }
+        }
+        else if (strType == "malcpair")
+        {
+            string strKeyView;
 
-            if (!pwallet->LoadMalleableKey(mKey))
+            std::vector<unsigned char> vchCryptedSecret;
+            ssKey >> strKeyView;
+            ssValue >> vchCryptedSecret;
+
+            CMalleableKeyView keyView(strKeyView);
+            if (!pwallet->LoadCryptedMalleableKey(keyView, vchCryptedSecret))
             {
-                strErr = "Error reading wallet database: LoadMalleableKey failed";
+                strErr = "Error reading wallet database: LoadCryptedMalleableKey failed";
                 return false;
             }
         }
@@ -497,7 +497,7 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
 static bool IsKeyType(string strType)
 {
     return (strType== "key" || strType == "wkey" ||
-            strType == "mkey" || strType == "ckey" || strType == "malpair");
+            strType == "mkey" || strType == "ckey" || strType == "malpair" || strType == "malcpair");
 }
 
 DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
@@ -879,7 +879,8 @@ bool ImportWallet(CWallet *pwallet, const string& strLocation)
               continue;
 
           std::vector<std::string> vstr;
-          boost::split(vstr, line, boost::is_any_of(" "));
+          istringstream iss(line);
+          copy(istream_iterator<string>(iss), istream_iterator<string>(), back_inserter(vstr));
           if (vstr.size() < 2)
               continue;
           CBitcoinSecret vchSecret;