Skip to content

Commit 5c759c7

Browse files
committed
[wallet] Move maxTxFee to wallet
This commit moves the maxtxfee setting to the wallet. There is only one minor behavior change: - an error message in feebumper now refers to -maxtxfee instead of maxTxFee.
1 parent bb68abe commit 5c759c7

17 files changed

+45
-50
lines changed

src/dummywallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class DummyWalletInit : public WalletInitInterface {
2424
void DummyWalletInit::AddWalletOptions() const
2525
{
2626
std::vector<std::string> opts = {"-addresstype", "-changetype", "-disablewallet", "-discardfee=<amt>", "-fallbackfee=<amt>",
27-
"-keypool=<n>", "-mintxfee=<amt>", "-paytxfee=<amt>", "-rescan", "-salvagewallet", "-spendzeroconfchange", "-txconfirmtarget=<n>",
27+
"-keypool=<n>", "-maxtxfee=<amt>", "-mintxfee=<amt>", "-paytxfee=<amt>", "-rescan", "-salvagewallet", "-spendzeroconfchange", "-txconfirmtarget=<n>",
2828
"-upgradewallet", "-wallet=<path>", "-walletbroadcast", "-walletdir=<dir>", "-walletnotify=<cmd>", "-walletrbf", "-zapwallettxes=<mode>",
2929
"-dblogsize=<n>", "-flushwallet", "-privdb", "-walletrejectlongchains"};
3030
gArgs.AddHiddenArgs(opts);

src/init.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -502,8 +502,6 @@ void SetupServerArgs()
502502
gArgs.AddArg("-mocktime=<n>", "Replace actual time with <n> seconds since epoch (default: 0)", true, OptionsCategory::DEBUG_TEST);
503503
gArgs.AddArg("-maxsigcachesize=<n>", strprintf("Limit sum of signature cache and script execution cache sizes to <n> MiB (default: %u)", DEFAULT_MAX_SIG_CACHE_SIZE), true, OptionsCategory::DEBUG_TEST);
504504
gArgs.AddArg("-maxtipage=<n>", strprintf("Maximum tip age in seconds to consider node in initial block download (default: %u)", DEFAULT_MAX_TIP_AGE), true, OptionsCategory::DEBUG_TEST);
505-
gArgs.AddArg("-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)", // TODO move setting to wallet
506-
CURRENCY_UNIT, FormatMoney(DEFAULT_TRANSACTION_MAXFEE)), false, OptionsCategory::DEBUG_TEST);
507505
gArgs.AddArg("-printpriority", strprintf("Log transaction fee per kB when mining blocks (default: %u)", DEFAULT_PRINTPRIORITY), true, OptionsCategory::DEBUG_TEST);
508506
gArgs.AddArg("-printtoconsole", "Send trace/debug info to console (default: 1 when no -daemon. To disable logging to file, set -nodebuglogfile)", false, OptionsCategory::DEBUG_TEST);
509507
gArgs.AddArg("-shrinkdebugfile", "Shrink debug.log file on client startup (default: 1 when no -debug)", false, OptionsCategory::DEBUG_TEST);
@@ -1123,22 +1121,6 @@ bool AppInitParameterInteraction()
11231121
dustRelayFee = CFeeRate(n);
11241122
}
11251123

1126-
// This is required by both the wallet and node
1127-
if (gArgs.IsArgSet("-maxtxfee"))
1128-
{
1129-
CAmount nMaxFee = 0;
1130-
if (!ParseMoney(gArgs.GetArg("-maxtxfee", ""), nMaxFee))
1131-
return InitError(AmountErrMsg("maxtxfee", gArgs.GetArg("-maxtxfee", "")));
1132-
if (nMaxFee > HIGH_MAX_TX_FEE)
1133-
InitWarning(_("-maxtxfee is set very high! Fees this large could be paid on a single transaction."));
1134-
maxTxFee = nMaxFee;
1135-
if (CFeeRate(maxTxFee, 1000) < ::minRelayTxFee)
1136-
{
1137-
return InitError(strprintf(_("Invalid amount for -maxtxfee=<amount>: '%s' (must be at least the minrelay fee of %s to prevent stuck transactions)"),
1138-
gArgs.GetArg("-maxtxfee", ""), ::minRelayTxFee.ToString()));
1139-
}
1140-
}
1141-
11421124
fRequireStandard = !gArgs.GetBoolArg("-acceptnonstdtxn", !chainparams.RequireStandard());
11431125
if (chainparams.RequireStandard() && !fRequireStandard)
11441126
return InitError(strprintf("acceptnonstdtxn is not currently supported for %s chain", chainparams.NetworkIDString()));

