Skip to content

Commit fadc14e

Browse files
author
MacroFake
committed
Remove ::dustRelayFee
1 parent fa8a7f0 commit fadc14e

File tree

10 files changed

+25
-18
lines changed

10 files changed

+25
-18
lines changed

src/init.cpp

-10
Original file line numberDiff line numberDiff line change
@@ -971,16 +971,6 @@ bool AppInitParameterInteraction(const ArgsManager& args, bool use_syscall_sandb
971971
}
972972
}
973973

974-
// Feerate used to define dust. Shouldn't be changed lightly as old
975-
// implementations may inadvertently create non-standard transactions
976-
if (args.IsArgSet("-dustrelayfee")) {
977-
if (std::optional<CAmount> parsed = ParseMoney(args.GetArg("-dustrelayfee", ""))) {
978-
dustRelayFee = CFeeRate{parsed.value()};
979-
} else {
980-
return InitError(AmountErrMsg("dustrelayfee", args.GetArg("-dustrelayfee", "")));
981-
}
982-
}
983-
984974
nBytesPerSigOp = args.GetIntArg("-bytespersigop", nBytesPerSigOp);
985975

986976
if (!g_wallet_init_interface.ParameterInteraction()) return false;

src/kernel/mempool_options.h

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ struct MemPoolOptions {
3939
CFeeRate incremental_relay_feerate{DEFAULT_INCREMENTAL_RELAY_FEE};
4040
/** A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation) */
4141
CFeeRate min_relay_feerate{DEFAULT_MIN_RELAY_TX_FEE};
42+
CFeeRate dust_relay_feerate{DUST_RELAY_TX_FEE};
4243
bool require_standard{true};
4344
bool full_rbf{DEFAULT_MEMPOOL_FULL_RBF};
4445
MemPoolLimits limits{};

src/mempool_args.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ std::optional<bilingual_str> ApplyArgsManOptions(const ArgsManager& argsman, con
6767
LogPrintf("Increasing minrelaytxfee to %s to match incrementalrelayfee\n", mempool_opts.min_relay_feerate.ToString());
6868
}
6969

70+
// Feerate used to define dust. Shouldn't be changed lightly as old
71+
// implementations may inadvertently create non-standard transactions
72+
if (argsman.IsArgSet("-dustrelayfee")) {
73+
if (std::optional<CAmount> parsed = ParseMoney(argsman.GetArg("-dustrelayfee", ""))) {
74+
mempool_opts.dust_relay_feerate = CFeeRate{parsed.value()};
75+
} else {
76+
return AmountErrMsg("dustrelayfee", argsman.GetArg("-dustrelayfee", ""));
77+
}
78+
}
79+
7080
mempool_opts.require_standard = !argsman.GetBoolArg("-acceptnonstdtxn", !chainparams.RequireStandard());
7181
if (!chainparams.IsTestChain() && !mempool_opts.require_standard) {
7282
return strprintf(Untranslated("acceptnonstdtxn is not currently supported for %s chain"), chainparams.NetworkIDString());

src/node/interfaces.cpp

+10-2
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,11 @@ class NodeImpl : public Node
301301
}
302302
}
303303
bool getNetworkActive() override { return m_context->connman && m_context->connman->GetNetworkActive(); }
304-
CFeeRate getDustRelayFee() override { return ::dustRelayFee; }
304+
CFeeRate getDustRelayFee() override
305+
{
306+
if (!m_context->mempool) return CFeeRate{DUST_RELAY_TX_FEE};
307+
return m_context->mempool->m_dust_relay_feerate;
308+
}
305309
UniValue executeRpc(const std::string& command, const UniValue& params, const std::string& uri) override
306310
{
307311
JSONRPCRequest req;
@@ -686,7 +690,11 @@ class ChainImpl : public Chain
686690
if (!m_node.mempool) return CFeeRate{DEFAULT_INCREMENTAL_RELAY_FEE};
687691
return m_node.mempool->m_incremental_relay_feerate;
688692
}
689-
CFeeRate relayDustFee() override { return ::dustRelayFee; }
693+
CFeeRate relayDustFee() override
694+
{
695+
if (!m_node.mempool) return CFeeRate{DUST_RELAY_TX_FEE};
696+
return m_node.mempool->m_dust_relay_feerate;
697+
}
690698
bool havePruned() override
691699
{
692700
LOCK(::cs_main);

src/policy/settings.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55

66
#include <policy/settings.h>
77

8-
#include <policy/feerate.h>
98
#include <policy/policy.h>
109

1110
bool fIsBareMultisigStd = DEFAULT_PERMIT_BAREMULTISIG;
12-
CFeeRate dustRelayFee = CFeeRate(DUST_RELAY_TX_FEE);
1311
unsigned int nBytesPerSigOp = DEFAULT_BYTES_PER_SIGOP;

src/policy/settings.h

-2
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
#ifndef BITCOIN_POLICY_SETTINGS_H
77
#define BITCOIN_POLICY_SETTINGS_H
88

9-
#include <policy/feerate.h>
109
#include <policy/policy.h>
1110

1211
#include <cstdint>
1312

1413
class CTransaction;
1514

16-
extern CFeeRate dustRelayFee;
1715
extern unsigned int nBytesPerSigOp;
1816
extern bool fIsBareMultisigStd;
1917

src/txmempool.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ CTxMemPool::CTxMemPool(const Options& opts)
460460
m_expiry{opts.expiry},
461461
m_incremental_relay_feerate{opts.incremental_relay_feerate},
462462
m_min_relay_feerate{opts.min_relay_feerate},
463+
m_dust_relay_feerate{opts.dust_relay_feerate},
463464
m_require_standard{opts.require_standard},
464465
m_full_rbf{opts.full_rbf},
465466
m_limits{opts.limits}

src/txmempool.h

+1
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,7 @@ class CTxMemPool
570570
const std::chrono::seconds m_expiry;
571571
const CFeeRate m_incremental_relay_feerate;
572572
const CFeeRate m_min_relay_feerate;
573+
const CFeeRate m_dust_relay_feerate;
573574
const bool m_require_standard;
574575
const bool m_full_rbf;
575576

src/validation.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
700700

701701
// Rather not work on nonstandard transactions (unless -testnet/-regtest)
702702
std::string reason;
703-
if (m_pool.m_require_standard && !IsStandardTx(tx, ::fIsBareMultisigStd, ::dustRelayFee, reason)) {
703+
if (m_pool.m_require_standard && !IsStandardTx(tx, ::fIsBareMultisigStd, m_pool.m_dust_relay_feerate, reason)) {
704704
return state.Invalid(TxValidationResult::TX_NOT_STANDARD, reason);
705705
}
706706

src/wallet/fees.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ CFeeRate GetDiscardRate(const CWallet& wallet)
8787
CFeeRate discard_rate = wallet.chain().estimateSmartFee(highest_target, false /* conservative */);
8888
// Don't let discard_rate be greater than longest possible fee estimate if we get a valid fee estimate
8989
discard_rate = (discard_rate == CFeeRate(0)) ? wallet.m_discard_rate : std::min(discard_rate, wallet.m_discard_rate);
90-
// Discard rate must be at least dustRelayFee
90+
// Discard rate must be at least dust relay feerate
9191
discard_rate = std::max(discard_rate, wallet.chain().relayDustFee());
9292
return discard_rate;
9393
}

0 commit comments

Comments
 (0)