aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <[email protected]>2014-01-27 10:15:18 +0100
committerWladimir J. van der Laan <[email protected]>2014-01-27 10:16:54 +0100
commitca1913e8f64fc245157b008d6b37160306aa1d83 (patch)
tree65d4289e4ab9aac220e22a0f20ac501f6dbf47fb /src/main.cpp
parentqt: Translation update (diff)
parentFix off-by-one errors in use of IsFinalTx() (diff)
downloaddiscoin-ca1913e8f64fc245157b008d6b37160306aa1d83.tar.xz
discoin-ca1913e8f64fc245157b008d6b37160306aa1d83.zip
Merge pull request #2342
665bdd3 Fix off-by-one errors in use of IsFinalTx() (Peter Todd)
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp
index efc70af90..8c60a26b3 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -365,7 +365,24 @@ bool IsStandardTx(const CTransaction& tx, string& reason)
return false;
}
- if (!IsFinalTx(tx)) {
+ // Treat non-final transactions as non-standard to prevent a specific type
+ // of double-spend attack, as well as DoS attacks. (if the transaction
+ // can't be mined, the attacker isn't expending resources broadcasting it)
+ // Basically we don't want to propagate transactions that can't included in
+ // the next block.
+ //
+ // However, IsFinalTx() is confusing... Without arguments, it uses
+ // chainActive.Height() to evaluate nLockTime; when a block is accepted, chainActive.Height()
+ // is set to the value of nHeight in the block. However, when IsFinalTx()
+ // is called within CBlock::AcceptBlock(), the height of the block *being*
+ // evaluated is what is used. Thus if we want to know if a transaction can
+ // be part of the *next* block, we need to call IsFinalTx() with one more
+ // than chainActive.Height().
+ //
+ // Timestamps on the other hand don't get any special treatment, because we
+ // can't know what timestamp the next block will have, and there aren't
+ // timestamp applications where it matters.
+ if (!IsFinalTx(tx, chainActive.Height() + 1)) {
reason = "non-final";
return false;
}