aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSjors Provoost <sjors@sprovoost.nl>2021-02-09 15:53:10 +0100
committerSjors Provoost <sjors@sprovoost.nl>2021-02-09 19:01:15 +0100
commit9305862f71189d47c873d366bf976622447e18af (patch)
tree9a69d2859ce181d9ed76af2fe7a09a7c1a32a052
parentb847f49717d1505694727dc800af661737fa6cc6 (diff)
wallet: load flags before everything else
-rw-r--r--src/wallet/walletdb.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp
index 4e6270220e..69854cae05 100644
--- a/src/wallet/walletdb.cpp
+++ b/src/wallet/walletdb.cpp
@@ -551,13 +551,6 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
CHDChain chain;
ssValue >> chain;
pwallet->GetOrCreateLegacyScriptPubKeyMan()->LoadHDChain(chain);
- } else if (strType == DBKeys::FLAGS) {
- uint64_t flags;
- ssValue >> flags;
- if (!pwallet->LoadWalletFlags(flags)) {
- strErr = "Error reading wallet database: Unknown non-tolerable wallet flags found";
- return false;
- }
} else if (strType == DBKeys::OLD_KEY) {
strErr = "Found unsupported 'wkey' record, try loading with version 0.18";
return false;
@@ -662,7 +655,8 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
wss.fIsEncrypted = true;
} else if (strType != DBKeys::BESTBLOCK && strType != DBKeys::BESTBLOCK_NOMERKLE &&
strType != DBKeys::MINVERSION && strType != DBKeys::ACENTRY &&
- strType != DBKeys::VERSION && strType != DBKeys::SETTINGS) {
+ strType != DBKeys::VERSION && strType != DBKeys::SETTINGS &&
+ strType != DBKeys::FLAGS) {
wss.m_unknown_records++;
}
} catch (const std::exception& e) {
@@ -707,6 +701,16 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet)
pwallet->LoadMinVersion(nMinVersion);
}
+ // Load wallet flags, so they are known when processing other records.
+ // The FLAGS key is absent during wallet creation.
+ uint64_t flags;
+ if (m_batch->Read(DBKeys::FLAGS, flags)) {
+ if (!pwallet->LoadWalletFlags(flags)) {
+ pwallet->WalletLogPrintf("Error reading wallet database: Unknown non-tolerable wallet flags found\n");
+ return DBErrors::CORRUPT;
+ }
+ }
+
// Get cursor
if (!m_batch->StartCursor())
{