diff --git a/src/miner.cpp b/src/miner.cpp index f52541eb2..d0f59101f 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -239,7 +239,7 @@ bool BlockAssembler::TestTransaction(const CTransactionRef& tx, PocketBlockRef& // Payload should be in operative table Transactions if (!ptx) { - LogPrint(BCLog::STAKEMODIF, "Warning: build block skip transaction %s with result 'NOT FOUND'\n", + LogPrint(BCLog::SELECTCOINS, "Warning: build block skip transaction %s with result 'NOT FOUND'\n", tx->GetHash().GetHex()); return false; @@ -248,7 +248,7 @@ bool BlockAssembler::TestTransaction(const CTransactionRef& tx, PocketBlockRef& // Check consensus if (auto[ok, result] = PocketConsensus::SocialConsensusHelper::Check(tx, ptx, ChainActive().Height() + 1); !ok) { - LogPrint(BCLog::STAKEMODIF, "Warning: build block skip transaction %s with check result %d\n", + LogPrint(BCLog::SELECTCOINS, "Warning: build block skip transaction %s with check result %d\n", tx->GetHash().GetHex(), (int) result); return false; @@ -257,11 +257,30 @@ bool BlockAssembler::TestTransaction(const CTransactionRef& tx, PocketBlockRef& // Validate consensus if (auto[ok, result] = PocketConsensus::SocialConsensusHelper::Validate(tx, ptx, pblockTemplate, ChainActive().Height() + 1); !ok) { - LogPrint(BCLog::STAKEMODIF, "Warning: build block skip transaction %s with validate result %d\n", + LogPrint(BCLog::SELECTCOINS, "Warning: build block skip transaction %s with validate result %d\n", tx->GetHash().GetHex(), (int) result); return false; } + + CCoinsViewCache view(&::ChainstateActive().CoinsTip()); + for (unsigned int i = 0; i < tx->vin.size(); ++i) { + const COutPoint &prevout = tx->vin[i].prevout; + const Coin& coin = view.AccessCoin(prevout); + if (coin.IsSpent()) + { + LogPrint(BCLog::SELECTCOINS, "Warning: build block skip transaction: tx - %s, prev - %s is spent\n", tx->GetHash().GetHex(), prevout.hash.GetHex()); + return false; + } + + // If prev is pocketnet, check that it's matured + if (ChainActive().Height() + 1 - coin.nHeight < POCKETNET_MATURITY) + { + LogPrint(BCLog::SELECTCOINS, "Warning: build block skip transaction: tx - %s, prev - %s, %d - %d = %d < %d\n", + tx->GetHash().GetHex(), prevout.hash.GetHex(), ChainActive().Height() + 1, coin.nHeight, ChainActive().Height() + 1 - coin.nHeight, POCKETNET_MATURITY); + return false; + } + } // All is good - save for descendants pblockTemplate->push_back(ptx); @@ -289,10 +308,12 @@ bool BlockAssembler::TestPackageTransactions(const CTxMemPool::setEntries& packa { if (!IsFinalTx(it->GetTx(), nHeight, nLockTimeCutoff)) { + LogPrint(BCLog::SELECTCOINS, "Warning: build block skip transaction: tx - %s, height - %d, locktime - %d\n", it->GetTx().GetHash().GetHex(), nHeight, nLockTimeCutoff); return false; } if (!fIncludeWitness && it->GetTx().HasWitness()) { + LogPrint(BCLog::SELECTCOINS, "Warning: build block skip transaction: tx - %s, height - %d, HasWitness\n", it->GetTx().GetHash().GetHex(), nHeight); return false; } } @@ -473,7 +494,7 @@ void BlockAssembler::addPackageTxs(int& nPackagesSelected, int& nDescendantsUpda if (packageFees < minFee) { - LogPrintf("tx - %s, fee - %s, minFee - %s\n", iter->GetTx().GetHash().GetHex(), packageFees, minFee); + LogPrint(BCLog::SELECTCOINS, "Warning: build block skip transaction %s, fee (%s) < minFee (%s)\n", iter->GetTx().GetHash().GetHex(), packageFees, minFee); if (fUsingModified) {