From b51444fd5c0fc548bdd16c8662d7e4caf201a4fe Mon Sep 17 00:00:00 2001 From: kkurokawa Date: Sun, 7 Aug 2016 18:58:14 -0400 Subject: [PATCH 1/2] Re-enable dust threshold checks --- src/primitives/transaction.h | 3 +-- src/test/transaction_tests.cpp | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h index 067b1fcc0..149816406 100644 --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -177,8 +177,7 @@ public: bool IsDust(const CFeeRate &minRelayTxFee) const { - return false; -// return (nValue < GetDustThreshold(minRelayTxFee)); + return (nValue < GetDustThreshold(minRelayTxFee)); } friend bool operator==(const CTxOut& a, const CTxOut& b) diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp index 0e35af45e..550a53c9c 100644 --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -340,8 +340,8 @@ BOOST_AUTO_TEST_CASE(test_IsStandard) CAmount nDustThreshold = 182 * minRelayTxFee.GetFeePerK()/1000 * 3; BOOST_CHECK_EQUAL(nDustThreshold, 546); // dust: - //t.vout[0].nValue = nDustThreshold - 1; - //BOOST_CHECK(!IsStandardTx(t, reason)); + t.vout[0].nValue = nDustThreshold - 1; + BOOST_CHECK(!IsStandardTx(t, reason)); // not dust: t.vout[0].nValue = nDustThreshold; BOOST_CHECK(IsStandardTx(t, reason)); From 50c2ed0feebcc8863dbe760c77de828a82af3382 Mon Sep 17 00:00:00 2001 From: kkurokawa Date: Mon, 8 Aug 2016 18:42:31 -0400 Subject: [PATCH 2/2] lowering dust threshold to 1 , in order to not break lbrynet --- src/primitives/transaction.h | 11 ++++++++--- src/test/transaction_tests.cpp | 7 +++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h index 149816406..38abdf9cb 100644 --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -170,9 +170,14 @@ public: // 546*minRelayTxFee/1000 (in satoshis) if (scriptPubKey.IsUnspendable()) return 0; - - size_t nSize = GetSerializeSize(SER_DISK,0)+148u; - return 3*minRelayTxFee.GetFee(nSize); + + // for lbrycrd this is mainly to prevent 0 value claims + // and some spam protection without limiting small + // lbrynet transactions + return 1; + // below is original bitcoin core code + //size_t nSize = GetSerializeSize(SER_DISK,0)+dd148u; + //return 3*minRelayTxFee.GetFee(nSize); } bool IsDust(const CFeeRate &minRelayTxFee) const diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp index 550a53c9c..1675b0690 100644 --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -337,8 +337,11 @@ BOOST_AUTO_TEST_CASE(test_IsStandard) BOOST_CHECK(IsStandardTx(t, reason)); // Check dust with default relay fee: - CAmount nDustThreshold = 182 * minRelayTxFee.GetFeePerK()/1000 * 3; - BOOST_CHECK_EQUAL(nDustThreshold, 546); + //CAmount nDustThreshold = 182 * minRelayTxFee.GetFeePerK()/1000 * 3; + //BOOST_CHECK_EQUAL(nDustThreshold, 546); + // lbry dust is set to 1, regardless of minRelayTxfee + CAmount nDustThreshold = 1; + // dust: t.vout[0].nValue = nDustThreshold - 1; BOOST_CHECK(!IsStandardTx(t, reason));