mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-21 07:39:08 +01:00
Merge branch '0.4.x' into 0.5.0.x
This commit is contained in:
@@ -243,7 +243,7 @@ public:
|
||||
std::vector<unsigned char> getvch() const
|
||||
{
|
||||
unsigned int nSize = BN_bn2mpi(this, NULL);
|
||||
if (nSize < 4)
|
||||
if (nSize <= 4)
|
||||
return std::vector<unsigned char>();
|
||||
std::vector<unsigned char> vch(nSize);
|
||||
BN_bn2mpi(this, &vch[0]);
|
||||
|
||||
35
src/db.cpp
35
src/db.cpp
@@ -780,7 +780,10 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
|
||||
// Get cursor
|
||||
Dbc* pcursor = GetCursor();
|
||||
if (!pcursor)
|
||||
{
|
||||
printf("Error getting wallet database cursor\n");
|
||||
return DB_CORRUPT;
|
||||
}
|
||||
|
||||
loop
|
||||
{
|
||||
@@ -791,7 +794,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
|
||||
@@ -861,19 +867,38 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
|
||||
CPrivKey pkey;
|
||||
ssValue >> pkey;
|
||||
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
|
||||
{
|
||||
CWalletKey wkey;
|
||||
ssValue >> wkey;
|
||||
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")
|
||||
{
|
||||
@@ -882,7 +907,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;
|
||||
@@ -894,7 +922,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")
|
||||
|
||||
@@ -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.c_str());
|
||||
wxMessageBox(strErrors, "Bitcoin", wxOK | wxICON_ERROR);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
strErrors += _("Error loading wallet.dat \n");
|
||||
}
|
||||
printf("%s", strErrors.c_str());
|
||||
printf(" wallet %15"PRI64d"ms\n", GetTimeMillis() - nStart);
|
||||
|
||||
RegisterWallet(pwalletMain);
|
||||
|
||||
Reference in New Issue
Block a user