test
This commit is contained in:
@@ -2278,11 +2278,11 @@ static void ApproximateBestSubset(vector<pair<CAmount, pair<const CWalletTx*,uns
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int nConfTheirs, vector<COutput> vCoins,set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, CAmount& nValueRet) const
|
bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int nConfTheirs, vector<COutput> vCoins,set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, CAmount& nValueRet, uint64_t *interestp) const
|
||||||
{
|
{
|
||||||
setCoinsRet.clear();
|
setCoinsRet.clear();
|
||||||
nValueRet = 0;
|
nValueRet = 0;
|
||||||
|
*interestp = 0;
|
||||||
// List of values less than target
|
// List of values less than target
|
||||||
pair<CAmount, pair<const CWalletTx*,unsigned int> > coinLowestLarger;
|
pair<CAmount, pair<const CWalletTx*,unsigned int> > coinLowestLarger;
|
||||||
coinLowestLarger.first = std::numeric_limits<CAmount>::max();
|
coinLowestLarger.first = std::numeric_limits<CAmount>::max();
|
||||||
@@ -2311,6 +2311,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int
|
|||||||
{
|
{
|
||||||
setCoinsRet.insert(coin.second);
|
setCoinsRet.insert(coin.second);
|
||||||
nValueRet += coin.first;
|
nValueRet += coin.first;
|
||||||
|
*interestp += pcoin->vout[i].interest;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (n < nTargetValue + CENT)
|
else if (n < nTargetValue + CENT)
|
||||||
@@ -2321,6 +2322,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int
|
|||||||
else if (n < coinLowestLarger.first)
|
else if (n < coinLowestLarger.first)
|
||||||
{
|
{
|
||||||
coinLowestLarger = coin;
|
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);
|
setCoinsRet.insert(vValue[i].second);
|
||||||
nValueRet += vValue[i].first;
|
nValueRet += vValue[i].first;
|
||||||
|
*interestp += pcoin->vout[i].interest;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -2340,6 +2343,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int
|
|||||||
return false;
|
return false;
|
||||||
setCoinsRet.insert(coinLowestLarger.second);
|
setCoinsRet.insert(coinLowestLarger.second);
|
||||||
nValueRet += coinLowestLarger.first;
|
nValueRet += coinLowestLarger.first;
|
||||||
|
*interestp += pcoin->vout[i].interest;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2359,6 +2363,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int
|
|||||||
{
|
{
|
||||||
setCoinsRet.insert(coinLowestLarger.second);
|
setCoinsRet.insert(coinLowestLarger.second);
|
||||||
nValueRet += coinLowestLarger.first;
|
nValueRet += coinLowestLarger.first;
|
||||||
|
*interestp += coinLowestLarger.second.first->interest;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (unsigned int i = 0; i < vValue.size(); i++)
|
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);
|
setCoinsRet.insert(vValue[i].second);
|
||||||
nValueRet += vValue[i].first;
|
nValueRet += vValue[i].first;
|
||||||
|
*interestp += vValue[i].second.first->interest;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogPrint("selectcoins", "SelectCoins() best subset: ");
|
LogPrint("selectcoins", "SelectCoins() best subset: ");
|
||||||
@@ -2412,6 +2418,7 @@ bool CWallet::SelectCoins(const CAmount& nTargetValue, set<pair<const CWalletTx*
|
|||||||
}
|
}
|
||||||
|
|
||||||
// coin control -> return all selected outputs (we want all selected to go into the transaction for sure)
|
// coin control -> return all selected outputs (we want all selected to go into the transaction for sure)
|
||||||
|
*interestp = 0;
|
||||||
if (coinControl && coinControl->HasSelected())
|
if (coinControl && coinControl->HasSelected())
|
||||||
{
|
{
|
||||||
BOOST_FOREACH(const COutput& out, vCoins)
|
BOOST_FOREACH(const COutput& out, vCoins)
|
||||||
@@ -2419,14 +2426,15 @@ bool CWallet::SelectCoins(const CAmount& nTargetValue, set<pair<const CWalletTx*
|
|||||||
if(!out.fSpendable)
|
if(!out.fSpendable)
|
||||||
continue;
|
continue;
|
||||||
nValueRet += out.tx->vout[out.i].nValue;
|
nValueRet += out.tx->vout[out.i].nValue;
|
||||||
|
*interestp += out.tx->vout[out.i].interest;
|
||||||
setCoinsRet.insert(make_pair(out.tx, out.i));
|
setCoinsRet.insert(make_pair(out.tx, out.i));
|
||||||
}
|
}
|
||||||
return (nValueRet >= nTargetValue);
|
return (nValueRet >= nTargetValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (SelectCoinsMinConf(nTargetValue, 1, 6, vCoins, setCoinsRet, nValueRet) ||
|
return (SelectCoinsMinConf(nTargetValue, 1, 6, vCoins, setCoinsRet, nValueRet,interestp) ||
|
||||||
SelectCoinsMinConf(nTargetValue, 1, 1, vCoins, setCoinsRet, nValueRet) ||
|
SelectCoinsMinConf(nTargetValue, 1, 1, vCoins, setCoinsRet, nValueRet,interestp) ||
|
||||||
(bSpendZeroConfChange && SelectCoinsMinConf(nTargetValue, 0, 1, vCoins, setCoinsRet, nValueRet)));
|
(bSpendZeroConfChange && SelectCoinsMinConf(nTargetValue, 0, 1, vCoins, setCoinsRet, nValueRet,interestp)));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend,
|
bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend,
|
||||||
|
|||||||
Reference in New Issue
Block a user