Skip to content

Commit

Permalink
Merge pull request #6822
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
laanwj committed Nov 10, 2015
2 parents 755b4ba + e20d924 commit 9fa54a1
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/init.cpp
Expand Up @@ -385,7 +385,7 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-spendzeroconfchange", strprintf(_("Spend unconfirmed change when sending transactions (default: %u)"), 1)); 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("-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)"), 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("-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("-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)); strUsage += HelpMessageOpt("-walletbroadcast", _("Make the wallet broadcast transactions") + " " + strprintf(_("(default: %u)"), true));
Expand Down Expand Up @@ -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("-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)"), 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")); strUsage += HelpMessageOpt("-printtoconsole", _("Send trace/debug info to console instead of debug.log file"));
if (showDebug) if (showDebug)
{ {
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Expand Up @@ -75,7 +75,7 @@ uint64_t nPruneTarget = 0;
bool fAlerts = DEFAULT_ALERTS; bool fAlerts = DEFAULT_ALERTS;


/** Fees smaller than this (in satoshi) are considered zero fee (for relaying, mining and transaction creation) */ /** 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); CTxMemPool mempool(::minRelayTxFee);


Expand Down
2 changes: 2 additions & 0 deletions src/main.h
Expand Up @@ -41,6 +41,8 @@ struct CNodeStateStats;


/** Default for accepting alerts from the P2P network. */ /** Default for accepting alerts from the P2P network. */
static const bool DEFAULT_ALERTS = true; 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 */ /** Default for -maxorphantx, maximum number of orphan transactions kept in memory */
static const unsigned int DEFAULT_MAX_ORPHAN_TRANSACTIONS = 100; static const unsigned int DEFAULT_MAX_ORPHAN_TRANSACTIONS = 100;
/** Default for -limitancestorcount, max number of in-mempool ancestors */ /** Default for -limitancestorcount, max number of in-mempool ancestors */
Expand Down
4 changes: 2 additions & 2 deletions src/primitives/transaction.h
Expand Up @@ -143,8 +143,8 @@ class CTxOut
// to spend something, then we consider it dust. // to spend something, then we consider it dust.
// A typical spendable txout is 34 bytes big, and will // A typical spendable txout is 34 bytes big, and will
// need a CTxIn of at least 148 bytes to spend: // need a CTxIn of at least 148 bytes to spend:
// so dust is a spendable txout less than 546 satoshis // so dust is a spendable txout less than
// with default minRelayTxFee. // 546*minRelayTxFee/1000 (in satoshis)
if (scriptPubKey.IsUnspendable()) if (scriptPubKey.IsUnspendable())
return 0; return 0;


Expand Down
19 changes: 17 additions & 2 deletions src/test/transaction_tests.cpp
Expand Up @@ -342,11 +342,26 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
string reason; string reason;
BOOST_CHECK(IsStandardTx(t, 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)); 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)); BOOST_CHECK(IsStandardTx(t, reason));
minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE);


t.vout[0].scriptPubKey = CScript() << OP_1; t.vout[0].scriptPubKey = CScript() << OP_1;
BOOST_CHECK(!IsStandardTx(t, reason)); BOOST_CHECK(!IsStandardTx(t, reason));
Expand Down

0 comments on commit 9fa54a1

Please sign in to comment.