From 8de9bb53af32f7f6b09c06f831f2c0a7b4e95303 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Wed, 24 Apr 2013 18:27:00 -0400 Subject: Define dust transaction outputs, and make them non-standard --- src/main.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/main.h') diff --git a/src/main.h b/src/main.h index 24b2cb2aa6..8c1e6d265c 100644 --- a/src/main.h +++ b/src/main.h @@ -439,6 +439,24 @@ public: return !(a == b); } + size_t size() const + { + return sizeof(nValue)+scriptPubKey.size(); + } + + bool IsDust() const + { + // "Dust" is defined in terms of MIN_RELAY_TX_FEE, which + // has units satoshis-per-kilobyte. + // If you'd pay more than 1/3 in fees + // to spend something, then we consider it dust. + // A typical txout is 32 bytes big, and will + // need a CTxIn of at least 148 bytes to spend, + // so dust is a txout less than 54 uBTC + // (5400 satoshis) + return ((nValue*1000)/(3*(size()+148)) < MIN_RELAY_TX_FEE); + } + std::string ToString() const { if (scriptPubKey.size() < 6) -- cgit v1.2.3