0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-03-05 14:06:27 -05:00

Rename nSubtractFeeFromAmount in CreateTransaction

Renamed to outputs_to_subtract_fee_from for clarity.
This commit is contained in:
Andrew Chow 2021-05-17 16:22:30 -04:00
parent dac21c793f
commit cd1d6d3324

View file

@ -583,7 +583,7 @@ bool CWallet::CreateTransactionInternal(
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;
unsigned int outputs_to_subtract_fee_from = 0; // The number of outputs which we are subtracting the fee from
for (const auto& recipient : vecSend)
{
if (recipients_sum < 0 || recipient.nAmount < 0)
@ -594,7 +594,7 @@ bool CWallet::CreateTransactionInternal(
recipients_sum += recipient.nAmount;
if (recipient.fSubtractFeeFromAmount)
nSubtractFeeFromAmount++;
outputs_to_subtract_fee_from++;
}
if (vecSend.empty())
{
@ -684,7 +684,7 @@ bool CWallet::CreateTransactionInternal(
coin_selection_params.m_change_fee = coin_selection_params.m_effective_feerate.GetFee(coin_selection_params.change_output_size);
coin_selection_params.m_cost_of_change = coin_selection_params.m_discard_feerate.GetFee(coin_selection_params.change_spend_size) + coin_selection_params.m_change_fee;
coin_selection_params.m_subtract_fee_outputs = nSubtractFeeFromAmount != 0; // If we are doing subtract fee from recipient, don't use effective values
coin_selection_params.m_subtract_fee_outputs = outputs_to_subtract_fee_from != 0; // If we are doing subtract fee from recipient, don't use effective values
// vouts to the payees
if (!coin_selection_params.m_subtract_fee_outputs) {
@ -757,7 +757,7 @@ bool CWallet::CreateTransactionInternal(
// Subtract fee from the change output if not subtracting it from recipient outputs
CAmount fee_needed = nFeeRet;
if (nSubtractFeeFromAmount == 0) {
if (outputs_to_subtract_fee_from == 0) {
change_position->nValue -= fee_needed;
}
@ -783,7 +783,7 @@ bool CWallet::CreateTransactionInternal(
}
// Reduce output values for subtractFeeFromAmount
if (nSubtractFeeFromAmount != 0) {
if (outputs_to_subtract_fee_from != 0) {
CAmount to_reduce = fee_needed + change_amount - change_and_fee;
int i = 0;
bool fFirst = true;
@ -796,12 +796,12 @@ bool CWallet::CreateTransactionInternal(
if (recipient.fSubtractFeeFromAmount)
{
txout.nValue -= to_reduce / nSubtractFeeFromAmount; // Subtract fee equally from each selected recipient
txout.nValue -= to_reduce / outputs_to_subtract_fee_from; // Subtract fee equally from each selected recipient
if (fFirst) // first receiver pays the remainder not divisible by output count
{
fFirst = false;
txout.nValue -= to_reduce % nSubtractFeeFromAmount;
txout.nValue -= to_reduce % outputs_to_subtract_fee_from;
}
// Error if this output is reduced to be below dust