Skip to content

Commit b7fbf74

Browse files
committed
Merge #16502: wallet: Drop unused OldKey
0b1f4b3 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 0b1f4b3 laanwj: ACK 0b1f4b3 fanquake: ACK 0b1f4b3 Tree-SHA512: 92e9b2d6fc41f2765492d5d69d18fc4302c40ab44f28c8c30ca652c72767fbc484848c51a38ecf1f447849767a583c398784408bb5f64f9c86f9a5872b325ffc
2 parents 25f0edd + 0b1f4b3 commit b7fbf74

File tree

2 files changed

+7
-33
lines changed

2 files changed

+7
-33
lines changed

src/wallet/wallet.h

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -663,28 +663,6 @@ class COutput
663663
}
664664
};
665665

666-
/** Private key that was serialized by an old wallet (only used for deserialization) */
667-
struct OldKey {
668-
CPrivKey vchPrivKey;
669-
ADD_SERIALIZE_METHODS;
670-
671-
template <typename Stream, typename Operation>
672-
inline void SerializationOp(Stream& s, Operation ser_action) {
673-
// no longer used by the wallet, thus dropped after deserialization:
674-
int64_t nTimeCreated;
675-
int64_t nTimeExpires;
676-
std::string strComment;
677-
678-
int nVersion = s.GetVersion();
679-
if (!(s.GetType() & SER_GETHASH))
680-
READWRITE(nVersion);
681-
READWRITE(vchPrivKey);
682-
READWRITE(nTimeCreated);
683-
READWRITE(nTimeExpires);
684-
READWRITE(LIMITED_STRING(strComment, 65536));
685-
}
686-
};
687-
688666
struct CoinSelectionParams
689667
{
690668
bool use_bnb = true;

src/wallet/walletdb.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ bool WalletBatch::WriteCryptedKey(const CPubKey& vchPubKey,
115115
return false;
116116
}
117117
EraseIC(std::make_pair(DBKeys::KEY, vchPubKey));
118-
EraseIC(std::make_pair(DBKeys::OLD_KEY, vchPubKey));
119118
return true;
120119
}
121120

@@ -256,7 +255,7 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
256255
ssValue >> fYes;
257256
if (fYes == '1')
258257
pwallet->LoadWatchOnly(script);
259-
} else if (strType == DBKeys::KEY || strType == DBKeys::OLD_KEY) {
258+
} else if (strType == DBKeys::KEY) {
260259
CPubKey vchPubKey;
261260
ssKey >> vchPubKey;
262261
if (!vchPubKey.IsValid())
@@ -268,14 +267,8 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
268267
CPrivKey pkey;
269268
uint256 hash;
270269

271-
if (strType == DBKeys::KEY) {
272-
wss.nKeys++;
273-
ssValue >> pkey;
274-
} else {
275-
OldKey wkey;
276-
ssValue >> wkey;
277-
pkey = wkey.vchPrivKey;
278-
}
270+
wss.nKeys++;
271+
ssValue >> pkey;
279272

280273
// Old wallets store keys as DBKeys::KEY [pubkey] => [privkey]
281274
// ... 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,
407400
strErr = "Error reading wallet database: Unknown non-tolerable wallet flags found";
408401
return false;
409402
}
403+
} else if (strType == DBKeys::OLD_KEY) {
404+
strErr = "Found unsupported 'wkey' record, try loading with version 0.18";
405+
return false;
410406
} else if (strType != DBKeys::BESTBLOCK && strType != DBKeys::BESTBLOCK_NOMERKLE &&
411407
strType != DBKeys::MINVERSION && strType != DBKeys::ACENTRY &&
412408
strType != DBKeys::VERSION && strType != DBKeys::SETTINGS) {
@@ -428,7 +424,7 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
428424

429425
bool WalletBatch::IsKeyType(const std::string& strType)
430426
{
431-
return (strType == DBKeys::KEY || strType == DBKeys::OLD_KEY ||
427+
return (strType == DBKeys::KEY ||
432428
strType == DBKeys::MASTER_KEY || strType == DBKeys::CRYPTED_KEY);
433429
}
434430

0 commit comments

Comments
 (0)