CoinControl: add option for custom confirmation target
This commit is contained in:
parent
fea5e05a63
commit
004168dcb7
2 changed files with 10 additions and 2 deletions
|
@ -22,6 +22,8 @@ public:
|
||||||
bool fOverrideFeeRate;
|
bool fOverrideFeeRate;
|
||||||
//! Feerate to use if overrideFeeRate is true
|
//! Feerate to use if overrideFeeRate is true
|
||||||
CFeeRate nFeeRate;
|
CFeeRate nFeeRate;
|
||||||
|
//! Override the default confirmation target, 0 = use default
|
||||||
|
int nConfirmTarget;
|
||||||
|
|
||||||
CCoinControl()
|
CCoinControl()
|
||||||
{
|
{
|
||||||
|
@ -37,6 +39,7 @@ public:
|
||||||
nMinimumTotalFee = 0;
|
nMinimumTotalFee = 0;
|
||||||
nFeeRate = CFeeRate(0);
|
nFeeRate = CFeeRate(0);
|
||||||
fOverrideFeeRate = false;
|
fOverrideFeeRate = false;
|
||||||
|
nConfirmTarget = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HasSelected() const
|
bool HasSelected() const
|
||||||
|
|
|
@ -2433,17 +2433,22 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
|
||||||
|
|
||||||
dPriority = wtxNew.ComputePriority(dPriority, nBytes);
|
dPriority = wtxNew.ComputePriority(dPriority, nBytes);
|
||||||
|
|
||||||
|
// Allow to override the default confirmation target over the CoinControl instance
|
||||||
|
int currentConfirmationTarget = nTxConfirmTarget;
|
||||||
|
if (coinControl && coinControl->nConfirmTarget > 0)
|
||||||
|
currentConfirmationTarget = coinControl->nConfirmTarget;
|
||||||
|
|
||||||
// Can we complete this as a free transaction?
|
// Can we complete this as a free transaction?
|
||||||
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.estimateSmartPriority(nTxConfirmTarget);
|
double dPriorityNeeded = mempool.estimateSmartPriority(currentConfirmationTarget);
|
||||||
// Require at least hard-coded AllowFree.
|
// Require at least hard-coded AllowFree.
|
||||||
if (dPriority >= dPriorityNeeded && AllowFree(dPriority))
|
if (dPriority >= dPriorityNeeded && AllowFree(dPriority))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAmount nFeeNeeded = GetMinimumFee(nBytes, nTxConfirmTarget, mempool);
|
CAmount nFeeNeeded = GetMinimumFee(nBytes, currentConfirmationTarget, mempool);
|
||||||
if (coinControl && nFeeNeeded > 0 && coinControl->nMinimumTotalFee > nFeeNeeded) {
|
if (coinControl && nFeeNeeded > 0 && coinControl->nMinimumTotalFee > nFeeNeeded) {
|
||||||
nFeeNeeded = coinControl->nMinimumTotalFee;
|
nFeeNeeded = coinControl->nMinimumTotalFee;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue