Skip to content

Commit

Permalink
Reject zerocoin transactions before tx checks
Browse files Browse the repository at this point in the history
  • Loading branch information
wagerr-builder committed Dec 30, 2022
1 parent 343ac4e commit 37bb5ad
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,10 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
if (pfMissingInputs) {
*pfMissingInputs = false;
}
bool fV17Active_context = (unsigned int)chainActive.Height() >= Params().GetConsensus().V17DeploymentHeight;
if (fV17Active_context && tx.ContainsZerocoins()) {
return state.DoS(30, error("%s: zerocoin has been disabled", __func__), REJECT_INVALID, "bad-txns-xwagerr");
}

if (!CheckTransaction(tx, state, true))
return false; // state filled in by CheckTransaction
Expand All @@ -586,7 +590,7 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
// This ensures that someone won't create an invalid OP_GROUP tx that sits in the mempool until after activation,
// potentially causing this node to create a bad block.
if (IsAnyOutputGrouped(tx)) {
if ((unsigned int)chainActive.Tip()->nHeight < chainparams.GetConsensus().ATPStartHeight)
if ((unsigned int)chainActive.Height() < chainparams.GetConsensus().ATPStartHeight)
{
return state.Invalid(ValidationInvalid::TX_NOT_STANDARD, false, REJECT_NONSTANDARD, "premature-op_group-tx");
} else if (!IsAnyOutputGroupedCreation(tx, TokenGroupIdFlags::MGT_TOKEN) && !tokenGroupManager.get()->ManagementTokensCreated()){
Expand Down Expand Up @@ -2191,7 +2195,7 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > addressUnspentIndex;
std::vector<std::pair<CSpentIndexKey, CSpentIndexValue> > spentIndex;

bool fDIP0001Active_context = pindex->nHeight >= Params().GetConsensus().DIP0001Height;
bool fV17Active_context = pindex->nHeight >= Params().GetConsensus().V17DeploymentHeight;

// MUST process special txes before updating UTXO to ensure consistency between mempool and block processing
if (!ProcessSpecialTxsInBlock(block, pindex, *m_quorum_block_processor, state, view, fJustCheck, fScriptChecks)) {
Expand All @@ -2214,6 +2218,10 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl

nInputs += tx->vin.size();

if (fV17Active_context && tx->ContainsZerocoins()) {
return state.DoS(100, error("%s: zerocoin has been disabled", __func__), REJECT_INVALID, "bad-txns-xwagerr");
}

if (tx->HasZerocoinSpendInputs())
{
if (!CheckZerocoinSpendTx(pindex, state, *tx, vSpendsInBlock, vSpends, vMints, nValueIn))
Expand Down

0 comments on commit 37bb5ad

Please sign in to comment.