mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-30 18:35:54 +02:00
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.
This commit is contained in:
committed by
Luke Dashjr
parent
04dc79f1cc
commit
fea0a27ddc
14
src/db.cpp
14
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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user