Skip to content

Commit 9fa54a1

Browse files
committed
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)
2 parents 755b4ba + e20d924 commit 9fa54a1

File tree

5 files changed

+24
-7
lines changed

5 files changed

+24
-7
lines changed

src/init.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ std::string HelpMessage(HelpMessageMode mode)
385385
strUsage += HelpMessageOpt("-spendzeroconfchange", strprintf(_("Spend unconfirmed change when sending transactions (default: %u)"), 1));
386386
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));
387387
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)"),
388-
CURRENCY_UNIT, FormatMoney(maxTxFee)));
388+
CURRENCY_UNIT, FormatMoney(DEFAULT_TRANSACTION_MAXFEE)));
389389
strUsage += HelpMessageOpt("-upgradewallet", _("Upgrade wallet to latest format on startup"));
390390
strUsage += HelpMessageOpt("-wallet=<file>", _("Specify wallet file (within data directory)") + " " + strprintf(_("(default: %s)"), "wallet.dat"));
391391
strUsage += HelpMessageOpt("-walletbroadcast", _("Make the wallet broadcast transactions") + " " + strprintf(_("(default: %u)"), true));
@@ -440,7 +440,7 @@ std::string HelpMessage(HelpMessageMode mode)
440440
strUsage += HelpMessageOpt("-maxsigcachesize=<n>", strprintf("Limit size of signature cache to <n> entries (default: %u)", 50000));
441441
}
442442
strUsage += HelpMessageOpt("-minrelaytxfee=<amt>", strprintf(_("Fees (in %s/kB) smaller than this are considered zero fee for relaying, mining and transaction creation (default: %s)"),
443-
CURRENCY_UNIT, FormatMoney(::minRelayTxFee.GetFeePerK())));
443+
CURRENCY_UNIT, FormatMoney(DEFAULT_MIN_RELAY_TX_FEE)));
444444
strUsage += HelpMessageOpt("-printtoconsole", _("Send trace/debug info to console instead of debug.log file"));
445445
if (showDebug)
446446
{

src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ uint64_t nPruneTarget = 0;
7575
bool fAlerts = DEFAULT_ALERTS;
7676

7777
/** Fees smaller than this (in satoshi) are considered zero fee (for relaying, mining and transaction creation) */
78-
CFeeRate minRelayTxFee = CFeeRate(1000);
78+
CFeeRate minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE);
7979

8080
CTxMemPool mempool(::minRelayTxFee);
8181

src/main.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ struct CNodeStateStats;
4141

4242
/** Default for accepting alerts from the P2P network. */
4343
static const bool DEFAULT_ALERTS = true;
44+
/** Default for -minrelaytxfee, minimum relay fee for transactions */
45+
static const unsigned int DEFAULT_MIN_RELAY_TX_FEE = 1000;
4446
/** Default for -maxorphantx, maximum number of orphan transactions kept in memory */
4547
static const unsigned int DEFAULT_MAX_ORPHAN_TRANSACTIONS = 100;
4648
/** Default for -limitancestorcount, max number of in-mempool ancestors */

src/primitives/transaction.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ class CTxOut
143143
// to spend something, then we consider it dust.
144144
// A typical spendable txout is 34 bytes big, and will
145145
// need a CTxIn of at least 148 bytes to spend:
146-
// so dust is a spendable txout less than 546 satoshis
147-
// with default minRelayTxFee.
146+
// so dust is a spendable txout less than
147+
// 546*minRelayTxFee/1000 (in satoshis)
148148
if (scriptPubKey.IsUnspendable())
149149
return 0;
150150

src/test/transaction_tests.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,11 +342,26 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
342342
string reason;
343343
BOOST_CHECK(IsStandardTx(t, reason));
344344

345-
t.vout[0].nValue = 501; // dust
345+
// Check dust with default relay fee:
346+
CAmount nDustThreshold = 182 * minRelayTxFee.GetFeePerK()/1000 * 3;
347+
BOOST_CHECK_EQUAL(nDustThreshold, 546);
348+
// dust:
349+
t.vout[0].nValue = nDustThreshold - 1;
346350
BOOST_CHECK(!IsStandardTx(t, reason));
351+
// not dust:
352+
t.vout[0].nValue = nDustThreshold;
353+
BOOST_CHECK(IsStandardTx(t, reason));
347354

348-
t.vout[0].nValue = 2730; // not dust
355+
// Check dust with odd relay fee to verify rounding:
356+
// nDustThreshold = 182 * 1234 / 1000 * 3
357+
minRelayTxFee = CFeeRate(1234);
358+
// dust:
359+
t.vout[0].nValue = 672 - 1;
360+
BOOST_CHECK(!IsStandardTx(t, reason));
361+
// not dust:
362+
t.vout[0].nValue = 672;
349363
BOOST_CHECK(IsStandardTx(t, reason));
364+
minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE);
350365

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

0 commit comments

Comments
 (0)