diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2012-01-26 19:26:34 +0100 |
---|---|---|
committer | Luke Dashjr <luke-jr+git@utopios.org> | 2012-02-02 20:03:26 -0500 |
commit | d841fc969a3a300ebeaa4279320235f2ff2b0533 (patch) | |
tree | d038b55c8ed79309ce408ad243065524009fa3b7 /src | |
parent | c1c6de6ad4f92c6628dccc271fe4c661e450d130 (diff) | |
download | bitcoin-d841fc969a3a300ebeaa4279320235f2ff2b0533.tar.xz |
Full checking of all loaded keys
Diffstat (limited to 'src')
-rw-r--r-- | src/db.cpp | 4 | ||||
-rw-r--r-- | src/key.h | 11 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/db.cpp b/src/db.cpp index bd31bd7943..600afe383d 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -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; @@ -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 |