mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-11 20:32:35 -03: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:
parent
100da73677
commit
ef12c2184d
1 changed files with 8 additions and 8 deletions
16
src/db.cpp
16
src/db.cpp
|
@ -771,6 +771,14 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
|
||||||
//// todo: shouldn't we catch exceptions and try to recover and continue?
|
//// todo: shouldn't we catch exceptions and try to recover and continue?
|
||||||
CRITICAL_BLOCK(pwallet->cs_wallet)
|
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
|
// Get cursor
|
||||||
Dbc* pcursor = GetCursor();
|
Dbc* pcursor = GetCursor();
|
||||||
if (!pcursor)
|
if (!pcursor)
|
||||||
|
@ -940,14 +948,6 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
|
||||||
if (nFileVersion == 10300)
|
if (nFileVersion == 10300)
|
||||||
nFileVersion = 300;
|
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")
|
else if (strType == "cscript")
|
||||||
{
|
{
|
||||||
uint160 hash;
|
uint160 hash;
|
||||||
|
|
Loading…
Reference in a new issue