aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGregory Maxwell <gmaxwell@gmail.com>2012-03-18 20:11:09 -0700
committerGregory Maxwell <gmaxwell@gmail.com>2012-03-18 20:11:09 -0700
commit0b99d1b574f33a67c8bfae0a149ef70346d4a114 (patch)
tree41318335fbde4e7a8696471b697b4b240f8f89eb /src
parent840f69c582b35391d38524e5216991836035d1db (diff)
parent3cc06249322bac5c495848a3f97be508153dc5d9 (diff)
downloadbitcoin-0b99d1b574f33a67c8bfae0a149ef70346d4a114.tar.xz
Merge pull request #931 from luke-jr/dbg_loaderr
Wallet loading diagnostic prints to debug.log
Diffstat (limited to 'src')
-rw-r--r--src/db.cpp38
-rw-r--r--src/init.cpp2
2 files changed, 38 insertions, 2 deletions
diff --git a/src/db.cpp b/src/db.cpp
index b77a038b41..0344c7960c 100644
--- a/src/db.cpp
+++ b/src/db.cpp
@@ -774,7 +774,10 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
// Get cursor
Dbc* pcursor = GetCursor();
if (!pcursor)
+ {
+ printf("Error getting wallet database cursor\n");
return DB_CORRUPT;
+ }
loop
{
@@ -785,7 +788,10 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
if (ret == DB_NOTFOUND)
break;
else if (ret != 0)
+ {
+ printf("Error reading next record from wallet database\n");
return DB_CORRUPT;
+ }
// Unserialize
// Taking advantage of the fact that pair serialization
@@ -856,8 +862,16 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
ssValue >> pkey;
key.SetPubKey(vchPubKey);
key.SetPrivKey(pkey);
- if (key.GetPubKey() != vchPubKey || !key.IsValid())
+ if (key.GetPubKey() != vchPubKey)
+ {
+ printf("Error reading wallet database: CPrivKey pubkey inconsistency\n");
return DB_CORRUPT;
+ }
+ if (!key.IsValid())
+ {
+ printf("Error reading wallet database: invalid CPrivKey\n");
+ return DB_CORRUPT;
+ }
}
else
{
@@ -865,11 +879,22 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
ssValue >> wkey;
key.SetPubKey(vchPubKey);
key.SetPrivKey(wkey.vchPrivKey);
- if (key.GetPubKey() != vchPubKey || !key.IsValid())
+ if (key.GetPubKey() != vchPubKey)
+ {
+ printf("Error reading wallet database: CWalletKey pubkey inconsistency\n");
+ return DB_CORRUPT;
+ }
+ if (!key.IsValid())
+ {
+ printf("Error reading wallet database: invalid CWalletKey\n");
return DB_CORRUPT;
+ }
}
if (!pwallet->LoadKey(key))
+ {
+ printf("Error reading wallet database: LoadKey failed\n");
return DB_CORRUPT;
+ }
}
else if (strType == "mkey")
{
@@ -878,7 +903,10 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
CMasterKey kMasterKey;
ssValue >> kMasterKey;
if(pwallet->mapMasterKeys.count(nID) != 0)
+ {
+ printf("Error reading wallet database: duplicate CMasterKey id %u\n", nID);
return DB_CORRUPT;
+ }
pwallet->mapMasterKeys[nID] = kMasterKey;
if (pwallet->nMasterKeyMaxID < nID)
pwallet->nMasterKeyMaxID = nID;
@@ -890,7 +918,10 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
vector<unsigned char> vchPrivKey;
ssValue >> vchPrivKey;
if (!pwallet->LoadCryptedKey(vchPubKey, vchPrivKey))
+ {
+ printf("Error reading wallet database: LoadCryptedKey failed\n");
return DB_CORRUPT;
+ }
fIsEncrypted = true;
}
else if (strType == "defaultkey")
@@ -924,7 +955,10 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
CScript script;
ssValue >> script;
if (!pwallet->LoadCScript(script))
+ {
+ printf("Error reading wallet database: LoadCScript failed\n");
return DB_CORRUPT;
+ }
}
}
pcursor->close();
diff --git a/src/init.cpp b/src/init.cpp
index 8fe0f90b19..a5db20b908 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -370,12 +370,14 @@ bool AppInit2(int argc, char* argv[])
else if (nLoadWalletRet == DB_NEED_REWRITE)
{
strErrors << _("Wallet needed to be rewritten: restart Bitcoin to complete") << "\n";
+ printf("%s", strErrors.str().c_str());
wxMessageBox(strErrors.str(), "Bitcoin", wxOK | wxICON_ERROR);
return false;
}
else
strErrors << _("Error loading wallet.dat") << "\n";
}
+ printf("%s", strErrors.str().c_str());
printf(" wallet %15"PRI64d"ms\n", GetTimeMillis() - nStart);
RegisterWallet(pwalletMain);