aboutsummaryrefslogtreecommitdiff
path: root/src/core.cpp
diff options
context:
space:
mode:
authorTom Harding <tomh@thinlink.com>2014-06-25 23:41:44 -0700
committerTom Harding <tomh@thinlink.com>2014-06-27 07:54:21 -0700
commitd640a3ceab4f4372c2a0f738c1286cfde4b41b50 (patch)
tree48aba47604e601d8b50b23de7ca9bb17f82e9926 /src/core.cpp
parent8fbf03995df9a2003be603be1a930bc3373d56e0 (diff)
downloadbitcoin-d640a3ceab4f4372c2a0f738c1286cfde4b41b50.tar.xz
Relay double-spends, subject to anti-DOS
Allows network wallets and other clients to see transactions that respend a prevout already spent in an unconfirmed transaction in this node's mempool. Knowledge of an attempted double-spend is of interest to recipients of the first spend. In some cases, it will allow these recipients to withhold goods or services upon being alerted of a double-spend that deprives them of payment. As before, respends are not added to the mempool. Anti-Denial-of-Service-Attack provisions: - Use a bloom filter to relay only one respend per mempool prevout - Rate-limit respend relays to a default of 100 thousand bytes/minute - Define tx2.IsEquivalentTo(tx1): equality when scriptSigs are not considered - Do not relay these equivalent transactions Remove an unused variable declaration in txmempool.cpp.
Diffstat (limited to 'src/core.cpp')
-rw-r--r--src/core.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/core.cpp b/src/core.cpp
index 6c5ee1c0f8..ca28624529 100644
--- a/src/core.cpp
+++ b/src/core.cpp
@@ -119,6 +119,22 @@ CTransaction& CTransaction::operator=(const CTransaction &tx) {
return *this;
}
+bool CTransaction::IsEquivalentTo(const CTransaction& tx) const
+{
+ if (nVersion != tx.nVersion ||
+ nLockTime != tx.nLockTime ||
+ vin.size() != tx.vin.size() ||
+ vout != tx.vout)
+ return false;
+ for (unsigned int i = 0; i < vin.size(); i++)
+ {
+ if (vin[i].nSequence != tx.vin[i].nSequence ||
+ vin[i].prevout != tx.vin[i].prevout)
+ return false;
+ }
+ return true;
+}
+
int64_t CTransaction::GetValueOut() const
{
int64_t nValueOut = 0;