aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorGavin Andresen <[email protected]>2013-02-05 07:12:27 -0800
committerGavin Andresen <[email protected]>2013-02-05 07:12:27 -0800
commit1d0851eca8917f1c3edaa51886c70353f03f8205 (patch)
tree06c58ca8ce31483651ce757ca00ab8de17317588 /src/main.cpp
parentMerge pull request #2253 from luke-jr/bugfix_valstate (diff)
parentMake transactions larger than 100K non-standard (diff)
downloaddiscoin-1d0851eca8917f1c3edaa51886c70353f03f8205.tar.xz
discoin-1d0851eca8917f1c3edaa51886c70353f03f8205.zip
Merge pull request #2273 from gavinandresen/txsize
Make transactions larger than 100K non-standard
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 2b102e5b9..df8f7efa2 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -362,6 +362,14 @@ bool CTransaction::IsStandard() const
if (!IsFinal())
return false;
+ // Extremely large transactions with lots of inputs can cost the network
+ // almost as much to process as they cost the sender in fees, because
+ // computing signature hashes is O(ninputs*txsize). Limiting transactions
+ // to MAX_STANDARD_TX_SIZE mitigates CPU exhaustion attacks.
+ unsigned int sz = this->GetSerializeSize(SER_NETWORK, CTransaction::CURRENT_VERSION);
+ if (sz >= MAX_STANDARD_TX_SIZE)
+ return false;
+
BOOST_FOREACH(const CTxIn& txin, vin)
{
// Biggest 'standard' txin is a 3-signature 3-of-3 CHECKMULTISIG