aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2015-10-01 11:16:14 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2015-10-01 11:20:08 +0200
commit12a7712abd49079cbd128caab8904684c7563fff (patch)
tree76ff04241d284c6646b1d92a767a4d03ed458974 /src
parent1119cc3f5918575ca397518c9fd31a64704c7e4f (diff)
parent835c12291efc2ca03017622fe970218fdeb63727 (diff)
Merge pull request #5924
835c122 Clean up change computation in CreateTransaction. (Daniel Kraft)
Diffstat (limited to 'src')
-rw-r--r--src/wallet/wallet.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 39eff3af30..bd3004061b 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -1852,9 +1852,9 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
nChangePosRet = -1;
bool fFirst = true;
- CAmount nTotalValue = nValue;
+ CAmount nValueToSelect = nValue;
if (nSubtractFeeFromAmount == 0)
- nTotalValue += nFeeRet;
+ nValueToSelect += nFeeRet;
double dPriority = 0;
// vouts to the payees
BOOST_FOREACH (const CRecipient& recipient, vecSend)
@@ -1891,7 +1891,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
// Choose coins to use
set<pair<const CWalletTx*,unsigned int> > setCoins;
CAmount nValueIn = 0;
- if (!SelectCoins(nTotalValue, setCoins, nValueIn, coinControl))
+ if (!SelectCoins(nValueToSelect, setCoins, nValueIn, coinControl))
{
strFailReason = _("Insufficient funds");
return false;
@@ -1909,10 +1909,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
dPriority += (double)nCredit * age;
}
- CAmount nChange = nValueIn - nValue;
- if (nSubtractFeeFromAmount == 0)
- nChange -= nFeeRet;
-
+ const CAmount nChange = nValueIn - nValueToSelect;
if (nChange > 0)
{
// Fill a vout to ourself