Skip to content

Commit

Permalink
Block dust spam tx from mempool before fork point.
Browse files Browse the repository at this point in the history
Don't accept dust spam tx to the mempool even before the fork point.
Blocks with them are still considered valid, though.
  • Loading branch information
domob1812 committed Nov 20, 2014
1 parent 92e2272 commit 9459649
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1191,9 +1191,11 @@ CTransaction::ConnectInputs (DatabaseSet& dbset,

/* Check for unspendable outputs. This is redundant for some
of the checks done in IsUnspendable, but it also takes care
of blocking dust spam. */
of blocking dust spam. If not validating blocks (i. e., miner
or mempool), we are strict and block dust even before
the hardfork point. */
if (IsUnspendable (txPrev->vout[prevout.n], prevHeight,
pindexBlock->nHeight))
pindexBlock->nHeight, !fBlock))
return error ("ConnectInputs: previous txo is unspendable");

// If prev is coinbase, check that it's matured
Expand Down
7 changes: 5 additions & 2 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,11 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock
/* Check if a transaction is unspendable. Either because it is provably
prunable, or because it is explicitly blocked due to some rule. nHeight
is the height at which (or later) it will be spent, and nPrevHeight
is the one where it is included in the block chain. */
bool IsUnspendable (const CTxOut& txo, int nPrevHeight, int nHeight);
is the one where it is included in the block chain. The strict parameter
can be turned on for mempool validation (as opposed to blocks) to
reject transactions from the mempool even before a hardfork. */
bool IsUnspendable (const CTxOut& txo, int nPrevHeight,
int nHeight, bool strict);



Expand Down
4 changes: 2 additions & 2 deletions src/namecoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1937,7 +1937,7 @@ int64 GetNameNetFee(const CTransaction& tx)
}

bool
IsUnspendable (const CTxOut& txo, int nPrevHeight, int nHeight)
IsUnspendable (const CTxOut& txo, int nPrevHeight, int nHeight, bool strict)
{
assert (nPrevHeight <= nHeight);

Expand All @@ -1951,7 +1951,7 @@ IsUnspendable (const CTxOut& txo, int nPrevHeight, int nHeight)
set. We block all 1-Swartz outputs created between blocks 39k and 41k.
Blocking takes effect at the softfork height. */
if (txo.nValue == 1 && nPrevHeight >= 39000 && nPrevHeight <= 41000
&& nHeight >= FORK_HEIGHT_DUSTSPAM)
&& (strict || nHeight >= FORK_HEIGHT_DUSTSPAM))
return true;

/* A name_update or name_firstupdate is unspendable if expired. */
Expand Down

0 comments on commit 9459649

Please sign in to comment.