@@ -551,13 +551,6 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
551
551
CHDChain chain;
552
552
ssValue >> chain;
553
553
pwallet->GetOrCreateLegacyScriptPubKeyMan ()->LoadHDChain (chain);
554
- } else if (strType == DBKeys::FLAGS) {
555
- uint64_t flags;
556
- ssValue >> flags;
557
- if (!pwallet->LoadWalletFlags (flags)) {
558
- strErr = " Error reading wallet database: Unknown non-tolerable wallet flags found" ;
559
- return false ;
560
- }
561
554
} else if (strType == DBKeys::OLD_KEY) {
562
555
strErr = " Found unsupported 'wkey' record, try loading with version 0.18" ;
563
556
return false ;
@@ -662,7 +655,8 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
662
655
wss.fIsEncrypted = true ;
663
656
} else if (strType != DBKeys::BESTBLOCK && strType != DBKeys::BESTBLOCK_NOMERKLE &&
664
657
strType != DBKeys::MINVERSION && strType != DBKeys::ACENTRY &&
665
- strType != DBKeys::VERSION && strType != DBKeys::SETTINGS) {
658
+ strType != DBKeys::VERSION && strType != DBKeys::SETTINGS &&
659
+ strType != DBKeys::FLAGS) {
666
660
wss.m_unknown_records ++;
667
661
}
668
662
} catch (const std::exception& e) {
@@ -707,6 +701,16 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet)
707
701
pwallet->LoadMinVersion (nMinVersion);
708
702
}
709
703
704
+ // Load wallet flags, so they are known when processing other records.
705
+ // The FLAGS key is absent during wallet creation.
706
+ uint64_t flags;
707
+ if (m_batch->Read (DBKeys::FLAGS, flags)) {
708
+ if (!pwallet->LoadWalletFlags (flags)) {
709
+ pwallet->WalletLogPrintf (" Error reading wallet database: Unknown non-tolerable wallet flags found\n " );
710
+ return DBErrors::CORRUPT;
711
+ }
712
+ }
713
+
710
714
// Get cursor
711
715
if (!m_batch->StartCursor ())
712
716
{
0 commit comments