aboutsummaryrefslogtreecommitdiff
path: root/src/db.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2012-03-22 04:59:59 +0100
committerPieter Wuille <pieter.wuille@gmail.com>2012-03-22 04:59:59 +0100
commitef12c2184d926eea25cc804a75bc4068f9f81891 (patch)
tree5d521bec92448b466b4ae3463ce9f121fc98c663 /src/db.cpp
parent100da7367767e7fa360f48f07b7a20e9374fda84 (diff)
Check minversion before loading the rest of the wallet
When a 0.6 wallet with compressed pubkeys is created, it writes a minversion record to prevent older clients from reading it. If the 0.5 loading it sees a key record before seeing the minversion record however, it will fail with DB_CORRUPT instead of DB_TOO_NEW.
Diffstat (limited to 'src/db.cpp')
-rw-r--r--src/db.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/db.cpp b/src/db.cpp
index 0344c7960c..f6cabda291 100644
--- a/src/db.cpp
+++ b/src/db.cpp
@@ -771,6 +771,14 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
//// todo: shouldn't we catch exceptions and try to recover and continue?
CRITICAL_BLOCK(pwallet->cs_wallet)
{
+ int nMinVersion = 0;
+ if (Read((string)"minversion", nMinVersion))
+ {
+ if (nMinVersion > CLIENT_VERSION)
+ return DB_TOO_NEW;
+ pwallet->LoadMinVersion(nMinVersion);
+ }
+
// Get cursor
Dbc* pcursor = GetCursor();
if (!pcursor)
@@ -940,14 +948,6 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
if (nFileVersion == 10300)
nFileVersion = 300;
}
- else if (strType == "minversion")
- {
- int nMinVersion = 0;
- ssValue >> nMinVersion;
- if (nMinVersion > CLIENT_VERSION)
- return DB_TOO_NEW;
- pwallet->LoadMinVersion(nMinVersion);
- }
else if (strType == "cscript")
{
uint160 hash;