@@ -580,18 +580,18 @@ bool CWallet::CreateTransactionInternal(
580
580
{
581
581
AssertLockHeld (cs_wallet);
582
582
583
- CAmount nValue = 0 ;
583
+ CAmount recipients_sum = 0 ;
584
584
const OutputType change_type = TransactionChangeType (coin_control.m_change_type ? *coin_control.m_change_type : m_default_change_type, vecSend);
585
585
ReserveDestination reservedest (this , change_type);
586
586
unsigned int nSubtractFeeFromAmount = 0 ;
587
587
for (const auto & recipient : vecSend)
588
588
{
589
- if (nValue < 0 || recipient.nAmount < 0 )
589
+ if (recipients_sum < 0 || recipient.nAmount < 0 )
590
590
{
591
591
error = _ (" Transaction amounts must not be negative" );
592
592
return false ;
593
593
}
594
- nValue += recipient.nAmount ;
594
+ recipients_sum += recipient.nAmount ;
595
595
596
596
if (recipient.fSubtractFeeFromAmount )
597
597
nSubtractFeeFromAmount++;
@@ -709,20 +709,20 @@ bool CWallet::CreateTransactionInternal(
709
709
710
710
// Include the fees for things that aren't inputs, excluding the change output
711
711
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;
713
713
714
714
// Choose coins to use
715
715
CAmount inputs_sum = 0 ;
716
716
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))
718
718
{
719
719
error = _ (" Insufficient funds" );
720
720
return false ;
721
721
}
722
722
723
723
// Always make a change output
724
724
// 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 ;
726
726
assert (change_and_fee >= 0 );
727
727
CTxOut newTxOut (change_and_fee, scriptChange);
728
728
0 commit comments