Try wallet fix here
This commit is contained in:
24
src/main.cpp
24
src/main.cpp
@@ -3835,15 +3835,16 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) {
|
|||||||
assert(pcoinsTip->GetSaplingAnchorAt(pcoinsTip->GetBestAnchor(SAPLING), newSaplingTree));
|
assert(pcoinsTip->GetSaplingAnchorAt(pcoinsTip->GetBestAnchor(SAPLING), newSaplingTree));
|
||||||
// Let wallets know transactions went from 1-confirmed to
|
// Let wallets know transactions went from 1-confirmed to
|
||||||
// 0-confirmed or conflicted:
|
// 0-confirmed or conflicted:
|
||||||
|
std::vector<uint256> TxToRemove;
|
||||||
for (int i = 0; i < block.vtx.size(); i++)
|
for (int i = 0; i < block.vtx.size(); i++)
|
||||||
{
|
{
|
||||||
CTransaction &tx = block.vtx[i];
|
CTransaction &tx = block.vtx[i];
|
||||||
//if ((i == (block.vtx.size() - 1)) && ((ASSETCHAINS_LWMAPOS && block.IsVerusPOSBlock()) || (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block) != 0))))
|
//if ((i == (block.vtx.size() - 1)) && ((ASSETCHAINS_LWMAPOS && block.IsVerusPOSBlock()) || (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block) != 0))))
|
||||||
if ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block) != 0)))
|
if ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block) != 0)))
|
||||||
{
|
{
|
||||||
//EraseFromWallets(tx.GetHash());
|
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
pwalletMain->EraseFromWallet(tx.GetHash());
|
TxToRemove.push_back(tx.GetHash());
|
||||||
|
//pwalletMain->EraseFromWallet(tx.GetHash());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -3851,6 +3852,25 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) {
|
|||||||
SyncWithWallets(tx, NULL);
|
SyncWithWallets(tx, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ( ASSETCHAINS_STAKED != 0 ) // If Staked chain, scan wallet for orphaned txs and delete them.
|
||||||
|
{
|
||||||
|
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||||
|
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
|
||||||
|
{
|
||||||
|
CTransaction tx;
|
||||||
|
uint256 hashBlock;
|
||||||
|
if (!GetTransaction((*it).first,tx,hashBlock,true))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "TX Does Not Exist: %s\n",(*it).first.ToString().c_str());
|
||||||
|
TxToRemove.push_back((*it).first);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BOOST_FOREACH (uint256& hash, TxToRemove)
|
||||||
|
{
|
||||||
|
pwalletMain->EraseFromWallet(hash);
|
||||||
|
fprintf(stderr, "Erased %s from wallet.\n",hash.ToString().c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
// Update cached incremental witnesses
|
// Update cached incremental witnesses
|
||||||
GetMainSignals().ChainTip(pindexDelete, &block, newSproutTree, newSaplingTree, false);
|
GetMainSignals().ChainTip(pindexDelete, &block, newSproutTree, newSaplingTree, false);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -867,6 +867,8 @@ static bool IsKeyType(string strType)
|
|||||||
strType == "mkey" || strType == "ckey");
|
strType == "mkey" || strType == "ckey");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern uint64_t ASSETCHAINS_STAKED;
|
||||||
|
|
||||||
DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
|
DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
|
||||||
{
|
{
|
||||||
pwallet->vchDefaultKey = CPubKey();
|
pwallet->vchDefaultKey = CPubKey();
|
||||||
@@ -918,8 +920,9 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
|
|||||||
{
|
{
|
||||||
// Leave other errors alone, if we try to fix them we might make things worse.
|
// Leave other errors alone, if we try to fix them we might make things worse.
|
||||||
fNoncriticalErrors = true; // ... but do warn the user there is something wrong.
|
fNoncriticalErrors = true; // ... but do warn the user there is something wrong.
|
||||||
if (strType == "tx")
|
if (strType == "tx" && ASSETCHAINS_STAKED == 0 )
|
||||||
// Rescan if there is a bad transaction record:
|
// Rescan if there is a bad transaction record..
|
||||||
|
// But dont on staked chains!
|
||||||
SoftSetBoolArg("-rescan", true);
|
SoftSetBoolArg("-rescan", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user