Check consistency of private keys
authorPieter Wuille <pieter.wuille@gmail.com>
Wed, 25 Jan 2012 02:05:16 +0000 (03:05 +0100)
committerLuke Dashjr <luke-jr+git@utopios.org>
Thu, 2 Feb 2012 22:49:39 +0000 (17:49 -0500)
Reported by onlineproof on IRC: Bitcoin does not verify whether private
keys and public keys correspond, when loading a wallet.

src/db.cpp

index f9a7d6c..bd31bd7 100644 (file)
@@ -879,6 +879,8 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
                     CPrivKey pkey;
                     ssValue >> pkey;
                     key.SetPrivKey(pkey);
+                    if (key.GetPubKey() != vchPubKey)
+                        return DB_CORRUPT;
                 }
                 else
                 {