Merge #16502: wallet: Drop unused OldKey

0b1f4b3c66 wallet: Drop unused OldKey (João Barbosa)

Pull request description:

  Replaces #16494, `OldKey` (previously `CWalletKey`) was never serialized in the code history which means that unserialization support is not required, so remove the code entirely.

ACKs for top commit:
  jnewbery:
    ACK 0b1f4b3c66
  laanwj:
    ACK 0b1f4b3c66
  fanquake:
    ACK 0b1f4b3c66

Tree-SHA512: 92e9b2d6fc41f2765492d5d69d18fc4302c40ab44f28c8c30ca652c72767fbc484848c51a38ecf1f447849767a583c398784408bb5f64f9c86f9a5872b325ffc
This commit is contained in:
fanquake 2019-08-01 11:54:06 +08:00
commit b7fbf74b98
No known key found for this signature in database
GPG key ID: 2EEB9F5CC09526C1
2 changed files with 7 additions and 33 deletions

View file

@ -663,28 +663,6 @@ public:
}
};
/** Private key that was serialized by an old wallet (only used for deserialization) */
struct OldKey {
CPrivKey vchPrivKey;
ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action) {
// no longer used by the wallet, thus dropped after deserialization:
int64_t nTimeCreated;
int64_t nTimeExpires;
std::string strComment;
int nVersion = s.GetVersion();
if (!(s.GetType() & SER_GETHASH))
READWRITE(nVersion);
READWRITE(vchPrivKey);
READWRITE(nTimeCreated);
READWRITE(nTimeExpires);
READWRITE(LIMITED_STRING(strComment, 65536));
}
};
struct CoinSelectionParams
{
bool use_bnb = true;

View file

@ -115,7 +115,6 @@ bool WalletBatch::WriteCryptedKey(const CPubKey& vchPubKey,
return false;
}
EraseIC(std::make_pair(DBKeys::KEY, vchPubKey));
EraseIC(std::make_pair(DBKeys::OLD_KEY, vchPubKey));
return true;
}
@ -256,7 +255,7 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
ssValue >> fYes;
if (fYes == '1')
pwallet->LoadWatchOnly(script);
} else if (strType == DBKeys::KEY || strType == DBKeys::OLD_KEY) {
} else if (strType == DBKeys::KEY) {
CPubKey vchPubKey;
ssKey >> vchPubKey;
if (!vchPubKey.IsValid())
@ -268,14 +267,8 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
CPrivKey pkey;
uint256 hash;
if (strType == DBKeys::KEY) {
wss.nKeys++;
ssValue >> pkey;
} else {
OldKey wkey;
ssValue >> wkey;
pkey = wkey.vchPrivKey;
}
wss.nKeys++;
ssValue >> pkey;
// Old wallets store keys as DBKeys::KEY [pubkey] => [privkey]
// ... which was slow for wallets with lots of keys, because the public key is re-derived from the private key
@ -407,6 +400,9 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
strErr = "Error reading wallet database: Unknown non-tolerable wallet flags found";
return false;
}
} else if (strType == DBKeys::OLD_KEY) {
strErr = "Found unsupported 'wkey' record, try loading with version 0.18";
return false;
} else if (strType != DBKeys::BESTBLOCK && strType != DBKeys::BESTBLOCK_NOMERKLE &&
strType != DBKeys::MINVERSION && strType != DBKeys::ACENTRY &&
strType != DBKeys::VERSION && strType != DBKeys::SETTINGS) {
@ -428,7 +424,7 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
bool WalletBatch::IsKeyType(const std::string& strType)
{
return (strType == DBKeys::KEY || strType == DBKeys::OLD_KEY ||
return (strType == DBKeys::KEY ||
strType == DBKeys::MASTER_KEY || strType == DBKeys::CRYPTED_KEY);
}