CPrivKey pkey;
ssValue >> pkey;
key.SetPrivKey(pkey);
- if (key.GetPubKey() != vchPubKey)
+ if (key.GetPubKey() != vchPubKey || !key.IsValid())
return DB_CORRUPT;
}
else
CWalletKey wkey;
ssValue >> wkey;
key.SetPrivKey(wkey.vchPrivKey);
+ if (key.GetPubKey() != vchPubKey || !key.IsValid())
+ return DB_CORRUPT;
}
if (!pwallet->LoadKey(key))
return DB_CORRUPT;
{
return CBitcoinAddress(GetPubKey());
}
+
+ bool IsValid()
+ {
+ if (!fSet)
+ return false;
+
+ CSecret secret = GetSecret();
+ CKey key2;
+ key2.SetSecret(secret);
+ return GetPubKey() == key2.GetPubKey();
+ }
};
#endif