aboutsummaryrefslogtreecommitdiff
path: root/src/walletdb.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <[email protected]>2013-12-16 17:17:39 +0100
committerWladimir J. van der Laan <[email protected]>2013-12-16 17:36:04 +0100
commit16ec9044d1f2eda7c5c86fcb73c839e17fb35db3 (patch)
tree9f7e2e34445fc56cee7530dc2ba545314235525c /src/walletdb.cpp
parentMerge pull request #3425 (diff)
downloaddiscoin-16ec9044d1f2eda7c5c86fcb73c839e17fb35db3.tar.xz
discoin-16ec9044d1f2eda7c5c86fcb73c839e17fb35db3.zip
Don't create empty transactions when reading corrupted wallet
The current transaction loading code is not exception safe. An exception during deserialization causes an empty transaction to be left behind in the wallet. Fix this by building the transaction separately and adding it only to the wallet at the end. Fixes #3333.
Diffstat (limited to 'src/walletdb.cpp')
-rw-r--r--src/walletdb.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/walletdb.cpp b/src/walletdb.cpp
index 2dc6594e9..9c5bddba6 100644
--- a/src/walletdb.cpp
+++ b/src/walletdb.cpp
@@ -357,16 +357,13 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
{
uint256 hash;
ssKey >> hash;
- CWalletTx& wtx = pwallet->mapWallet[hash];
+ CWalletTx wtx;
ssValue >> wtx;
CValidationState state;
if (CheckTransaction(wtx, state) && (wtx.GetHash() == hash) && state.IsValid())
wtx.BindWallet(pwallet);
else
- {
- pwallet->mapWallet.erase(hash);
return false;
- }
// Undo serialize changes in 31600
if (31404 <= wtx.fTimeReceivedIsTxTime && wtx.fTimeReceivedIsTxTime <= 31703)
@@ -391,6 +388,7 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
if (wtx.nOrderPos == -1)
wss.fAnyUnordered = true;
+ pwallet->mapWallet[hash] = wtx;
//// debug print
//LogPrintf("LoadWallet %s\n", wtx.GetHash().ToString().c_str());
//LogPrintf(" %12"PRId64" %s %s %s\n",