mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 21:12:48 +01:00
Change wallet and GUI code to use new smart fee estimation calls.
This commit is contained in:
parent
22eca7da22
commit
4fe28236c0
@ -538,7 +538,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
|
|||||||
nBytes = nBytesInputs + ((CoinControlDialog::payAmounts.size() > 0 ? CoinControlDialog::payAmounts.size() + 1 : 2) * 34) + 10; // always assume +1 output for change here
|
nBytes = nBytesInputs + ((CoinControlDialog::payAmounts.size() > 0 ? CoinControlDialog::payAmounts.size() + 1 : 2) * 34) + 10; // always assume +1 output for change here
|
||||||
|
|
||||||
// Priority
|
// Priority
|
||||||
double mempoolEstimatePriority = mempool.estimatePriority(nTxConfirmTarget);
|
double mempoolEstimatePriority = mempool.estimateSmartPriority(nTxConfirmTarget);
|
||||||
dPriority = dPriorityInputs / (nBytes - nBytesInputs + (nQuantityUncompressed * 29)); // 29 = 180 - 151 (uncompressed public keys are over the limit. max 151 bytes of the input are ignored for priority)
|
dPriority = dPriorityInputs / (nBytes - nBytesInputs + (nQuantityUncompressed * 29)); // 29 = 180 - 151 (uncompressed public keys are over the limit. max 151 bytes of the input are ignored for priority)
|
||||||
sPriorityLabel = CoinControlDialog::getPriorityLabel(dPriority, mempoolEstimatePriority);
|
sPriorityLabel = CoinControlDialog::getPriorityLabel(dPriority, mempoolEstimatePriority);
|
||||||
|
|
||||||
@ -550,10 +550,8 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
|
|||||||
// Fee
|
// Fee
|
||||||
nPayFee = CWallet::GetMinimumFee(nBytes, nTxConfirmTarget, mempool);
|
nPayFee = CWallet::GetMinimumFee(nBytes, nTxConfirmTarget, mempool);
|
||||||
|
|
||||||
// Allow free?
|
// Allow free? (require at least hard-coded threshold and default to that if no estimate)
|
||||||
double dPriorityNeeded = mempoolEstimatePriority;
|
double dPriorityNeeded = std::max(mempoolEstimatePriority, AllowFreeThreshold());
|
||||||
if (dPriorityNeeded <= 0)
|
|
||||||
dPriorityNeeded = AllowFreeThreshold(); // not enough data, back to hard-coded
|
|
||||||
fAllowFree = (dPriority >= dPriorityNeeded);
|
fAllowFree = (dPriority >= dPriorityNeeded);
|
||||||
|
|
||||||
if (fSendFreeTransactions)
|
if (fSendFreeTransactions)
|
||||||
@ -649,8 +647,9 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
|
|||||||
double dFeeVary;
|
double dFeeVary;
|
||||||
if (payTxFee.GetFeePerK() > 0)
|
if (payTxFee.GetFeePerK() > 0)
|
||||||
dFeeVary = (double)std::max(CWallet::GetRequiredFee(1000), payTxFee.GetFeePerK()) / 1000;
|
dFeeVary = (double)std::max(CWallet::GetRequiredFee(1000), payTxFee.GetFeePerK()) / 1000;
|
||||||
else
|
else {
|
||||||
dFeeVary = (double)std::max(CWallet::GetRequiredFee(1000), mempool.estimateFee(nTxConfirmTarget).GetFeePerK()) / 1000;
|
dFeeVary = (double)std::max(CWallet::GetRequiredFee(1000), mempool.estimateSmartFee(nTxConfirmTarget).GetFeePerK()) / 1000;
|
||||||
|
}
|
||||||
QString toolTip4 = tr("Can vary +/- %1 satoshi(s) per input.").arg(dFeeVary);
|
QString toolTip4 = tr("Can vary +/- %1 satoshi(s) per input.").arg(dFeeVary);
|
||||||
|
|
||||||
l3->setToolTip(toolTip4);
|
l3->setToolTip(toolTip4);
|
||||||
@ -686,7 +685,7 @@ void CoinControlDialog::updateView()
|
|||||||
QFlags<Qt::ItemFlag> flgTristate = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsTristate;
|
QFlags<Qt::ItemFlag> flgTristate = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsTristate;
|
||||||
|
|
||||||
int nDisplayUnit = model->getOptionsModel()->getDisplayUnit();
|
int nDisplayUnit = model->getOptionsModel()->getDisplayUnit();
|
||||||
double mempoolEstimatePriority = mempool.estimatePriority(nTxConfirmTarget);
|
double mempoolEstimatePriority = mempool.estimateSmartPriority(nTxConfirmTarget);
|
||||||
|
|
||||||
std::map<QString, std::vector<COutput> > mapCoins;
|
std::map<QString, std::vector<COutput> > mapCoins;
|
||||||
model->listCoins(mapCoins);
|
model->listCoins(mapCoins);
|
||||||
|
@ -633,7 +633,8 @@ void SendCoinsDialog::updateSmartFeeLabel()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
int nBlocksToConfirm = defaultConfirmTarget - ui->sliderSmartFee->value();
|
int nBlocksToConfirm = defaultConfirmTarget - ui->sliderSmartFee->value();
|
||||||
CFeeRate feeRate = mempool.estimateFee(nBlocksToConfirm);
|
int estimateFoundAtBlocks = nBlocksToConfirm;
|
||||||
|
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(), CWallet::GetRequiredFee(1000)) + "/kB");
|
||||||
@ -644,7 +645,7 @@ void SendCoinsDialog::updateSmartFeeLabel()
|
|||||||
{
|
{
|
||||||
ui->labelSmartFee->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), feeRate.GetFeePerK()) + "/kB");
|
ui->labelSmartFee->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), feeRate.GetFeePerK()) + "/kB");
|
||||||
ui->labelSmartFee2->hide();
|
ui->labelSmartFee2->hide();
|
||||||
ui->labelFeeEstimation->setText(tr("Estimated to begin confirmation within %n block(s).", "", nBlocksToConfirm));
|
ui->labelFeeEstimation->setText(tr("Estimated to begin confirmation within %n block(s).", "", estimateFoundAtBlocks));
|
||||||
}
|
}
|
||||||
|
|
||||||
updateFeeMinimizedLabel();
|
updateFeeMinimizedLabel();
|
||||||
|
@ -2033,14 +2033,10 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
|
|||||||
if (fSendFreeTransactions && nBytes <= MAX_FREE_TRANSACTION_CREATE_SIZE)
|
if (fSendFreeTransactions && nBytes <= MAX_FREE_TRANSACTION_CREATE_SIZE)
|
||||||
{
|
{
|
||||||
// Not enough fee: enough priority?
|
// Not enough fee: enough priority?
|
||||||
double dPriorityNeeded = mempool.estimatePriority(nTxConfirmTarget);
|
double dPriorityNeeded = mempool.estimateSmartPriority(nTxConfirmTarget);
|
||||||
// Not enough mempool history to estimate: use hard-coded AllowFree.
|
// Require at least hard-coded AllowFree.
|
||||||
if (dPriorityNeeded <= 0 && AllowFree(dPriority))
|
if (dPriority >= dPriorityNeeded && AllowFree(dPriority))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Small enough, and priority high enough, to send for free
|
|
||||||
if (dPriorityNeeded > 0 && dPriority >= dPriorityNeeded)
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CAmount nFeeNeeded = GetMinimumFee(nBytes, nTxConfirmTarget, mempool);
|
CAmount nFeeNeeded = GetMinimumFee(nBytes, nTxConfirmTarget, mempool);
|
||||||
@ -2131,12 +2127,14 @@ CAmount CWallet::GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarge
|
|||||||
if (fPayAtLeastCustomFee && nFeeNeeded > 0 && nFeeNeeded < payTxFee.GetFeePerK())
|
if (fPayAtLeastCustomFee && nFeeNeeded > 0 && nFeeNeeded < payTxFee.GetFeePerK())
|
||||||
nFeeNeeded = payTxFee.GetFeePerK();
|
nFeeNeeded = payTxFee.GetFeePerK();
|
||||||
// User didn't set: use -txconfirmtarget to estimate...
|
// User didn't set: use -txconfirmtarget to estimate...
|
||||||
if (nFeeNeeded == 0)
|
if (nFeeNeeded == 0) {
|
||||||
nFeeNeeded = pool.estimateFee(nConfirmTarget).GetFee(nTxBytes);
|
int estimateFoundTarget = nConfirmTarget;
|
||||||
// ... unless we don't have enough mempool data, in which case fall
|
nFeeNeeded = pool.estimateSmartFee(nConfirmTarget, &estimateFoundTarget).GetFee(nTxBytes);
|
||||||
// back to the required fee
|
// ... unless we don't have enough mempool data for our desired target
|
||||||
if (nFeeNeeded == 0)
|
// so we make sure we're paying at least minTxFee
|
||||||
nFeeNeeded = GetRequiredFee(nTxBytes);
|
if (nFeeNeeded == 0 || (unsigned int)estimateFoundTarget > nConfirmTarget)
|
||||||
|
nFeeNeeded = std::max(nFeeNeeded, GetRequiredFee(nTxBytes));
|
||||||
|
}
|
||||||
// prevent user from paying a non-sense fee (like 1 satoshi): 0 < fee < minRelayFee
|
// prevent user from paying a non-sense fee (like 1 satoshi): 0 < fee < minRelayFee
|
||||||
if (nFeeNeeded < ::minRelayTxFee.GetFee(nTxBytes))
|
if (nFeeNeeded < ::minRelayTxFee.GetFee(nTxBytes))
|
||||||
nFeeNeeded = ::minRelayTxFee.GetFee(nTxBytes);
|
nFeeNeeded = ::minRelayTxFee.GetFee(nTxBytes);
|
||||||
|
Loading…
Reference in New Issue
Block a user