diff options
author | Andrew Chow <achow101-github@achow101.com> | 2021-05-17 16:20:40 -0400 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2021-05-30 14:03:43 -0400 |
commit | dac21c793f8fbb4d5debc55ac97c406c7c93ff48 (patch) | |
tree | ca8168963814dd688da88332f7add854a441acb7 /src/wallet | |
parent | d2aee3bbc765a1f02e4ceadb2fa5928ac524f1a7 (diff) | |
download | bitcoin-dac21c793f8fbb4d5debc55ac97c406c7c93ff48.tar.xz |
Rename nValue and nValueToSelect
nValue is the sum of the intended recipient amounts, so name it that for
clarity.
nValueToSelect is the coin selection target value, so name it
selection_target for clarity.
Diffstat (limited to 'src/wallet')
-rw-r--r-- | src/wallet/spend.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp index e8bbdc454b..3e69703788 100644 --- a/src/wallet/spend.cpp +++ b/src/wallet/spend.cpp @@ -580,18 +580,18 @@ bool CWallet::CreateTransactionInternal( { AssertLockHeld(cs_wallet); - CAmount nValue = 0; + CAmount recipients_sum = 0; const OutputType change_type = TransactionChangeType(coin_control.m_change_type ? *coin_control.m_change_type : m_default_change_type, vecSend); ReserveDestination reservedest(this, change_type); unsigned int nSubtractFeeFromAmount = 0; for (const auto& recipient : vecSend) { - if (nValue < 0 || recipient.nAmount < 0) + if (recipients_sum < 0 || recipient.nAmount < 0) { error = _("Transaction amounts must not be negative"); return false; } - nValue += recipient.nAmount; + recipients_sum += recipient.nAmount; if (recipient.fSubtractFeeFromAmount) nSubtractFeeFromAmount++; @@ -709,12 +709,12 @@ bool CWallet::CreateTransactionInternal( // Include the fees for things that aren't inputs, excluding the change output const CAmount not_input_fees = coin_selection_params.m_effective_feerate.GetFee(coin_selection_params.tx_noinputs_size); - CAmount nValueToSelect = nValue + not_input_fees; + CAmount selection_target = recipients_sum + not_input_fees; // Choose coins to use CAmount inputs_sum = 0; setCoins.clear(); - if (!SelectCoins(vAvailableCoins, /* nTargetValue */ nValueToSelect, setCoins, inputs_sum, coin_control, coin_selection_params)) + if (!SelectCoins(vAvailableCoins, /* nTargetValue */ selection_target, setCoins, inputs_sum, coin_control, coin_selection_params)) { error = _("Insufficient funds"); return false; @@ -722,7 +722,7 @@ bool CWallet::CreateTransactionInternal( // Always make a change output // We will reduce the fee from this change output later, and remove the output if it is too small. - const CAmount change_and_fee = inputs_sum - nValue; + const CAmount change_and_fee = inputs_sum - recipients_sum; assert(change_and_fee >= 0); CTxOut newTxOut(change_and_fee, scriptChange); |