Skip to content

Commit d6cc6a1

Browse files
author
João Barbosa
committed
Use CCoinControl selection in CWallet::FundTransaction
1 parent 87d6562 commit d6cc6a1

File tree

3 files changed

+5
-15
lines changed

3 files changed

+5
-15
lines changed

src/coincontrol.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,9 @@ class CCoinControl
3838
return (setSelected.size() > 0);
3939
}
4040

41-
bool IsSelected(const uint256& hash, unsigned int n) const
41+
bool IsSelected(const COutPoint& output) const
4242
{
43-
COutPoint outpt(hash, n);
44-
return (setSelected.count(outpt) > 0);
43+
return (setSelected.count(output) > 0);
4544
}
4645

4746
void Select(const COutPoint& output)

src/qt/coincontroldialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ void CoinControlDialog::updateView()
796796
}
797797

798798
// set checkbox
799-
if (coinControl->IsSelected(txhash, out.i))
799+
if (coinControl->IsSelected(COutPoint(txhash, out.i)))
800800
itemOutput->setCheckState(COLUMN_CHECKBOX, Qt::Checked);
801801
}
802802

src/wallet/wallet.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,7 +1669,7 @@ void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const
16691669
isminetype mine = IsMine(pcoin->vout[i]);
16701670
if (!(IsSpent(wtxid, i)) && mine != ISMINE_NO &&
16711671
!IsLockedCoin((*it).first, i) && (pcoin->vout[i].nValue > 0 || fIncludeZeroValue) &&
1672-
(!coinControl || !coinControl->HasSelected() || coinControl->fAllowOtherInputs || coinControl->IsSelected((*it).first, i)))
1672+
(!coinControl || !coinControl->HasSelected() || coinControl->fAllowOtherInputs || coinControl->IsSelected(COutPoint((*it).first, i))))
16731673
vCoins.push_back(COutput(pcoin, i, nDepth,
16741674
((mine & ISMINE_SPENDABLE) != ISMINE_NO) ||
16751675
(coinControl && coinControl->fAllowWatchOnly && (mine & ISMINE_WATCH_SOLVABLE) != ISMINE_NO)));
@@ -1927,16 +1927,7 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount &nFeeRet, int& nC
19271927
// Add new txins (keeping original txin scriptSig/order)
19281928
BOOST_FOREACH(const CTxIn& txin, wtx.vin)
19291929
{
1930-
bool found = false;
1931-
BOOST_FOREACH(const CTxIn& origTxIn, tx.vin)
1932-
{
1933-
if (txin.prevout.hash == origTxIn.prevout.hash && txin.prevout.n == origTxIn.prevout.n)
1934-
{
1935-
found = true;
1936-
break;
1937-
}
1938-
}
1939-
if (!found)
1930+
if (!coinControl.IsSelected(txin.prevout))
19401931
tx.vin.push_back(txin);
19411932
}
19421933

0 commit comments

Comments
 (0)