aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2015-11-10 15:57:58 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2015-11-10 15:58:00 +0100
commit9fa54a1b0c1ae1b12c292d5cb3158c58c975eb24 (patch)
treea6c750dc620b99c57d7b887da54c467a91218cb4
parent755b4ba848bc61c6c0a858aba042739f34fe37ff (diff)
parente20d9245e58bafdab51105c985478ccb3e0c9095 (diff)
Merge pull request #6822
e20d924 [trivial] init: Use defaults MIN_RELAY_TX_FEE & TRANSACTION_MAXFEE (MarcoFalke) 536766c [trivial] New DEFAULT_MIN_RELAY_TX_FEE = 1000 (MarcoFalke) 5f46a7d transaction_tests: Be more strict checking dust (MarcoFalke)
-rw-r--r--src/init.cpp4
-rw-r--r--src/main.cpp2
-rw-r--r--src/main.h2
-rw-r--r--src/primitives/transaction.h4
-rw-r--r--src/test/transaction_tests.cpp19
5 files changed, 24 insertions, 7 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 8fdafa392a..5f2dc8bf2f 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -385,7 +385,7 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-spendzeroconfchange", strprintf(_("Spend unconfirmed change when sending transactions (default: %u)"), 1));
strUsage += HelpMessageOpt("-txconfirmtarget=<n>", strprintf(_("If paytxfee is not set, include enough fee so transactions begin confirmation on average within n blocks (default: %u)"), DEFAULT_TX_CONFIRM_TARGET));
strUsage += HelpMessageOpt("-maxtxfee=<amt>", strprintf(_("Maximum total fees (in %s) to use in a single wallet transaction; setting this too low may abort large transactions (default: %s)"),
- CURRENCY_UNIT, FormatMoney(maxTxFee)));
+ CURRENCY_UNIT, FormatMoney(DEFAULT_TRANSACTION_MAXFEE)));
strUsage += HelpMessageOpt("-upgradewallet", _("Upgrade wallet to latest format on startup"));
strUsage += HelpMessageOpt("-wallet=<file>", _("Specify wallet file (within data directory)") + " " + strprintf(_("(default: %s)"), "wallet.dat"));
strUsage += HelpMessageOpt("-walletbroadcast", _("Make the wallet broadcast transactions") + " " + strprintf(_("(default: %u)"), true));
@@ -440,7 +440,7 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-maxsigcachesize=<n>", strprintf("Limit size of signature cache to <n> entries (default: %u)", 50000));
}
strUsage += HelpMessageOpt("-minrelaytxfee=<amt>", strprintf(_("Fees (in %s/kB) smaller than this are considered zero fee for relaying, mining and transaction creation (default: %s)"),
- CURRENCY_UNIT, FormatMoney(::minRelayTxFee.GetFeePerK())));
+ CURRENCY_UNIT, FormatMoney(DEFAULT_MIN_RELAY_TX_FEE)));
strUsage += HelpMessageOpt("-printtoconsole", _("Send trace/debug info to console instead of debug.log file"));
if (showDebug)
{
diff --git a/src/main.cpp b/src/main.cpp
index bc49d09fe7..cd932b5d3a 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -75,7 +75,7 @@ uint64_t nPruneTarget = 0;
bool fAlerts = DEFAULT_ALERTS;
/** Fees smaller than this (in satoshi) are considered zero fee (for relaying, mining and transaction creation) */
-CFeeRate minRelayTxFee = CFeeRate(1000);
+CFeeRate minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE);
CTxMemPool mempool(::minRelayTxFee);
diff --git a/src/main.h b/src/main.h
index c7dad10ca3..a82e3faa45 100644
--- a/src/main.h
+++ b/src/main.h
@@ -41,6 +41,8 @@ struct CNodeStateStats;
/** Default for accepting alerts from the P2P network. */
static const bool DEFAULT_ALERTS = true;
+/** Default for -minrelaytxfee, minimum relay fee for transactions */
+static const unsigned int DEFAULT_MIN_RELAY_TX_FEE = 1000;
/** Default for -maxorphantx, maximum number of orphan transactions kept in memory */
static const unsigned int DEFAULT_MAX_ORPHAN_TRANSACTIONS = 100;
/** Default for -limitancestorcount, max number of in-mempool ancestors */
diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h
index 2a457cdae7..98882d315e 100644
--- a/src/primitives/transaction.h
+++ b/src/primitives/transaction.h
@@ -143,8 +143,8 @@ public:
// to spend something, then we consider it dust.
// A typical spendable txout is 34 bytes big, and will
// need a CTxIn of at least 148 bytes to spend:
- // so dust is a spendable txout less than 546 satoshis
- // with default minRelayTxFee.
+ // so dust is a spendable txout less than
+ // 546*minRelayTxFee/1000 (in satoshis)
if (scriptPubKey.IsUnspendable())
return 0;
diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp
index f9423bc0de..fb0df1aff4 100644
--- a/src/test/transaction_tests.cpp
+++ b/src/test/transaction_tests.cpp
@@ -342,11 +342,26 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
string reason;
BOOST_CHECK(IsStandardTx(t, reason));
- t.vout[0].nValue = 501; // dust
+ // Check dust with default relay fee:
+ CAmount nDustThreshold = 182 * minRelayTxFee.GetFeePerK()/1000 * 3;
+ BOOST_CHECK_EQUAL(nDustThreshold, 546);
+ // dust:
+ t.vout[0].nValue = nDustThreshold - 1;
BOOST_CHECK(!IsStandardTx(t, reason));
+ // not dust:
+ t.vout[0].nValue = nDustThreshold;
+ BOOST_CHECK(IsStandardTx(t, reason));
- t.vout[0].nValue = 2730; // not dust
+ // Check dust with odd relay fee to verify rounding:
+ // nDustThreshold = 182 * 1234 / 1000 * 3
+ minRelayTxFee = CFeeRate(1234);
+ // dust:
+ t.vout[0].nValue = 672 - 1;
+ BOOST_CHECK(!IsStandardTx(t, reason));
+ // not dust:
+ t.vout[0].nValue = 672;
BOOST_CHECK(IsStandardTx(t, reason));
+ minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE);
t.vout[0].scriptPubKey = CScript() << OP_1;
BOOST_CHECK(!IsStandardTx(t, reason));