New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[wallet] Move maxtxfee from node to wallet #15778
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,8 @@ void WalletInit::AddWalletOptions() const | |
gArgs.AddArg("-fallbackfee=<amt>", 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=<n>", strprintf("Set key pool size to <n> (default: %u)", DEFAULT_KEYPOOL_SIZE), false, OptionsCategory::WALLET); | ||
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)", | ||
CURRENCY_UNIT, FormatMoney(DEFAULT_TRANSACTION_MAXFEE)), false, OptionsCategory::DEBUG_TEST); | ||
gArgs.AddArg("-mintxfee=<amt>", strprintf("Fees (in %s/kB) smaller than this are considered zero fee for transaction creation (default: %s)", | ||
CURRENCY_UNIT, FormatMoney(DEFAULT_TRANSACTION_MINFEE)), false, OptionsCategory::WALLET); | ||
gArgs.AddArg("-paytxfee=<amt>", strprintf("Fee (in %s/kB) to add to transactions you send (default: %s)", | ||
|
@@ -124,10 +126,6 @@ bool WalletInit::ParameterInteraction() const | |
if (gArgs.GetArg("-prune", 0) && gArgs.GetBoolArg("-rescan", false)) | ||
return InitError(_("Rescans are not possible in pruned mode. You will need to use -reindex which will download the whole blockchain again.")); | ||
|
||
if (::minRelayTxFee.GetFeePerK() > HIGH_TX_FEE_PER_KB) | ||
InitWarning(AmountHighWarn("-minrelaytxfee") + " " + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can see how it makes sense to disable this particular warning about the But would it make sense to to keep some warning about really high -minrelaytxfee settings even in non-wallet builds? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The warning was added as a wallet warning in #8486. This PR is meant to be a pure refactor (except for the updated log message) so I'm not going to add the suggested new warning for a high There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. EDIT: these warnings will now show for each wallet at startup rather than just once for the node, so that's also a minor behaviour change when starting with multiple wallets. |
||
_("The wallet will avoid paying less than the minimum relay fee.")); | ||
|
||
return true; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4204,6 +4204,29 @@ std::shared_ptr<CWallet> CWallet::CreateWalletFromFile(interfaces::Chain& chain, | |
return nullptr; | ||
} | ||
} | ||
|
||
if (gArgs.IsArgSet("-maxtxfee")) | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. μ-nit: bracket There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Didn't catch this when moving the code from init.cpp. Sorry! |
||
CAmount nMaxFee = 0; | ||
if (!ParseMoney(gArgs.GetArg("-maxtxfee", ""), nMaxFee)) { | ||
chain.initError(AmountErrMsg("maxtxfee", gArgs.GetArg("-maxtxfee", ""))); | ||
return nullptr; | ||
} | ||
if (nMaxFee > HIGH_MAX_TX_FEE) { | ||
chain.initWarning(_("-maxtxfee is set very high! Fees this large could be paid on a single transaction.")); | ||
} | ||
if (CFeeRate(nMaxFee, 1000) < chain.relayMinFee()) { | ||
chain.initError(strprintf(_("Invalid amount for -maxtxfee=<amount>: '%s' (must be at least the minrelay fee of %s to prevent stuck transactions)"), | ||
gArgs.GetArg("-maxtxfee", ""), chain.relayMinFee().ToString())); | ||
return nullptr; | ||
} | ||
walletInstance->m_default_max_tx_fee = nMaxFee; | ||
} | ||
|
||
if (chain.relayMinFee().GetFeePerK() > HIGH_TX_FEE_PER_KB) | ||
chain.initWarning(AmountHighWarn("-minrelaytxfee") + " " + | ||
_("The wallet will avoid paying less than the minimum relay fee.")); | ||
|
||
walletInstance->m_confirm_target = gArgs.GetArg("-txconfirmtarget", DEFAULT_TX_CONFIRM_TARGET); | ||
walletInstance->m_spend_zero_conf_change = gArgs.GetBoolArg("-spendzeroconfchange", DEFAULT_SPEND_ZEROCONF_CHANGE); | ||
walletInstance->m_signal_rbf = gArgs.GetBoolArg("-walletrbf", DEFAULT_WALLET_RBF); | ||
|
@@ -4394,7 +4417,7 @@ bool CWalletTx::AcceptToMemoryPool(interfaces::Chain::Lock& locked_chain, CValid | |
// user could call sendmoney in a loop and hit spurious out of funds errors | ||
// because we think that this newly generated transaction's change is | ||
// unavailable as we're not yet aware that it is in the mempool. | ||
bool ret = locked_chain.submitToMemoryPool(tx, pwallet->chain().maxTxFee(), state); | ||
bool ret = locked_chain.submitToMemoryPool(tx, pwallet->m_default_max_tx_fee, state); | ||
fInMempool |= ret; | ||
return ret; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is another change in behavior that might be worth noting in the commit message or release notes: that specifiying -maxtxfee will now result in an error in non-wallet builds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is true. Doesn't defining
-maxtxfee
in dummywallet.cpp ensure that there's no error?I can change this so there is an error, which would effectively alert users that the
-maxtxfee
setting is not used in non-wallet builds.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re: #15778 (comment)
You're right, I just didn't pay attention to the dummywallet change. I think it probably shouldn't be an error to specify -maxtxfee, based on the way other wallet options are handled, though I could see reasons for doing it either way.