Re-add txs that were removed from wallet, if they are valid.
This commit is contained in:
@@ -1753,8 +1753,6 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
|
||||
AssertLockHeld(cs_wallet);
|
||||
if ( tx.IsCoinBase() && tx.vout[0].nValue == 0 )
|
||||
return false;
|
||||
if ( tx.vin.empty() )
|
||||
return false;
|
||||
bool fExisted = mapWallet.count(tx.GetHash()) != 0;
|
||||
if (fExisted && !fUpdate) return false;
|
||||
auto sproutNoteData = FindMySproutNotes(tx);
|
||||
|
||||
@@ -953,11 +953,19 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
|
||||
|
||||
if (!deadTxns.empty())
|
||||
{
|
||||
int32_t reAdded = 0;
|
||||
BOOST_FOREACH (uint256& hash, deadTxns) {
|
||||
if (!EraseTx(hash))
|
||||
fprintf(stderr, "could not delete tx.%s\n",hash.ToString().c_str());
|
||||
uint256 blockhash; CTransaction tx;
|
||||
if (GetTransaction(hash,tx,blockhash,true))
|
||||
{
|
||||
CWalletTx wtx(pwallet,tx);
|
||||
pwallet->AddToWallet(wtx, true, NULL);
|
||||
reAdded++;
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "Cleared %i corrupted transactions from wallet.\n",deadTxns.size());
|
||||
fprintf(stderr, "Cleared %lu corrupted transactions from wallet. Readded %i on chain transactions.\n",deadTxns.size(),reAdded);
|
||||
deadTxns.clear();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user