Skip to content

Commit 0b1f4b3

Browse files
committed
wallet: Drop unused OldKey
1 parent 74f1a27 commit 0b1f4b3

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
@@ -676,28 +676,6 @@ class COutput
676676
}
677677
};
678678

679-
/** Private key that was serialized by an old wallet (only used for deserialization) */
680-
struct OldKey {
681-
CPrivKey vchPrivKey;
682-
ADD_SERIALIZE_METHODS;
683-
684-
template <typename Stream, typename Operation>
685-
inline void SerializationOp(Stream& s, Operation ser_action) {
686-
// no longer used by the wallet, thus dropped after deserialization:
687-
int64_t nTimeCreated;
688-
int64_t nTimeExpires;
689-
std::string strComment;
690-
691-
int nVersion = s.GetVersion();
692-
if (!(s.GetType() & SER_GETHASH))
693-
READWRITE(nVersion);
694-
READWRITE(vchPrivKey);
695-
READWRITE(nTimeCreated);
696-
READWRITE(nTimeExpires);
697-
READWRITE(LIMITED_STRING(strComment, 65536));
698-
}
699-
};
700-
701679
struct CoinSelectionParams
702680
{
703681
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)