Permalink
Browse files

Merge #7506: Use CCoinControl selection in CWallet::FundTransaction

d6cc6a1 Use CCoinControl selection in CWallet::FundTransaction (João Barbosa)
  • Loading branch information...
laanwj committed Mar 24, 2016
2 parents 3ba07bd + d6cc6a1 commit b88e0b0c610a6ff1aeaab136005e1ce600c4970d
Showing with 5 additions and 15 deletions.
  1. +2 −3 src/coincontrol.h
  2. +1 −1 src/qt/coincontroldialog.cpp
  3. +2 −11 src/wallet/wallet.cpp
View
@@ -38,10 +38,9 @@ class CCoinControl
return (setSelected.size() > 0); return (setSelected.size() > 0);
} }
bool IsSelected(const uint256& hash, unsigned int n) const bool IsSelected(const COutPoint& output) const
{ {
COutPoint outpt(hash, n); return (setSelected.count(output) > 0);
return (setSelected.count(outpt) > 0);
} }
void Select(const COutPoint& output) void Select(const COutPoint& output)
@@ -796,7 +796,7 @@ void CoinControlDialog::updateView()
} }
// set checkbox // set checkbox
if (coinControl->IsSelected(txhash, out.i)) if (coinControl->IsSelected(COutPoint(txhash, out.i)))
itemOutput->setCheckState(COLUMN_CHECKBOX, Qt::Checked); itemOutput->setCheckState(COLUMN_CHECKBOX, Qt::Checked);
} }
View
@@ -1679,7 +1679,7 @@ void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const
isminetype mine = IsMine(pcoin->vout[i]); isminetype mine = IsMine(pcoin->vout[i]);
if (!(IsSpent(wtxid, i)) && mine != ISMINE_NO && if (!(IsSpent(wtxid, i)) && mine != ISMINE_NO &&
!IsLockedCoin((*it).first, i) && (pcoin->vout[i].nValue > 0 || fIncludeZeroValue) && !IsLockedCoin((*it).first, i) && (pcoin->vout[i].nValue > 0 || fIncludeZeroValue) &&
(!coinControl || !coinControl->HasSelected() || coinControl->fAllowOtherInputs || coinControl->IsSelected((*it).first, i))) (!coinControl || !coinControl->HasSelected() || coinControl->fAllowOtherInputs || coinControl->IsSelected(COutPoint((*it).first, i))))
vCoins.push_back(COutput(pcoin, i, nDepth, vCoins.push_back(COutput(pcoin, i, nDepth,
((mine & ISMINE_SPENDABLE) != ISMINE_NO) || ((mine & ISMINE_SPENDABLE) != ISMINE_NO) ||
(coinControl && coinControl->fAllowWatchOnly && (mine & ISMINE_WATCH_SOLVABLE) != ISMINE_NO))); (coinControl && coinControl->fAllowWatchOnly && (mine & ISMINE_WATCH_SOLVABLE) != ISMINE_NO)));
@@ -1936,16 +1936,7 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount &nFeeRet, int& nC
// Add new txins (keeping original txin scriptSig/order) // Add new txins (keeping original txin scriptSig/order)
BOOST_FOREACH(const CTxIn& txin, wtx.vin) BOOST_FOREACH(const CTxIn& txin, wtx.vin)
{ {
bool found = false; if (!coinControl.IsSelected(txin.prevout))
BOOST_FOREACH(const CTxIn& origTxIn, tx.vin)
{
if (txin.prevout.hash == origTxIn.prevout.hash && txin.prevout.n == origTxIn.prevout.n)
{
found = true;
break;
}
}
if (!found)
tx.vin.push_back(txin); tx.vin.push_back(txin);
} }

0 comments on commit b88e0b0

Please sign in to comment.