src/wallet.cpp
/**
 * populate vCoins with vector of available COutputs.
 */
populate vCoins with vector of available COutputs.
populate vCoins with vector of available COutputs .
void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const CCoinControl* coinControl, bool fIncludeZeroValue, AvailableCoinsType nCoinType, bool fUseIX) const
{
    vCoins.clear();
    {
        LOCK2(cs_main, cs_wallet);
        for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) {
            const uint256& wtxid = it->first;
            const CWalletTx* pcoin = &(*it).second;
            if (!CheckFinalTx(*pcoin))
                continue;
            if (fOnlyConfirmed && !pcoin->IsTrusted())
                continue;
            if ((pcoin->IsCoinBase() || pcoin->IsCoinStake()) && pcoin->GetBlocksToMaturity() > 0)
                continue;
            int nDepth = pcoin->GetDepthInMainChain(false);
            if (fUseIX && nDepth < 6)
                continue;
            if (nDepth == 0 && !pcoin->InMempool())
                continue;
            for (unsigned int i = 0; i < pcoin->vout.size(); i++) {
                bool found = false;
                if (nCoinType == ONLY_DENOMINATED) {
                    found = IsDenominatedAmount(pcoin->vout[i].nValue);
                } else if (nCoinType == ONLY_NOT10000IFMN) {
                    found = !(fMasterNode && pcoin->vout[i].nValue == 2500 * COIN);
                } else if (nCoinType == ONLY_NONDENOMINATED_NOT10000IFMN) {
                    if (IsCollateralAmount(pcoin->vout[i].nValue)) continue; 
                    found = !IsDenominatedAmount(pcoin->vout[i].nValue);
                    if (found && fMasterNode) found = pcoin->vout[i].nValue != 2500 * COIN; 
                } else if (nCoinType == ONLY_10000) {
                    found = pcoin->vout[i].nValue == 2500 * COIN;
                } else {
                    found = true;
                }
                if (!found) continue;
                isminetype mine = IsMine(pcoin->vout[i]);
                if (!(IsSpent(wtxid, i)) && mine != ISMINE_NO &&
                    (!IsLockedCoin((*it).first, i) || nCoinType == ONLY_10000) &&
                    (pcoin->vout[i].nValue > 0 || fIncludeZeroValue) &&
                    (!coinControl || !coinControl->HasSelected() || coinControl->fAllowOtherInputs || coinControl->IsSelected((*it).first, i)))
                    vCoins.push_back(COutput(pcoin, i, nDepth,
                        ((mine & ISMINE_SPENDABLE) != ISMINE_NO) ||
                            (coinControl && coinControl->fAllowWatchOnly && (mine & ISMINE_WATCH_SOLVABLE) != ISMINE_NO)));
            }
        }
    }
}
void CWallet :: AvailableCoins ( vector < COutput > & vCoins , bool fOnlyConfirmed , const CCoinControl * coinControl , bool fIncludeZeroValue , AvailableCoinsType nCoinType , bool fUseIX ) const { vCoins . clear ( ) ; { LOCK2 ( cs_main , cs_wallet ) ; for ( map < uint256 , CWalletTx > :: const_iterator it = mapWallet . begin ( ) ; it != mapWallet . end ( ) ; ++ it ) { const uint256 & wtxid = it -> first ; const CWalletTx * pcoin = & ( * it ) . second ; if ( ! CheckFinalTx ( * pcoin ) ) continue ; if ( fOnlyConfirmed && ! pcoin -> IsTrusted ( ) ) continue ; if ( ( pcoin -> IsCoinBase ( ) || pcoin -> IsCoinStake ( ) ) && pcoin -> GetBlocksToMaturity ( ) > 0 ) continue ; int nDepth = pcoin -> GetDepthInMainChain ( false ) ; if ( fUseIX && nDepth < 6 ) continue ; if ( nDepth == 0 && ! pcoin -> InMempool ( ) ) continue ; for ( unsigned int i = 0 ; i < pcoin -> vout . size ( ) ; i ++ ) { bool found = false ; if ( nCoinType == ONLY_DENOMINATED ) { found = IsDenominatedAmount ( pcoin -> vout [ i ] . nValue ) ; } else if ( nCoinType == ONLY_NOT10000IFMN ) { found = ! ( fMasterNode && pcoin -> vout [ i ] . nValue == 2500 * COIN ) ; } else if ( nCoinType == ONLY_NONDENOMINATED_NOT10000IFMN ) { if ( IsCollateralAmount ( pcoin -> vout [ i ] . nValue ) ) continue ; found = ! IsDenominatedAmount ( pcoin -> vout [ i ] . nValue ) ; if ( found && fMasterNode ) found = pcoin -> vout [ i ] . nValue != 2500 * COIN ; } else if ( nCoinType == ONLY_10000 ) { found = pcoin -> vout [ i ] . nValue == 2500 * COIN ; } else { found = true ; } if ( ! found ) continue ; isminetype mine = IsMine ( pcoin -> vout [ i ] ) ; if ( ! ( IsSpent ( wtxid , i ) ) & & mine != ISMINE_NO && ( ! IsLockedCoin ( ( * it ) . first , i ) || nCoinType == ONLY_10000 ) && ( pcoin -> vout [ i ] . nValue > 0 || fIncludeZeroValue ) && ( ! coinControl || ! coinControl -> HasSelected ( ) || coinControl -> fAllowOtherInputs || coinControl -> IsSelected ( ( * it ) . first , i ) ) ) vCoins . push_back ( COutput ( pcoin , i , nDepth , ( ( mine & ISMINE_SPENDABLE ) != ISMINE_NO ) || ( coinControl && coinControl -> fAllowWatchOnly && ( mine & ISMINE_WATCH_SOLVABLE ) != ISMINE_NO ) ) ) ; } } } }
populate vCoins with vector of available COutputs.
populate vCoins with vector of available COutputs .
// do not use IX for inputs that have less then 6 blockchain confirmations // We should not consider coins which aren't at least in our mempool // It's possible for these to be conflicted via ancestors which we may never be able to detect // do not use collateral amounts // do not use Hot MN funds