diff --git a/src/wallet.cpp b/src/wallet.cpp index a05599c106..276ca7a94e 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -1662,8 +1662,29 @@ bool CWallet::SelectCoins(const CAmount& nTargetValue, set vCoins; AvailableCoins(vCoins, true, coinControl, coin_type, useIX); + // coin control -> return all selected outputs (we want all selected to go into the transaction for sure) + if (coinControl && coinControl->HasSelected()) + { + BOOST_FOREACH(const COutput& out, vCoins) + { + if(!out.fSpendable) + continue; + + if(coin_type == ONLY_DENOMINATED) { + CTxIn vin = CTxIn(out.tx->GetHash(),out.i); + int rounds = GetInputDarksendRounds(vin); + // make sure it's actually anonymized + if(rounds < nDarksendRounds) continue; + } + + nValueRet += out.tx->vout[out.i].nValue; + setCoinsRet.insert(make_pair(out.tx, out.i)); + } + return (nValueRet >= nTargetValue); + } + //if we're doing only denominated, we need to round up to the nearest .1DRK - if(coin_type == ONLY_DENOMINATED){ + if(coin_type == ONLY_DENOMINATED) { // Make outputs by looping through denominations, from large to small BOOST_FOREACH(int64_t v, darkSendDenominations) { @@ -1684,19 +1705,6 @@ bool CWallet::SelectCoins(const CAmount& nTargetValue, set= nTargetValue); } - // coin control -> return all selected outputs (we want all selected to go into the transaction for sure) - if (coinControl && coinControl->HasSelected()) - { - BOOST_FOREACH(const COutput& out, vCoins) - { - if(!out.fSpendable) - continue; - nValueRet += out.tx->vout[out.i].nValue; - setCoinsRet.insert(make_pair(out.tx, out.i)); - } - return (nValueRet >= nTargetValue); - } - return (SelectCoinsMinConf(nTargetValue, 1, 6, vCoins, setCoinsRet, nValueRet) || SelectCoinsMinConf(nTargetValue, 1, 1, vCoins, setCoinsRet, nValueRet) || (bSpendZeroConfChange && SelectCoinsMinConf(nTargetValue, 0, 1, vCoins, setCoinsRet, nValueRet)));