aboutsummaryrefslogtreecommitdiff
path: root/src/db.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2012-03-22 04:59:59 +0100
committerLuke Dashjr <luke-jr+git@utopios.org>2012-03-22 16:25:36 -0400
commitfea0a27ddc30f2d51c386d268499d6c50363c202 (patch)
treefa1db3a2258d91758e2cbb6b3d44923049f2b08c /src/db.cpp
parent04dc79f1cc19b48531cc9a16ca502eac34d7e95b (diff)
downloadbitcoin-fea0a27ddc30f2d51c386d268499d6c50363c202.tar.xz
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.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/db.cpp b/src/db.cpp
index 7f9439bf74..bf335e7e3f 100644
--- a/src/db.cpp
+++ b/src/db.cpp
@@ -795,6 +795,13 @@ 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 > VERSION)
+ return DB_TOO_NEW;
+ }
+
// Get cursor
Dbc* pcursor = GetCursor();
if (!pcursor)
@@ -980,13 +987,6 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
if (strKey == "addrProxy") ssValue >> addrProxy;
if (fHaveUPnP && strKey == "fUseUPnP") ssValue >> fUseUPnP;
}
- else if (strType == "minversion")
- {
- int nMinVersion = 0;
- ssValue >> nMinVersion;
- if (nMinVersion > VERSION)
- return DB_TOO_NEW;
- }
}
pcursor->close();
}