Merge pull request #1421 from blackjok3rtt/jl777

fix wallet crash
This commit is contained in:
jl777
2019-04-15 03:52:30 -11:00
committed by GitHub

View File

@@ -954,6 +954,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
if (!deadTxns.empty()) if (!deadTxns.empty())
{ {
int32_t reAdded = 0; int32_t reAdded = 0;
CWalletDB walletdb(pwallet->strWalletFile, "r+", false);
BOOST_FOREACH (uint256& hash, deadTxns) { BOOST_FOREACH (uint256& hash, deadTxns) {
if (!EraseTx(hash)) if (!EraseTx(hash))
fprintf(stderr, "could not delete tx.%s\n",hash.ToString().c_str()); fprintf(stderr, "could not delete tx.%s\n",hash.ToString().c_str());
@@ -961,7 +962,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
if (GetTransaction(hash,tx,blockhash,true)) if (GetTransaction(hash,tx,blockhash,true))
{ {
CWalletTx wtx(pwallet,tx); CWalletTx wtx(pwallet,tx);
pwallet->AddToWallet(wtx, false, NULL); pwallet->AddToWallet(wtx, false, &walletdb);
reAdded++; reAdded++;
} }
} }