Skip to content

Commit 004168d

Browse files
committed
CoinControl: add option for custom confirmation target
1 parent fea5e05 commit 004168d

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/wallet/coincontrol.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ class CCoinControl
2222
bool fOverrideFeeRate;
2323
//! Feerate to use if overrideFeeRate is true
2424
CFeeRate nFeeRate;
25+
//! Override the default confirmation target, 0 = use default
26+
int nConfirmTarget;
2527

2628
CCoinControl()
2729
{
@@ -37,6 +39,7 @@ class CCoinControl
3739
nMinimumTotalFee = 0;
3840
nFeeRate = CFeeRate(0);
3941
fOverrideFeeRate = false;
42+
nConfirmTarget = 0;
4043
}
4144

4245
bool HasSelected() const

src/wallet/wallet.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2433,17 +2433,22 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
24332433

24342434
dPriority = wtxNew.ComputePriority(dPriority, nBytes);
24352435

2436+
// Allow to override the default confirmation target over the CoinControl instance
2437+
int currentConfirmationTarget = nTxConfirmTarget;
2438+
if (coinControl && coinControl->nConfirmTarget > 0)
2439+
currentConfirmationTarget = coinControl->nConfirmTarget;
2440+
24362441
// Can we complete this as a free transaction?
24372442
if (fSendFreeTransactions && nBytes <= MAX_FREE_TRANSACTION_CREATE_SIZE)
24382443
{
24392444
// Not enough fee: enough priority?
2440-
double dPriorityNeeded = mempool.estimateSmartPriority(nTxConfirmTarget);
2445+
double dPriorityNeeded = mempool.estimateSmartPriority(currentConfirmationTarget);
24412446
// Require at least hard-coded AllowFree.
24422447
if (dPriority >= dPriorityNeeded && AllowFree(dPriority))
24432448
break;
24442449
}
24452450

2446-
CAmount nFeeNeeded = GetMinimumFee(nBytes, nTxConfirmTarget, mempool);
2451+
CAmount nFeeNeeded = GetMinimumFee(nBytes, currentConfirmationTarget, mempool);
24472452
if (coinControl && nFeeNeeded > 0 && coinControl->nMinimumTotalFee > nFeeNeeded) {
24482453
nFeeNeeded = coinControl->nMinimumTotalFee;
24492454
}

0 commit comments

Comments
 (0)