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);
|
AssertLockHeld(cs_wallet);
|
||||||
if ( tx.IsCoinBase() && tx.vout[0].nValue == 0 )
|
if ( tx.IsCoinBase() && tx.vout[0].nValue == 0 )
|
||||||
return false;
|
return false;
|
||||||
if ( tx.vin.empty() )
|
|
||||||
return false;
|
|
||||||
bool fExisted = mapWallet.count(tx.GetHash()) != 0;
|
bool fExisted = mapWallet.count(tx.GetHash()) != 0;
|
||||||
if (fExisted && !fUpdate) return false;
|
if (fExisted && !fUpdate) return false;
|
||||||
auto sproutNoteData = FindMySproutNotes(tx);
|
auto sproutNoteData = FindMySproutNotes(tx);
|
||||||
|
|||||||
@@ -489,7 +489,7 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
|
|||||||
fprintf(stderr, "Removing corrupt tx from wallet.%s\n", hash.ToString().c_str());
|
fprintf(stderr, "Removing corrupt tx from wallet.%s\n", hash.ToString().c_str());
|
||||||
deadTxns.push_back(hash);
|
deadTxns.push_back(hash);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Undo serialize changes in 31600
|
// Undo serialize changes in 31600
|
||||||
if (31404 <= wtx.fTimeReceivedIsTxTime && wtx.fTimeReceivedIsTxTime <= 31703)
|
if (31404 <= wtx.fTimeReceivedIsTxTime && wtx.fTimeReceivedIsTxTime <= 31703)
|
||||||
{
|
{
|
||||||
@@ -953,11 +953,19 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
|
|||||||
|
|
||||||
if (!deadTxns.empty())
|
if (!deadTxns.empty())
|
||||||
{
|
{
|
||||||
|
int32_t reAdded = 0;
|
||||||
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());
|
||||||
|
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();
|
deadTxns.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user