Fix segfault when creating new wallet
authorPieter Wuille <pieter.wuille@gmail.com>
Sun, 26 Jun 2011 00:37:52 +0000 (02:37 +0200)
committerPieter Wuille <pieter.wuille@gmail.com>
Sun, 26 Jun 2011 00:37:52 +0000 (02:37 +0200)
The initialization of the default key used keyUser instead
of vchDefaultKey. keyUser is now complete removed.

src/wallet.cpp
src/wallet.h

index b06187a..e35bce6 100644 (file)
@@ -962,21 +962,15 @@ bool CWallet::LoadWallet(bool& fFirstRunRet)
         return false;
     fFirstRunRet = vchDefaultKey.empty();
 
-    if (mapKeys.count(vchDefaultKey))
+    if (!mapKeys.count(vchDefaultKey))
     {
-        // Set keyUser
-        keyUser.SetPubKey(vchDefaultKey);
-        keyUser.SetPrivKey(mapKeys[vchDefaultKey]);
-    }
-    else
-    {
-        // Create new keyUser and set as default key
+        // Create new default key
         RandAddSeedPerfmon();
 
         vchDefaultKey = GetKeyFromKeyPool();
         if (!SetAddressBookName(PubKeyToAddress(vchDefaultKey), ""))
             return false;
-        CWalletDB(strWalletFile).WriteDefaultKey(keyUser.GetPubKey());
+        CWalletDB(strWalletFile).WriteDefaultKey(vchDefaultKey);
     }
 
     CreateThread(ThreadFlushWalletDB, &strWalletFile);
index cda4293..b069d31 100644 (file)
@@ -47,7 +47,6 @@ public:
     mutable CCriticalSection cs_mapAddressBook;
 
     std::vector<unsigned char> vchDefaultKey;
-    CKey keyUser;
 
     bool AddKey(const CKey& key);
     bool AddToWallet(const CWalletTx& wtxIn);