mirror of
https://github.com/dashpay/dash.git
synced 2024-12-28 05:23:01 +01:00
Add sane fallback for fee estimation
Add new commandline option "-fallbackfee" to use when fee estimation does not have sufficient data.
This commit is contained in:
parent
995b9f385b
commit
e420a1b15e
11
src/init.cpp
11
src/init.cpp
@ -393,6 +393,8 @@ std::string HelpMessage(HelpMessageMode mode)
|
|||||||
strUsage += HelpMessageGroup(_("Wallet options:"));
|
strUsage += HelpMessageGroup(_("Wallet options:"));
|
||||||
strUsage += HelpMessageOpt("-disablewallet", _("Do not load the wallet and disable wallet RPC calls"));
|
strUsage += HelpMessageOpt("-disablewallet", _("Do not load the wallet and disable wallet RPC calls"));
|
||||||
strUsage += HelpMessageOpt("-keypool=<n>", strprintf(_("Set key pool size to <n> (default: %u)"), DEFAULT_KEYPOOL_SIZE));
|
strUsage += HelpMessageOpt("-keypool=<n>", strprintf(_("Set key pool size to <n> (default: %u)"), DEFAULT_KEYPOOL_SIZE));
|
||||||
|
strUsage += HelpMessageOpt("-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)));
|
||||||
strUsage += HelpMessageOpt("-mintxfee=<amt>", strprintf(_("Fees (in %s/kB) smaller than this are considered zero fee for transaction creation (default: %s)"),
|
strUsage += HelpMessageOpt("-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)));
|
CURRENCY_UNIT, FormatMoney(DEFAULT_TRANSACTION_MINFEE)));
|
||||||
strUsage += HelpMessageOpt("-paytxfee=<amt>", strprintf(_("Fee (in %s/kB) to add to transactions you send (default: %s)"),
|
strUsage += HelpMessageOpt("-paytxfee=<amt>", strprintf(_("Fee (in %s/kB) to add to transactions you send (default: %s)"),
|
||||||
@ -947,6 +949,15 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
else
|
else
|
||||||
return InitError(strprintf(_("Invalid amount for -mintxfee=<amount>: '%s'"), mapArgs["-mintxfee"]));
|
return InitError(strprintf(_("Invalid amount for -mintxfee=<amount>: '%s'"), mapArgs["-mintxfee"]));
|
||||||
}
|
}
|
||||||
|
if (mapArgs.count("-fallbackfee"))
|
||||||
|
{
|
||||||
|
CAmount nFeePerK = 0;
|
||||||
|
if (!ParseMoney(mapArgs["-fallbackfee"], nFeePerK))
|
||||||
|
return InitError(strprintf(_("Invalid amount for -fallbackfee=<amount>: '%s'"), mapArgs["-fallbackfee"]));
|
||||||
|
if (nFeePerK > nHighTransactionFeeWarning)
|
||||||
|
InitWarning(_("-fallbackfee is set very high! This is the transaction fee you may pay when fee estimates are not available."));
|
||||||
|
CWallet::fallbackFee = CFeeRate(nFeePerK);
|
||||||
|
}
|
||||||
if (mapArgs.count("-paytxfee"))
|
if (mapArgs.count("-paytxfee"))
|
||||||
{
|
{
|
||||||
CAmount nFeePerK = 0;
|
CAmount nFeePerK = 0;
|
||||||
|
@ -640,13 +640,15 @@ void SendCoinsDialog::updateSmartFeeLabel()
|
|||||||
CFeeRate feeRate = mempool.estimateSmartFee(nBlocksToConfirm, &estimateFoundAtBlocks);
|
CFeeRate feeRate = mempool.estimateSmartFee(nBlocksToConfirm, &estimateFoundAtBlocks);
|
||||||
if (feeRate <= CFeeRate(0)) // not enough data => minfee
|
if (feeRate <= CFeeRate(0)) // not enough data => minfee
|
||||||
{
|
{
|
||||||
ui->labelSmartFee->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), CWallet::GetRequiredFee(1000)) + "/kB");
|
ui->labelSmartFee->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(),
|
||||||
|
std::max(CWallet::fallbackFee.GetFeePerK(), CWallet::GetRequiredFee(1000))) + "/kB");
|
||||||
ui->labelSmartFee2->show(); // (Smart fee not initialized yet. This usually takes a few blocks...)
|
ui->labelSmartFee2->show(); // (Smart fee not initialized yet. This usually takes a few blocks...)
|
||||||
ui->labelFeeEstimation->setText("");
|
ui->labelFeeEstimation->setText("");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui->labelSmartFee->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), feeRate.GetFeePerK()) + "/kB");
|
ui->labelSmartFee->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(),
|
||||||
|
std::max(feeRate.GetFeePerK(), CWallet::GetRequiredFee(1000))) + "/kB");
|
||||||
ui->labelSmartFee2->hide();
|
ui->labelSmartFee2->hide();
|
||||||
ui->labelFeeEstimation->setText(tr("Estimated to begin confirmation within %n block(s).", "", estimateFoundAtBlocks));
|
ui->labelFeeEstimation->setText(tr("Estimated to begin confirmation within %n block(s).", "", estimateFoundAtBlocks));
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,12 @@ bool fSendFreeTransactions = DEFAULT_SEND_FREE_TRANSACTIONS;
|
|||||||
* Override with -mintxfee
|
* Override with -mintxfee
|
||||||
*/
|
*/
|
||||||
CFeeRate CWallet::minTxFee = CFeeRate(DEFAULT_TRANSACTION_MINFEE);
|
CFeeRate CWallet::minTxFee = CFeeRate(DEFAULT_TRANSACTION_MINFEE);
|
||||||
|
/**
|
||||||
|
* If fee estimation does not have enough data to provide estimates, use this fee instead.
|
||||||
|
* Has no effect if not using fee estimation
|
||||||
|
* Override with -fallbackfee
|
||||||
|
*/
|
||||||
|
CFeeRate CWallet::fallbackFee = CFeeRate(DEFAULT_FALLBACK_FEE);
|
||||||
|
|
||||||
/** @defgroup mapWallet
|
/** @defgroup mapWallet
|
||||||
*
|
*
|
||||||
@ -2223,6 +2229,9 @@ CAmount CWallet::GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarge
|
|||||||
if (nFeeNeeded == 0) {
|
if (nFeeNeeded == 0) {
|
||||||
int estimateFoundTarget = nConfirmTarget;
|
int estimateFoundTarget = nConfirmTarget;
|
||||||
nFeeNeeded = pool.estimateSmartFee(nConfirmTarget, &estimateFoundTarget).GetFee(nTxBytes);
|
nFeeNeeded = pool.estimateSmartFee(nConfirmTarget, &estimateFoundTarget).GetFee(nTxBytes);
|
||||||
|
// ... unless we don't have enough mempool data for estimatefee, then use fallbackFee
|
||||||
|
if (nFeeNeeded == 0)
|
||||||
|
nFeeNeeded = fallbackFee.GetFee(nTxBytes);
|
||||||
}
|
}
|
||||||
// prevent user from paying a fee below minRelayTxFee or minTxFee
|
// prevent user from paying a fee below minRelayTxFee or minTxFee
|
||||||
nFeeNeeded = std::max(nFeeNeeded, GetRequiredFee(nTxBytes));
|
nFeeNeeded = std::max(nFeeNeeded, GetRequiredFee(nTxBytes));
|
||||||
|
@ -41,6 +41,8 @@ static const unsigned int DEFAULT_KEYPOOL_SIZE = 100;
|
|||||||
static const CAmount DEFAULT_TRANSACTION_FEE = 0;
|
static const CAmount DEFAULT_TRANSACTION_FEE = 0;
|
||||||
//! -paytxfee will warn if called with a higher fee than this amount (in satoshis) per KB
|
//! -paytxfee will warn if called with a higher fee than this amount (in satoshis) per KB
|
||||||
static const CAmount nHighTransactionFeeWarning = 0.01 * COIN;
|
static const CAmount nHighTransactionFeeWarning = 0.01 * COIN;
|
||||||
|
//! -fallbackfee default
|
||||||
|
static const CAmount DEFAULT_FALLBACK_FEE = 20000;
|
||||||
//! -mintxfee default
|
//! -mintxfee default
|
||||||
static const CAmount DEFAULT_TRANSACTION_MINFEE = 1000;
|
static const CAmount DEFAULT_TRANSACTION_MINFEE = 1000;
|
||||||
//! -maxtxfee default
|
//! -maxtxfee default
|
||||||
@ -666,6 +668,7 @@ public:
|
|||||||
bool AddAccountingEntry(const CAccountingEntry&, CWalletDB & pwalletdb);
|
bool AddAccountingEntry(const CAccountingEntry&, CWalletDB & pwalletdb);
|
||||||
|
|
||||||
static CFeeRate minTxFee;
|
static CFeeRate minTxFee;
|
||||||
|
static CFeeRate fallbackFee;
|
||||||
/**
|
/**
|
||||||
* Estimate the minimum fee considering user set parameters
|
* Estimate the minimum fee considering user set parameters
|
||||||
* and the required fee
|
* and the required fee
|
||||||
|
Loading…
Reference in New Issue
Block a user