src/interfaces/chain.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,6 @@ class ChainImpl : public Chain
339339
CFeeRate relayMinFee() override { return ::minRelayTxFee; }
340340
CFeeRate relayIncrementalFee() override { return ::incrementalRelayFee; }
341341
CFeeRate relayDustFee() override { return ::dustRelayFee; }
342-
CAmount maxTxFee() override { return ::maxTxFee; }
343342
bool getPruneMode() override { return ::fPruneMode; }
344343
bool p2pEnabled() override { return g_connman != nullptr; }
345344
bool isReadyToBroadcast() override { return !::fImporting && !::fReindex && !IsInitialBlockDownload(); }

src/interfaces/chain.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,6 @@ class Chain
216216
//! Relay dust fee setting (-dustrelayfee), reflecting lowest rate it's economical to spend.
217217
virtual CFeeRate relayDustFee() = 0;
218218

219-
//! Node max tx fee setting (-maxtxfee).
220-
//! This could be replaced by a per-wallet max fee, as proposed at
221-
//! https://github.com/bitcoin/bitcoin/issues/15355
222-
//! But for the time being, wallets call this to access the node setting.
223-
virtual CAmount maxTxFee() = 0;
224-
225219
//! Check if pruning is enabled.
226220
virtual bool getPruneMode() = 0;
227221

src/interfaces/node.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ class NodeImpl : public Node
207207
}
208208
}
209209
bool getNetworkActive() override { return g_connman && g_connman->GetNetworkActive(); }
210-
CAmount getMaxTxFee() override { return ::maxTxFee; }
211210
CFeeRate estimateSmartFee(int num_blocks, bool conservative, int* returned_target = nullptr) override
212211
{
213212
FeeCalculation fee_calc;

src/interfaces/node.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,6 @@ class Node
159159
//! Get network active.
160160
virtual bool getNetworkActive() = 0;
161161

162-
//! Get max tx fee.
163-
virtual CAmount getMaxTxFee() = 0;
164-
165162
//! Estimate smart fee.
166163
virtual CFeeRate estimateSmartFee(int num_blocks, bool conservative, int* returned_target = nullptr) = 0;
167164

src/interfaces/wallet.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ class WalletImpl : public Wallet
464464
bool IsWalletFlagSet(uint64_t flag) override { return m_wallet->IsWalletFlagSet(flag); }
465465
OutputType getDefaultAddressType() override { return m_wallet->m_default_address_type; }
466466
OutputType getDefaultChangeType() override { return m_wallet->m_default_change_type; }
467+
CAmount getDefaultMaxTxFee() override { return m_wallet->m_default_max_tx_fee; }
467468
void remove() override
468469
{
469470
RemoveWallet(m_wallet);

src/interfaces/wallet.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,9 @@ class Wallet
247247
// Get default change type.
248248
virtual OutputType getDefaultChangeType() = 0;
249249

250+
//! Get max tx fee.
251+
virtual CAmount getDefaultMaxTxFee() = 0;
252+
250253
// Remove wallet.
251254
virtual void remove() = 0;
252255

src/qt/sendcoinsdialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ void SendCoinsDialog::processSendCoinsReturn(const WalletModel::SendCoinsReturn
578578
msgParams.second = CClientUIInterface::MSG_ERROR;
579579
break;
580580
case WalletModel::AbsurdFee:
581-
msgParams.first = tr("A fee higher than %1 is considered an absurdly high fee.").arg(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), model->node().getMaxTxFee()));
581+
msgParams.first = tr("A fee higher than %1 is considered an absurdly high fee.").arg(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), model->wallet().getDefaultMaxTxFee()));
582582
break;
583583
case WalletModel::PaymentRequestExpired:
584584
msgParams.first = tr("Payment request expired.");

src/qt/walletmodel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,9 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact
222222
}
223223

224224
// reject absurdly high fee. (This can never happen because the
225-
// wallet caps the fee at maxTxFee. This merely serves as a
225+
// wallet caps the fee at m_default_max_tx_fee. This merely serves as a
226226
// belt-and-suspenders check)
227-
if (nFeeRequired > m_node.getMaxTxFee())
227+
if (nFeeRequired > m_wallet->getDefaultMaxTxFee())
228228
return AbsurdFee;
229229
}
230230

0 commit comments

Comments
 (0)