aboutsummaryrefslogtreecommitdiff
path: root/src/db.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2011-07-15 16:08:38 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2011-07-15 16:42:44 +0200
commitd4211176208b5e4ae4a699c6ce3239447752cdb2 (patch)
tree2f1c91d534d1571e3a04c000d66590964bbc213e /src/db.cpp
parenta24b23622e504f5134dd8011af5bbe68cb9443f1 (diff)
parent5b0fc31b1c3d25039262ae2043474b35c14bd30b (diff)
downloadbitcoin-d4211176208b5e4ae4a699c6ce3239447752cdb2.tar.xz
Merge branch 'master' of https://github.com/bitcoin/bitcoin
Diffstat (limited to 'src/db.cpp')
-rw-r--r--src/db.cpp59
1 files changed, 45 insertions, 14 deletions
diff --git a/src/db.cpp b/src/db.cpp
index f044355a35..6692db239f 100644
--- a/src/db.cpp
+++ b/src/db.cpp
@@ -627,8 +627,6 @@ int64 CWalletDB::GetAccountCreditDebit(const string& strAccount)
void CWalletDB::ListAccountCreditDebit(const string& strAccount, list<CAccountingEntry>& entries)
{
- int64 nCreditDebit = 0;
-
bool fAllAccounts = (strAccount == "*");
Dbc* pcursor = GetCursor();
@@ -670,7 +668,7 @@ void CWalletDB::ListAccountCreditDebit(const string& strAccount, list<CAccountin
}
-bool CWalletDB::LoadWallet(CWallet* pwallet)
+int CWalletDB::LoadWallet(CWallet* pwallet)
{
pwallet->vchDefaultKey.clear();
int nFileVersion = 0;
@@ -685,12 +683,12 @@ bool CWalletDB::LoadWallet(CWallet* pwallet)
//// todo: shouldn't we catch exceptions and try to recover and continue?
CRITICAL_BLOCK(pwallet->cs_mapWallet)
- CRITICAL_BLOCK(pwallet->cs_mapKeys)
+ CRITICAL_BLOCK(pwallet->cs_KeyStore)
{
// Get cursor
Dbc* pcursor = GetCursor();
if (!pcursor)
- return false;
+ return DB_CORRUPT;
loop
{
@@ -701,7 +699,7 @@ bool CWalletDB::LoadWallet(CWallet* pwallet)
if (ret == DB_NOTFOUND)
break;
else if (ret != 0)
- return false;
+ return DB_CORRUPT;
// Unserialize
// Taking advantage of the fact that pair serialization
@@ -765,14 +763,42 @@ bool CWalletDB::LoadWallet(CWallet* pwallet)
{
vector<unsigned char> vchPubKey;
ssKey >> vchPubKey;
- CWalletKey wkey;
+ CKey key;
if (strType == "key")
- ssValue >> wkey.vchPrivKey;
+ {
+ CPrivKey pkey;
+ ssValue >> pkey;
+ key.SetPrivKey(pkey);
+ }
else
+ {
+ CWalletKey wkey;
ssValue >> wkey;
-
- pwallet->mapKeys[vchPubKey] = wkey.vchPrivKey;
- mapPubKeys[Hash160(vchPubKey)] = vchPubKey;
+ key.SetPrivKey(wkey.vchPrivKey);
+ }
+ if (!pwallet->LoadKey(key))
+ return DB_CORRUPT;
+ }
+ else if (strType == "mkey")
+ {
+ unsigned int nID;
+ ssKey >> nID;
+ CMasterKey kMasterKey;
+ ssValue >> kMasterKey;
+ if(pwallet->mapMasterKeys.count(nID) != 0)
+ return DB_CORRUPT;
+ pwallet->mapMasterKeys[nID] = kMasterKey;
+ if (pwallet->nMasterKeyMaxID < nID)
+ pwallet->nMasterKeyMaxID = nID;
+ }
+ else if (strType == "ckey")
+ {
+ vector<unsigned char> vchPubKey;
+ ssKey >> vchPubKey;
+ vector<unsigned char> vchPrivKey;
+ ssValue >> vchPrivKey;
+ if (!pwallet->LoadCryptedKey(vchPubKey, vchPrivKey))
+ return DB_CORRUPT;
}
else if (strType == "defaultkey")
{
@@ -800,7 +826,6 @@ bool CWalletDB::LoadWallet(CWallet* pwallet)
if (strKey == "fGenerateBitcoins") ssValue >> fGenerateBitcoins;
#endif
if (strKey == "nTransactionFee") ssValue >> nTransactionFee;
- if (strKey == "addrIncoming") ssValue >> addrIncoming;
if (strKey == "fLimitProcessors") ssValue >> fLimitProcessors;
if (strKey == "nLimitProcessors") ssValue >> nLimitProcessors;
if (strKey == "fMinimizeToTray") ssValue >> fMinimizeToTray;
@@ -809,6 +834,13 @@ bool CWalletDB::LoadWallet(CWallet* pwallet)
if (strKey == "addrProxy") ssValue >> addrProxy;
if (fHaveUPnP && strKey == "fUseUPnP") ssValue >> fUseUPnP;
}
+ else if (strType == "minversion")
+ {
+ int nMinVersion = 0;
+ ssValue >> nMinVersion;
+ if (nMinVersion > VERSION)
+ return DB_TOO_NEW;
+ }
}
pcursor->close();
}
@@ -819,7 +851,6 @@ bool CWalletDB::LoadWallet(CWallet* pwallet)
printf("nFileVersion = %d\n", nFileVersion);
printf("fGenerateBitcoins = %d\n", fGenerateBitcoins);
printf("nTransactionFee = %"PRI64d"\n", nTransactionFee);
- printf("addrIncoming = %s\n", addrIncoming.ToString().c_str());
printf("fMinimizeToTray = %d\n", fMinimizeToTray);
printf("fMinimizeOnClose = %d\n", fMinimizeOnClose);
printf("fUseProxy = %d\n", fUseProxy);
@@ -839,7 +870,7 @@ bool CWalletDB::LoadWallet(CWallet* pwallet)
}
- return true;
+ return DB_LOAD_OK;
}
void ThreadFlushWalletDB(void* parg)