| 2566 | } |
| 2567 | |
| 2568 | bool CWallet::SelectCoinsDark(CAmount nValueMin, CAmount nValueMax, std::vector<CTxIn>& setCoinsRet, CAmount& nValueRet, int nDarksendRoundsMin, int nDarksendRoundsMax) const |
| 2569 | { |
| 2570 | CCoinControl* coinControl = NULL; |
| 2571 | |
| 2572 | setCoinsRet.clear(); |
| 2573 | nValueRet = 0; |
| 2574 | |
| 2575 | vector<COutput> vCoins; |
| 2576 | AvailableCoins(vCoins, true, coinControl, false, nDarksendRoundsMin < 0 ? ONLY_NONDENOMINATED_NOTMN : ONLY_DENOMINATED); |
| 2577 | |
| 2578 | set<pair<const CWalletTx*, unsigned int> > setCoinsRet2; |
| 2579 | |
| 2580 | //order the array so largest nondenom are first, then denominations, then very small inputs. |
| 2581 | sort(vCoins.rbegin(), vCoins.rend(), CompareByPriority()); |
| 2582 | |
| 2583 | //the first thing we get is a fee input, then we'll use as many denominated as possible. then the rest |
| 2584 | for (const COutput& out : vCoins) { |
| 2585 | //there's no reason to allow inputs less than 1 COIN into DS (other than denominations smaller than that amount) |
| 2586 | if (out.tx->vout[out.i].nValue < 1*COIN && out.tx->vout[out.i].nValue != (.1*COIN)+100) continue; |
| 2587 | if (fMasterNode && out.tx->vout[out.i].nValue == GetMNCollateral(chainActive.Height()) * COIN) continue; //masternode input |
| 2588 | |
| 2589 | if (nValueRet + out.tx->vout[out.i].nValue <= nValueMax) { |
| 2590 | CTxIn vin = CTxIn(out.tx->GetHash(), out.i); |
| 2591 | |
| 2592 | int rounds = GetInputDarksendRounds(vin); |
| 2593 | if (rounds >= nDarksendRoundsMax) continue; |
| 2594 | if (rounds < nDarksendRoundsMin) continue; |
| 2595 | |
| 2596 | vin.prevPubKey = out.tx->vout[out.i].scriptPubKey; // the inputs PubKey |
| 2597 | nValueRet += out.tx->vout[out.i].nValue; |
| 2598 | setCoinsRet.push_back(vin); |
| 2599 | setCoinsRet2.insert(make_pair(out.tx, out.i)); |
| 2600 | } |
| 2601 | } |
| 2602 | |
| 2603 | // if it's more than min, we're good to return |
| 2604 | if (nValueRet >= nValueMin) return true; |
| 2605 | |
| 2606 | return false; |
| 2607 | } |
| 2608 | |
| 2609 | bool CWallet::SelectCoinsCollateral(std::vector<CTxIn>& setCoinsRet, int64_t& nValueRet) const |
| 2610 | { |
no test coverage detected