Skip to content

Commit e5daf97

Browse files
committed
wallet: Rename nFeeRet in CreateTransactionInternal to current_fee
nFeeRet represents the fee that the transaction currently pays. Update it's name to reflect that.
1 parent ef744c0 commit e5daf97

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/wallet/spend.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,6 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
778778
AssertLockHeld(wallet.cs_wallet);
779779

780780
// out variables, to be packed into returned result structure
781-
CAmount nFeeRet;
782781
int nChangePosInOut = change_pos;
783782

784783
FastRandomContext rng_fast;
@@ -960,24 +959,24 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
960959
return util::Error{_("Missing solving data for estimating transaction size")};
961960
}
962961
CAmount fee_needed = coin_selection_params.m_effective_feerate.GetFee(nBytes);
963-
nFeeRet = result->GetSelectedValue() - recipients_sum - change_amount;
962+
CAmount current_fee = result->GetSelectedValue() - recipients_sum - change_amount;
964963

965964
// The only time that fee_needed should be less than the amount available for fees is when
966965
// we are subtracting the fee from the outputs. If this occurs at any other time, it is a bug.
967-
if (!coin_selection_params.m_subtract_fee_outputs && fee_needed > nFeeRet) {
966+
if (!coin_selection_params.m_subtract_fee_outputs && fee_needed > current_fee) {
968967
return util::Error{Untranslated(STR_INTERNAL_BUG("Fee needed > fee paid"))};
969968
}
970969

971970
// If there is a change output and we overpay the fees then increase the change to match the fee needed
972-
if (nChangePosInOut != -1 && fee_needed < nFeeRet) {
971+
if (nChangePosInOut != -1 && fee_needed < current_fee) {
973972
auto& change = txNew.vout.at(nChangePosInOut);
974-
change.nValue += nFeeRet - fee_needed;
975-
nFeeRet = fee_needed;
973+
change.nValue += current_fee - fee_needed;
974+
current_fee = fee_needed;
976975
}
977976

978977
// Reduce output values for subtractFeeFromAmount
979978
if (coin_selection_params.m_subtract_fee_outputs) {
980-
CAmount to_reduce = fee_needed - nFeeRet;
979+
CAmount to_reduce = fee_needed - current_fee;
981980
int i = 0;
982981
bool fFirst = true;
983982
for (const auto& recipient : vecSend)
@@ -1008,7 +1007,7 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
10081007
}
10091008
++i;
10101009
}
1011-
nFeeRet = fee_needed;
1010+
current_fee = fee_needed;
10121011
}
10131012

10141013
// Give up if change keypool ran out and change is required
@@ -1030,7 +1029,7 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
10301029
return util::Error{_("Transaction too large")};
10311030
}
10321031

1033-
if (nFeeRet > wallet.m_default_max_tx_fee) {
1032+
if (current_fee > wallet.m_default_max_tx_fee) {
10341033
return util::Error{TransactionErrorString(TransactionError::MAX_FEE_EXCEEDED)};
10351034
}
10361035

@@ -1046,14 +1045,14 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
10461045
reservedest.KeepDestination();
10471046

10481047
wallet.WalletLogPrintf("Fee Calculation: Fee:%d Bytes:%u Tgt:%d (requested %d) Reason:\"%s\" Decay %.5f: Estimation: (%g - %g) %.2f%% %.1f/(%.1f %d mem %.1f out) Fail: (%g - %g) %.2f%% %.1f/(%.1f %d mem %.1f out)\n",
1049-
nFeeRet, nBytes, feeCalc.returnedTarget, feeCalc.desiredTarget, StringForFeeReason(feeCalc.reason), feeCalc.est.decay,
1048+
current_fee, nBytes, feeCalc.returnedTarget, feeCalc.desiredTarget, StringForFeeReason(feeCalc.reason), feeCalc.est.decay,
10501049
feeCalc.est.pass.start, feeCalc.est.pass.end,
10511050
(feeCalc.est.pass.totalConfirmed + feeCalc.est.pass.inMempool + feeCalc.est.pass.leftMempool) > 0.0 ? 100 * feeCalc.est.pass.withinTarget / (feeCalc.est.pass.totalConfirmed + feeCalc.est.pass.inMempool + feeCalc.est.pass.leftMempool) : 0.0,
10521051
feeCalc.est.pass.withinTarget, feeCalc.est.pass.totalConfirmed, feeCalc.est.pass.inMempool, feeCalc.est.pass.leftMempool,
10531052
feeCalc.est.fail.start, feeCalc.est.fail.end,
10541053
(feeCalc.est.fail.totalConfirmed + feeCalc.est.fail.inMempool + feeCalc.est.fail.leftMempool) > 0.0 ? 100 * feeCalc.est.fail.withinTarget / (feeCalc.est.fail.totalConfirmed + feeCalc.est.fail.inMempool + feeCalc.est.fail.leftMempool) : 0.0,
10551054
feeCalc.est.fail.withinTarget, feeCalc.est.fail.totalConfirmed, feeCalc.est.fail.inMempool, feeCalc.est.fail.leftMempool);
1056-
return CreatedTransactionResult(tx, nFeeRet, nChangePosInOut, feeCalc);
1055+
return CreatedTransactionResult(tx, current_fee, nChangePosInOut, feeCalc);
10571056
}
10581057

10591058
util::Result<CreatedTransactionResult> CreateTransaction(

0 commit comments

Comments
 (0)