src/wallet.cpp
void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const CCoinControl *coinControl) 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 (!IsFinalTx(*pcoin))
                continue;

            if (fOnlyConfirmed && !pcoin->IsTrusted())
                continue;

            if ((pcoin->IsCoinBase() || pcoin->IsCoinStake()) && pcoin->GetBlocksToMaturity() > 0)
                continue;

            int nDepth = pcoin->GetDepthInMainChain();
            if (nDepth < 0)
                continue;

            for (unsigned int i = 0; i < pcoin->vout.size(); i++) {
                isminetype mine = IsMine(pcoin->vout[i]);
                if (!(IsSpent(wtxid, i)) && mine != ISMINE_NO &&
                    !IsLockedCoin((*it).first, i) && pcoin->vout[i].nValue > 0 &&
                    (!coinControl || !coinControl->HasSelected() || coinControl->IsSelected((*it).first, i)))
                        vCoins.push_back(COutput(pcoin, i, nDepth, (mine & ISMINE_SPENDABLE) != ISMINE_NO));
            }
        }
    }
}
/**
 * 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) 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 (!IsFinalTx(*pcoin))
                continue;
            if (fOnlyConfirmed && !pcoin->IsTrusted())
                continue;
            if ((pcoin->IsCoinBase() || pcoin->IsCoinStake()) && pcoin->GetBlocksToMaturity() > 0)
                continue;
            int nDepth = pcoin->GetDepthInMainChain();
            if (nDepth < 0)
                continue;
            for (unsigned int i = 0; i < pcoin->vout.size(); i++) {
                isminetype mine = IsMine(pcoin->vout[i]);
                if (!(IsSpent(wtxid, i)) && mine != ISMINE_NO &&
                    !IsLockedCoin((*it).first, i) && pcoin->vout[i].nValue > 0 &&
                    (!coinControl || !coinControl->HasSelected() || coinControl->IsSelected((*it).first, i)))
                        vCoins.push_back(COutput(pcoin, i, nDepth, (mine & ISMINE_SPENDABLE) != ISMINE_NO));
            }
        }
    }
}
void CWallet :: AvailableCoins ( vector < COutput > & vCoins , bool fOnlyConfirmed , const CCoinControl * coinControl ) 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 ( ! IsFinalTx ( * pcoin ) ) continue ; if ( fOnlyConfirmed && ! pcoin -> IsTrusted ( ) ) continue ; if ( ( pcoin -> IsCoinBase ( ) || pcoin -> IsCoinStake ( ) ) && pcoin -> GetBlocksToMaturity ( ) > 0 ) continue ; int nDepth = pcoin -> GetDepthInMainChain ( ) ; if ( nDepth < 0 ) continue ; for ( unsigned int i = 0 ; i < pcoin -> vout . size ( ) ; i ++ ) { isminetype mine = IsMine ( pcoin -> vout [ i ] ) ; if ( ! ( IsSpent ( wtxid , i ) ) & & mine != ISMINE_NO && ! IsLockedCoin ( ( * it ) . first , i ) && pcoin -> vout [ i ] . nValue > 0 && ( ! coinControl || ! coinControl -> HasSelected ( ) || coinControl -> IsSelected ( ( * it ) . first , i ) ) ) vCoins . push_back ( COutput ( pcoin , i , nDepth , ( mine & ISMINE_SPENDABLE ) != ISMINE_NO ) ) ; } } } }
populate vCoins with vector of available COutputs.
populate vCoins with vector of available COutputs .