@ -1757,9 +1757,9 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend,
nChangePosRet = - 1 ;
nChangePosRet = - 1 ;
bool fFirst = true ;
bool fFirst = true ;
CAmount nTotal Value = nValue ;
CAmount nValueToSelect = nValue ;
if ( nSubtractFeeFromAmount = = 0 )
if ( nSubtractFeeFromAmount = = 0 )
nTotal Value + = nFeeRet ;
nValueToSelect + = nFeeRet ;
double dPriority = 0 ;
double dPriority = 0 ;
// vouts to the payees
// vouts to the payees
BOOST_FOREACH ( const CRecipient & recipient , vecSend )
BOOST_FOREACH ( const CRecipient & recipient , vecSend )
@ -1796,7 +1796,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend,
// Choose coins to use
// Choose coins to use
set < pair < const CWalletTx * , unsigned int > > setCoins ;
set < pair < const CWalletTx * , unsigned int > > setCoins ;
CAmount nValueIn = 0 ;
CAmount nValueIn = 0 ;
if ( ! SelectCoins ( nTotal Value , setCoins , nValueIn , coinControl ) )
if ( ! SelectCoins ( nValueToSelect , setCoins , nValueIn , coinControl ) )
{
{
strFailReason = _ ( " Insufficient funds " ) ;
strFailReason = _ ( " Insufficient funds " ) ;
return false ;
return false ;
@ -1814,10 +1814,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend,
dPriority + = ( double ) nCredit * age ;
dPriority + = ( double ) nCredit * age ;
}
}
CAmount nChange = nValueIn - nValue ;
const CAmount nChange = nValueIn - nValueToSelect ;
if ( nSubtractFeeFromAmount = = 0 )
nChange - = nFeeRet ;
if ( nChange > 0 )
if ( nChange > 0 )
{
{
// Fill a vout to ourself
// Fill a vout to ourself