@@ -298,13 +298,6 @@ bool WalletBatch::EraseLockedUTXO(const COutPoint& output)
298
298
return EraseIC (std::make_pair (DBKeys::LOCKED_UTXO, std::make_pair (output.hash , output.n )));
299
299
}
300
300
301
- class CWalletScanState {
302
- public:
303
- unsigned int m_unknown_records{0 };
304
-
305
- CWalletScanState () = default ;
306
- };
307
-
308
301
bool LoadKey (CWallet* pwallet, DataStream& ssKey, DataStream& ssValue, std::string& strErr)
309
302
{
310
303
LOCK (pwallet->cs_wallet );
@@ -453,61 +446,6 @@ bool LoadHDChain(CWallet* pwallet, DataStream& ssValue, std::string& strErr)
453
446
return true ;
454
447
}
455
448
456
- static bool
457
- ReadKeyValue (CWallet* pwallet, DataStream& ssKey, CDataStream& ssValue,
458
- CWalletScanState &wss, std::string& strType, std::string& strErr) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)
459
- {
460
- try {
461
- // Unserialize
462
- // Taking advantage of the fact that pair serialization
463
- // is just the two items serialized one after the other
464
- ssKey >> strType;
465
- if (pwallet->IsWalletFlagSet (WALLET_FLAG_DESCRIPTORS) && DBKeys::LEGACY_TYPES.count (strType) > 0 ) {
466
- return true ;
467
- }
468
- if (strType == DBKeys::NAME) {
469
- } else if (strType == DBKeys::PURPOSE) {
470
- } else if (strType == DBKeys::TX) {
471
- } else if (strType == DBKeys::WATCHS) {
472
- } else if (strType == DBKeys::KEY) {
473
- } else if (strType == DBKeys::MASTER_KEY) {
474
- } else if (strType == DBKeys::CRYPTED_KEY) {
475
- } else if (strType == DBKeys::KEYMETA) {
476
- } else if (strType == DBKeys::WATCHMETA) {
477
- } else if (strType == DBKeys::DEFAULTKEY) {
478
- } else if (strType == DBKeys::POOL) {
479
- } else if (strType == DBKeys::CSCRIPT) {
480
- } else if (strType == DBKeys::ORDERPOSNEXT) {
481
- } else if (strType == DBKeys::DESTDATA) {
482
- } else if (strType == DBKeys::HDCHAIN) {
483
- } else if (strType == DBKeys::OLD_KEY) {
484
- } else if (strType == DBKeys::ACTIVEEXTERNALSPK || strType == DBKeys::ACTIVEINTERNALSPK) {
485
- } else if (strType == DBKeys::WALLETDESCRIPTOR) {
486
- } else if (strType == DBKeys::WALLETDESCRIPTORCACHE) {
487
- } else if (strType == DBKeys::WALLETDESCRIPTORLHCACHE) {
488
- } else if (strType == DBKeys::WALLETDESCRIPTORKEY) {
489
- } else if (strType == DBKeys::WALLETDESCRIPTORCKEY) {
490
- } else if (strType == DBKeys::LOCKED_UTXO) {
491
- } else if (strType != DBKeys::BESTBLOCK && strType != DBKeys::BESTBLOCK_NOMERKLE &&
492
- strType != DBKeys::MINVERSION && strType != DBKeys::ACENTRY &&
493
- strType != DBKeys::VERSION && strType != DBKeys::SETTINGS &&
494
- strType != DBKeys::FLAGS) {
495
- wss.m_unknown_records ++;
496
- }
497
- } catch (const std::exception& e) {
498
- if (strErr.empty ()) {
499
- strErr = e.what ();
500
- }
501
- return false ;
502
- } catch (...) {
503
- if (strErr.empty ()) {
504
- strErr = " Caught unknown exception in ReadKeyValue" ;
505
- }
506
- return false ;
507
- }
508
- return true ;
509
- }
510
-
511
449
static DBErrors LoadMinVersion (CWallet* pwallet, DatabaseBatch& batch) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)
512
450
{
513
451
AssertLockHeld (pwallet->cs_wallet );
@@ -1198,8 +1136,6 @@ static DBErrors LoadDecryptionKeys(CWallet* pwallet, DatabaseBatch& batch) EXCLU
1198
1136
1199
1137
DBErrors WalletBatch::LoadWallet (CWallet* pwallet)
1200
1138
{
1201
- CWalletScanState wss;
1202
- bool fNoncriticalErrors = false ;
1203
1139
DBErrors result = DBErrors::LOAD_OK;
1204
1140
bool any_unordered = false ;
1205
1141
std::vector<uint256> upgraded_txs;
@@ -1246,49 +1182,12 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet)
1246
1182
1247
1183
// Load decryption keys
1248
1184
result = std::max (LoadDecryptionKeys (pwallet, *m_batch), result);
1249
-
1250
- // Get cursor
1251
- std::unique_ptr<DatabaseCursor> cursor = m_batch->GetNewCursor ();
1252
- if (!cursor)
1253
- {
1254
- pwallet->WalletLogPrintf (" Error getting wallet database cursor\n " );
1255
- return DBErrors::CORRUPT;
1256
- }
1257
-
1258
- while (true )
1259
- {
1260
- // Read next record
1261
- DataStream ssKey{};
1262
- CDataStream ssValue (SER_DISK, CLIENT_VERSION);
1263
- DatabaseCursor::Status status = cursor->Next (ssKey, ssValue);
1264
- if (status == DatabaseCursor::Status::DONE) {
1265
- break ;
1266
- } else if (status == DatabaseCursor::Status::FAIL) {
1267
- cursor.reset ();
1268
- pwallet->WalletLogPrintf (" Error reading next record from wallet database\n " );
1269
- return DBErrors::CORRUPT;
1270
- }
1271
-
1272
- // Try to be tolerant of single corrupt records:
1273
- std::string strType, strErr;
1274
- if (!ReadKeyValue (pwallet, ssKey, ssValue, wss, strType, strErr))
1275
- {
1276
- // Leave other errors alone, if we try to fix them we might make things worse.
1277
- fNoncriticalErrors = true ; // ... but do warn the user there is something wrong.
1278
- }
1279
- if (!strErr.empty ())
1280
- pwallet->WalletLogPrintf (" %s\n " , strErr);
1281
- }
1282
1185
} catch (...) {
1283
1186
// Exceptions that can be ignored or treated as non-critical are handled by the individual loading functions.
1284
1187
// Any uncaught exceptions will be caught here and treated as critical.
1285
1188
result = DBErrors::CORRUPT;
1286
1189
}
1287
1190
1288
- if (fNoncriticalErrors && result == DBErrors::LOAD_OK) {
1289
- result = DBErrors::NONCRITICAL_ERROR;
1290
- }
1291
-
1292
1191
// Any wallet corruption at all: skip any rewriting or
1293
1192
// upgrading, we don't want to make it worse.
1294
1193
if (result != DBErrors::LOAD_OK)
0 commit comments