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
celbalrai authored and wagerr-builder committed Apr 27, 2022
1 parent bc69f60 commit b18b7dd
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,11 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
*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 @@ -696,7 +701,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.DoS(0, false, REJECT_NONSTANDARD, "premature-op_group-tx");
} else if (!IsAnyOutputGroupedCreation(tx, TokenGroupIdFlags::MGT_TOKEN) && !tokenGroupManager.get()->ManagementTokensCreated()){
Expand Down Expand Up @@ -2244,6 +2249,7 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl
txdata.reserve(block.vtx.size()); // Required so that pointers to individual PrecomputedTransactionData don't get invalidated

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, state, view, fJustCheck, fScriptChecks)) {
Expand All @@ -2266,6 +2272,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 b18b7dd

Please sign in to comment.