Browse Source

Full checking of all loaded keys

0.8
Pieter Wuille 13 years ago
parent
commit
91f43a33f8
  1. 4
      src/db.cpp
  2. 12
      src/key.h

4
src/db.cpp

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

12
src/key.h

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

Loading…
Cancel
Save