@ -1757,9 +1757,9 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend,
nChangePosRet = - 1 ;
bool fFirst = true ;
CAmount n Total Value = nValue ;
CAmount n ValueToSelect = nValue ;
if ( nSubtractFeeFromAmount = = 0 )
n Total Value + = nFeeRet ;
n ValueToSelect + = nFeeRet ;
double dPriority = 0 ;
// vouts to the payees
BOOST_FOREACH ( const CRecipient & recipient , vecSend )
@ -1796,7 +1796,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend,
// Choose coins to use
set < pair < const CWalletTx * , unsigned int > > setCoins ;
CAmount nValueIn = 0 ;
if ( ! SelectCoins ( n Total Value, setCoins , nValueIn , coinControl ) )
if ( ! SelectCoins ( n ValueToSelect , setCoins , nValueIn , coinControl ) )
{
strFailReason = _ ( " Insufficient funds " ) ;
return false ;
@ -1814,10 +1814,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend,
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