diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -812,13 +812,6 @@ "initial block download (default: %u)", DEFAULT_MAX_TIP_AGE), true, OptionsCategory::DEBUG_TEST); - gArgs.AddArg( - "-maxtxfee=", - strprintf(_("Maximum total fees (in %s) to use in a single wallet " - "transaction or raw transaction; setting this too low may " - "abort large transactions (default: %s)"), - CURRENCY_UNIT, FormatMoney(DEFAULT_TRANSACTION_MAXFEE)), - false, OptionsCategory::DEBUG_TEST); gArgs.AddArg( "-printtoconsole", diff --git a/src/wallet/fees.cpp b/src/wallet/fees.cpp --- a/src/wallet/fees.cpp +++ b/src/wallet/fees.cpp @@ -31,9 +31,7 @@ } CFeeRate GetRequiredFeeRate() { - // FIXME: This should be CWallet::minTxFee but it was removed so we use - // minRelayFee exclusively instead. - return ::minRelayTxFee; + return std::max(CWallet::minTxFee, ::minRelayTxFee); } CFeeRate GetMinimumFeeRate(const CCoinControl &coin_control, diff --git a/src/wallet/init.cpp b/src/wallet/init.cpp --- a/src/wallet/init.cpp +++ b/src/wallet/init.cpp @@ -56,15 +56,28 @@ gArgs.AddArg("-disablewallet", _("Do not load the wallet and disable wallet RPC calls"), false, OptionsCategory::WALLET); - gArgs.AddArg("-keypool=", - strprintf(_("Set key pool size to (default: %u)"), - DEFAULT_KEYPOOL_SIZE), - false, OptionsCategory::WALLET); gArgs.AddArg("-fallbackfee=", strprintf(_("A fee rate (in %s/kB) that will be used when fee " "estimation has insufficient data (default: %s)"), CURRENCY_UNIT, FormatMoney(DEFAULT_FALLBACK_FEE)), false, OptionsCategory::WALLET); + gArgs.AddArg("-keypool=", + strprintf(_("Set key pool size to (default: %u)"), + DEFAULT_KEYPOOL_SIZE), + false, OptionsCategory::WALLET); + gArgs.AddArg( + "-maxtxfee=", + strprintf(_("Maximum total fees (in %s) to use in a single wallet " + "transaction or raw transaction; setting this too low may " + "abort large transactions (default: %s)"), + CURRENCY_UNIT, FormatMoney(DEFAULT_TRANSACTION_MAXFEE)), + false, OptionsCategory::DEBUG_TEST); + gArgs.AddArg("-mintxfee=", + strprintf(_("Fees (in %s/kB) smaller than this are considered " + "zero fee for transaction creation (default: %s)"), + CURRENCY_UNIT, + FormatMoney(DEFAULT_TRANSACTION_MINFEE_PER_KB)), + false, OptionsCategory::WALLET); gArgs.AddArg( "-paytxfee=", strprintf( @@ -278,6 +291,23 @@ } } + if (gArgs.IsArgSet("-mintxfee")) { + Amount n = Amount::zero(); + auto parsed = ParseMoney(gArgs.GetArg("-mintxfee", ""), n); + if (!parsed || n == Amount::zero()) { + return InitError( + AmountErrMsg("mintxfee", gArgs.GetArg("-mintxfee", ""))); + } + + if (n > HIGH_TX_FEE_PER_KB) { + InitWarning(AmountHighWarn("-mintxfee") + " " + + _("This is the minimum transaction fee you pay on " + "every transaction.")); + } + + CWallet::minTxFee = CFeeRate(n); + } + bSpendZeroConfChange = gArgs.GetBoolArg("-spendzeroconfchange", DEFAULT_SPEND_ZEROCONF_CHANGE); diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -45,6 +45,8 @@ static const Amount DEFAULT_TRANSACTION_FEE = Amount::zero(); //! -fallbackfee default static const Amount DEFAULT_FALLBACK_FEE(20000 * SATOSHI); +//! -mintxfee default +static const Amount DEFAULT_TRANSACTION_MINFEE_PER_KB = 1000 * SATOSHI; //! minimum recommended increment for BIP 125 replacement txs static const Amount WALLET_INCREMENTAL_RELAY_FEE(5000 * SATOSHI); //! Default for -spendzeroconfchange @@ -1082,6 +1084,7 @@ const std::vector &txouts) const; bool DummySignInput(CTxIn &tx_in, const CTxOut &txout) const; + static CFeeRate minTxFee; static CFeeRate fallbackFee; bool NewKeyPool(); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -51,6 +51,13 @@ const uint32_t BIP32_HARDENED_KEY_LIMIT = 0x80000000; +/** + * Fees smaller than this (in satoshi) are considered zero fee (for transaction + * creation) + * Override with -mintxfee + */ +CFeeRate CWallet::minTxFee = CFeeRate(DEFAULT_TRANSACTION_MINFEE_PER_KB); + /** * If fee estimation does not have enough data to provide estimates, use this * fee instead. Has no effect if not using fee estimation.