From 15649f727dab5e89fb94977ad9e5d35dccdd476e Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Nov 2016 16:28:56 -0300 Subject: [PATCH] test --- src/wallet/wallet.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index e15067686..88ae03540 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2278,11 +2278,11 @@ static void ApproximateBestSubset(vector vCoins,set >& setCoinsRet, CAmount& nValueRet) const +bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int nConfTheirs, vector vCoins,set >& setCoinsRet, CAmount& nValueRet, uint64_t *interestp) const { setCoinsRet.clear(); nValueRet = 0; - + *interestp = 0; // List of values less than target pair > coinLowestLarger; coinLowestLarger.first = std::numeric_limits::max(); @@ -2311,6 +2311,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int { setCoinsRet.insert(coin.second); nValueRet += coin.first; + *interestp += pcoin->vout[i].interest; return true; } else if (n < nTargetValue + CENT) @@ -2321,6 +2322,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int else if (n < coinLowestLarger.first) { coinLowestLarger = coin; + coinLowestLarger.second.first->interest = pcoin->vout[i].interest; } } @@ -2330,6 +2332,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int { setCoinsRet.insert(vValue[i].second); nValueRet += vValue[i].first; + *interestp += pcoin->vout[i].interest; } return true; } @@ -2340,6 +2343,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int return false; setCoinsRet.insert(coinLowestLarger.second); nValueRet += coinLowestLarger.first; + *interestp += pcoin->vout[i].interest; return true; } @@ -2359,6 +2363,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int { setCoinsRet.insert(coinLowestLarger.second); nValueRet += coinLowestLarger.first; + *interestp += coinLowestLarger.second.first->interest; } else { for (unsigned int i = 0; i < vValue.size(); i++) @@ -2366,6 +2371,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int { setCoinsRet.insert(vValue[i].second); nValueRet += vValue[i].first; + *interestp += vValue[i].second.first->interest; } LogPrint("selectcoins", "SelectCoins() best subset: "); @@ -2412,6 +2418,7 @@ bool CWallet::SelectCoins(const CAmount& nTargetValue, set return all selected outputs (we want all selected to go into the transaction for sure) + *interestp = 0; if (coinControl && coinControl->HasSelected()) { BOOST_FOREACH(const COutput& out, vCoins) @@ -2419,14 +2426,15 @@ bool CWallet::SelectCoins(const CAmount& nTargetValue, setvout[out.i].nValue; + *interestp += out.tx->vout[out.i].interest; 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))); + return (SelectCoinsMinConf(nTargetValue, 1, 6, vCoins, setCoinsRet, nValueRet,interestp) || + SelectCoinsMinConf(nTargetValue, 1, 1, vCoins, setCoinsRet, nValueRet,interestp) || + (bSpendZeroConfChange && SelectCoinsMinConf(nTargetValue, 0, 1, vCoins, setCoinsRet, nValueRet,interestp))); } bool CWallet::CreateTransaction(const vector& vecSend,