@@ -803,6 +803,19 @@ static DBErrors LoadMinVersion(CWallet* pwallet, DatabaseBatch& batch) EXCLUSIVE
803
803
return DBErrors::LOAD_OK;
804
804
}
805
805
806
+ static DBErrors LoadWalletFlags (CWallet* pwallet, DatabaseBatch& batch) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)
807
+ {
808
+ AssertLockHeld (pwallet->cs_wallet );
809
+ uint64_t flags;
810
+ if (batch.Read (DBKeys::FLAGS, flags)) {
811
+ if (!pwallet->LoadWalletFlags (flags)) {
812
+ pwallet->WalletLogPrintf (" Error reading wallet database: Unknown non-tolerable wallet flags found\n " );
813
+ return DBErrors::TOO_NEW;
814
+ }
815
+ }
816
+ return DBErrors::LOAD_OK;
817
+ }
818
+
806
819
DBErrors WalletBatch::LoadWallet (CWallet* pwallet)
807
820
{
808
821
CWalletScanState wss;
@@ -822,13 +835,7 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet)
822
835
823
836
// Load wallet flags, so they are known when processing other records.
824
837
// The FLAGS key is absent during wallet creation.
825
- uint64_t flags;
826
- if (m_batch->Read (DBKeys::FLAGS, flags)) {
827
- if (!pwallet->LoadWalletFlags (flags)) {
828
- pwallet->WalletLogPrintf (" Error reading wallet database: Unknown non-tolerable wallet flags found\n " );
829
- return DBErrors::CORRUPT;
830
- }
831
- }
838
+ if ((result = LoadWalletFlags (pwallet, *m_batch)) != DBErrors::LOAD_OK) return result;
832
839
833
840
#ifndef ENABLE_EXTERNAL_SIGNER
834
841
if (pwallet->IsWalletFlagSet (WALLET_FLAG_EXTERNAL_SIGNER)) {
@@ -873,9 +880,6 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet)
873
880
// we assume the user can live with:
874
881
if (IsKeyType (strType) || strType == DBKeys::DEFAULTKEY) {
875
882
result = DBErrors::CORRUPT;
876
- } else if (strType == DBKeys::FLAGS) {
877
- // reading the wallet flags can only fail if unknown flags are present
878
- result = DBErrors::TOO_NEW;
879
883
} else if (wss.tx_corrupt ) {
880
884
pwallet->WalletLogPrintf (" Error: Corrupt transaction found. This can be fixed by removing transactions from wallet and rescanning.\n " );
881
885
// Set tx_corrupt back to false so that the error is only printed once (per corrupt tx)
0 commit comments