diff options
author | Gavin Andresen <gavinandresen@gmail.com> | 2012-01-31 12:19:26 -0500 |
---|---|---|
committer | Gavin Andresen <gavinandresen@gmail.com> | 2012-01-31 12:19:26 -0500 |
commit | 4477b17f15ac3e574fdddef7c9cf10473158d30d (patch) | |
tree | 94a1acddc9c40fe04539e318172920281ecebf96 | |
parent | 68649bef9395947f3a71e40daae053ca5c0aabca (diff) | |
parent | 91f43a33f8fb9d87bd2b6a7a279e4a6f5c1e3c96 (diff) |
Merge branch 'checkkeys' of https://github.com/sipa/bitcoin
-rw-r--r-- | src/db.cpp | 4 | ||||
-rw-r--r-- | src/key.h | 12 |
2 files changed, 15 insertions, 1 deletions
diff --git a/src/db.cpp b/src/db.cpp index 9ad05ba780..07f58ef38a 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -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) 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; @@ -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 |