aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet.cpp
diff options
context:
space:
mode:
authorNicolasDorier <nicolas.dorier@gmail.com>2017-04-08 03:41:27 +0000
committerNicolasDorier <nicolas.dorier@gmail.com>2017-04-13 05:32:24 +0000
commitc37e32af0d2f8723f89c5304d41a4a41d4d34ea3 (patch)
tree686b8200b6de71b683ef66f2a152d903d0778bea /src/wallet/wallet.cpp
parentf597dcb7c875b51abe9a4cfdcb22dd5099cdbf7f (diff)
downloadbitcoin-c37e32af0d2f8723f89c5304d41a4a41d4d34ea3.tar.xz
[Wallet] Prevent CInputCoin to be in a null state
Diffstat (limited to 'src/wallet/wallet.cpp')
-rw-r--r--src/wallet/wallet.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 540352c7da..ff135fb05b 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -2085,7 +2085,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, const int nConfMin
nValueRet = 0;
// List of values less than target
- CInputCoin coinLowestLarger;
+ boost::optional<CInputCoin> coinLowestLarger;
std::vector<CInputCoin> vValue;
CAmount nTotalLower = 0;
@@ -2119,7 +2119,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, const int nConfMin
vValue.push_back(coin);
nTotalLower += coin.txout.nValue;
}
- else if (coinLowestLarger.IsNull() || coin.txout.nValue < coinLowestLarger.txout.nValue)
+ else if (!coinLowestLarger || coin.txout.nValue < coinLowestLarger->txout.nValue)
{
coinLowestLarger = coin;
}
@@ -2137,10 +2137,10 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, const int nConfMin
if (nTotalLower < nTargetValue)
{
- if (coinLowestLarger.IsNull())
+ if (!coinLowestLarger)
return false;
- setCoinsRet.insert(coinLowestLarger);
- nValueRet += coinLowestLarger.txout.nValue;
+ setCoinsRet.insert(coinLowestLarger.get());
+ nValueRet += coinLowestLarger->txout.nValue;
return true;
}
@@ -2156,11 +2156,11 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, const int nConfMin
// If we have a bigger coin and (either the stochastic approximation didn't find a good solution,
// or the next bigger coin is closer), return the bigger coin
- if (!coinLowestLarger.IsNull() &&
- ((nBest != nTargetValue && nBest < nTargetValue + MIN_CHANGE) || coinLowestLarger.txout.nValue <= nBest))
+ if (coinLowestLarger &&
+ ((nBest != nTargetValue && nBest < nTargetValue + MIN_CHANGE) || coinLowestLarger->txout.nValue <= nBest))
{
- setCoinsRet.insert(coinLowestLarger);
- nValueRet += coinLowestLarger.txout.nValue;
+ setCoinsRet.insert(coinLowestLarger.get());
+ nValueRet += coinLowestLarger->txout.nValue;
}
else {
for (unsigned int i = 0; i < vValue.size(); i++)