mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 06:43:45 +01:00
CSecret/CKey -> CKey/CPubKey split/refactor
This commit is contained in:
committed by
Pieter Wuille
parent
5d891489ab
commit
dfa23b94c2
@@ -262,52 +262,33 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
|
||||
}
|
||||
else if (strType == "key" || strType == "wkey")
|
||||
{
|
||||
vector<unsigned char> vchPubKey;
|
||||
CPubKey vchPubKey;
|
||||
ssKey >> vchPubKey;
|
||||
CKey key;
|
||||
if (strType == "key")
|
||||
if (!vchPubKey.IsValid())
|
||||
{
|
||||
CPrivKey pkey;
|
||||
ssValue >> pkey;
|
||||
key.SetPubKey(vchPubKey);
|
||||
if (!key.SetPrivKey(pkey))
|
||||
{
|
||||
strErr = "Error reading wallet database: CPrivKey corrupt";
|
||||
return false;
|
||||
}
|
||||
if (key.GetPubKey() != vchPubKey)
|
||||
{
|
||||
strErr = "Error reading wallet database: CPrivKey pubkey inconsistency";
|
||||
return false;
|
||||
}
|
||||
if (!key.IsValid())
|
||||
{
|
||||
strErr = "Error reading wallet database: invalid CPrivKey";
|
||||
return false;
|
||||
}
|
||||
strErr = "Error reading wallet database: CPubKey corrupt";
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
CKey key;
|
||||
CPrivKey pkey;
|
||||
if (strType == "key")
|
||||
ssValue >> pkey;
|
||||
else {
|
||||
CWalletKey wkey;
|
||||
ssValue >> wkey;
|
||||
key.SetPubKey(vchPubKey);
|
||||
if (!key.SetPrivKey(wkey.vchPrivKey))
|
||||
{
|
||||
strErr = "Error reading wallet database: CPrivKey corrupt";
|
||||
return false;
|
||||
}
|
||||
if (key.GetPubKey() != vchPubKey)
|
||||
{
|
||||
strErr = "Error reading wallet database: CWalletKey pubkey inconsistency";
|
||||
return false;
|
||||
}
|
||||
if (!key.IsValid())
|
||||
{
|
||||
strErr = "Error reading wallet database: invalid CWalletKey";
|
||||
return false;
|
||||
}
|
||||
pkey = wkey.vchPrivKey;
|
||||
}
|
||||
if (!pwallet->LoadKey(key))
|
||||
if (!key.SetPrivKey(pkey, vchPubKey.IsCompressed()))
|
||||
{
|
||||
strErr = "Error reading wallet database: CPrivKey corrupt";
|
||||
return false;
|
||||
}
|
||||
if (key.GetPubKey() != vchPubKey)
|
||||
{
|
||||
strErr = "Error reading wallet database: CPrivKey pubkey inconsistency";
|
||||
return false;
|
||||
}
|
||||
if (!pwallet->LoadKey(key, vchPubKey))
|
||||
{
|
||||
strErr = "Error reading wallet database: LoadKey failed";
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user