@@ -580,18 +580,18 @@ bool CWallet::CreateTransactionInternal(
580580{
581581 AssertLockHeld (cs_wallet);
582582
583- CAmount nValue = 0 ;
583+ CAmount recipients_sum = 0 ;
584584 const OutputType change_type = TransactionChangeType (coin_control.m_change_type ? *coin_control.m_change_type : m_default_change_type, vecSend);
585585 ReserveDestination reservedest (this , change_type);
586586 unsigned int nSubtractFeeFromAmount = 0 ;
587587 for (const auto & recipient : vecSend)
588588 {
589- if (nValue < 0 || recipient.nAmount < 0 )
589+ if (recipients_sum < 0 || recipient.nAmount < 0 )
590590 {
591591 error = _ (" Transaction amounts must not be negative" );
592592 return false ;
593593 }
594- nValue += recipient.nAmount ;
594+ recipients_sum += recipient.nAmount ;
595595
596596 if (recipient.fSubtractFeeFromAmount )
597597 nSubtractFeeFromAmount++;
@@ -709,20 +709,20 @@ bool CWallet::CreateTransactionInternal(
709709
710710 // Include the fees for things that aren't inputs, excluding the change output
711711 const CAmount not_input_fees = coin_selection_params.m_effective_feerate .GetFee (coin_selection_params.tx_noinputs_size );
712- CAmount nValueToSelect = nValue + not_input_fees;
712+ CAmount selection_target = recipients_sum + not_input_fees;
713713
714714 // Choose coins to use
715715 CAmount inputs_sum = 0 ;
716716 setCoins.clear ();
717- if (!SelectCoins (vAvailableCoins, /* nTargetValue */ nValueToSelect , setCoins, inputs_sum, coin_control, coin_selection_params))
717+ if (!SelectCoins (vAvailableCoins, /* nTargetValue */ selection_target , setCoins, inputs_sum, coin_control, coin_selection_params))
718718 {
719719 error = _ (" Insufficient funds" );
720720 return false ;
721721 }
722722
723723 // Always make a change output
724724 // We will reduce the fee from this change output later, and remove the output if it is too small.
725- const CAmount change_and_fee = inputs_sum - nValue ;
725+ const CAmount change_and_fee = inputs_sum - recipients_sum ;
726726 assert (change_and_fee >= 0 );
727727 CTxOut newTxOut (change_and_fee, scriptChange);
728728
0 commit comments