src/wallet.cpp
// Select some coins without random shuffle or best subset approximation
Select some coins without random shuffle or best subset approximation
Select some coins without random shuffle or best subset approximation
bool CWallet::SelectCoinsSimple(int64_t nTargetValue, unsigned int nSpendTime, int nMinConf,
                                set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet) const
{
    vector<COutput> vCoins;
    AvailableCoinsMinConf(vCoins, nMinConf);
    setCoinsRet.clear();
    nValueRet = 0;
    BOOST_FOREACH(COutput output, vCoins)
    {
        const CWalletTx *pcoin = output.tx;
        int i = output.i;
        if (nValueRet >= nTargetValue)
            break;
        if (pcoin->nTime > nSpendTime)
            continue;
        int64_t n = pcoin->vout[i].nValue;
        pair<int64_t,pair<const CWalletTx*,unsigned int> > coin = make_pair(n,make_pair(pcoin, i));
        if (n >= nTargetValue)
        {
            setCoinsRet.insert(coin.second);
            nValueRet += coin.first;
            break;
        }
        else if (n < nTargetValue + CENT)
        {
            setCoinsRet.insert(coin.second);
            nValueRet += coin.first;
        }
    }
    return true;
}
bool CWallet :: SelectCoinsSimple ( int64_t nTargetValue , unsigned int nSpendTime , int nMinConf , set < pair < const CWalletTx * , unsigned int > > & setCoinsRet , int64_t & nValueRet ) const { vector < COutput > vCoins ; AvailableCoinsMinConf ( vCoins , nMinConf ) ; setCoinsRet . clear ( ) ; nValueRet = 0 ; BOOST_FOREACH ( COutput output , vCoins ) { const CWalletTx * pcoin = output . tx ; int i = output . i ; if ( nValueRet >= nTargetValue ) break ; if ( pcoin -> nTime > nSpendTime ) continue ; int64_t n = pcoin -> vout [ i ] . nValue ; pair < int64_t , pair < const CWalletTx * , unsigned int > > coin = make_pair ( n , make_pair ( pcoin , i ) ) ; if ( n >= nTargetValue ) { setCoinsRet . insert ( coin . second ) ; nValueRet += coin . first ; break ; } else if ( n < nTargetValue + CENT ) { setCoinsRet . insert ( coin . second ) ; nValueRet += coin . first ; } } return true ; }
Select some coins without random shuffle or best subset approximation
Select some coins without random shuffle or best subset approximation
// Stop if we've chosen enough inputs // Follow the timestamp rules // If input value is greater or equal to target then simply insert //    it into the current subset and exit