Full checking of all loaded keys

This commit is contained in:
Pieter Wuille
2012-01-26 19:26:34 +01:00
committed by Luke Dashjr
parent c1c6de6ad4
commit d841fc969a
2 changed files with 14 additions and 1 deletions

View File

@@ -879,7 +879,7 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
CPrivKey pkey;
ssValue >> pkey;
key.SetPrivKey(pkey);
if (key.GetPubKey() != vchPubKey)
if (key.GetPubKey() != vchPubKey || !key.IsValid())
return DB_CORRUPT;
}
else
@@ -887,6 +887,8 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
CWalletKey wkey;
ssValue >> wkey;
key.SetPrivKey(wkey.vchPrivKey);
if (key.GetPubKey() != vchPubKey || !key.IsValid())
return DB_CORRUPT;
}
if (!pwallet->LoadKey(key))
return DB_CORRUPT;

View File

@@ -233,6 +233,17 @@ public:
{
return CBitcoinAddress(GetPubKey());
}
bool IsValid()
{
if (!fSet)
return false;
CSecret secret = GetSecret();
CKey key2;
key2.SetSecret(secret);
return GetPubKey() == key2.GetPubKey();
}
};
#endif