From 0d8cc0761c075d67e73612fd482dbc27c3689a99 Mon Sep 17 00:00:00 2001 From: Alexander Block Date: Fri, 1 Feb 2019 08:49:18 +0100 Subject: [PATCH] Invoke CheckSpecialTx after all normal TX checks have passed (#2673) Otherwise duplicate-keys checks for deterministic masternodes triggers for duplicate/identical transactions. --- src/validation.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/validation.cpp b/src/validation.cpp index 8e9f0a239..73b1fe2d1 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -656,9 +656,6 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C return state.DoS(100, false, REJECT_INVALID, "qc-not-allowed"); } - if (!CheckSpecialTx(tx, chainActive.Tip(), state)) - return false; - // Coinbase is only valid in a block, not as a loose transaction if (tx.IsCoinBase()) return state.DoS(100, false, REJECT_INVALID, "coinbase"); @@ -866,6 +863,12 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C return state.DoS(0, false, REJECT_NONSTANDARD, "too-long-mempool-chain", false, errString); } + // check special TXs after all the other checks. If we'd do this before the other checks, we might end up + // DoS scoring a node for non-critical errors, e.g. duplicate keys because a TX is received that was already + // mined + if (!CheckSpecialTx(tx, chainActive.Tip(), state)) + return false; + // If we aren't going to actually accept it but just were verifying it, we are fine already if(fDryRun) return true;