mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 10:43:19 -03:00
wallet: Rename nFeeRet in CreateTransactionInternal to current_fee
nFeeRet represents the fee that the transaction currently pays. Update it's name to reflect that.
This commit is contained in:
parent
ef744c03e5
commit
e5daf976d5
1 changed files with 10 additions and 11 deletions
|
@ -778,7 +778,6 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
|
|||
AssertLockHeld(wallet.cs_wallet);
|
||||
|
||||
// out variables, to be packed into returned result structure
|
||||
CAmount nFeeRet;
|
||||
int nChangePosInOut = change_pos;
|
||||
|
||||
FastRandomContext rng_fast;
|
||||
|
@ -960,24 +959,24 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
|
|||
return util::Error{_("Missing solving data for estimating transaction size")};
|
||||
}
|
||||
CAmount fee_needed = coin_selection_params.m_effective_feerate.GetFee(nBytes);
|
||||
nFeeRet = result->GetSelectedValue() - recipients_sum - change_amount;
|
||||
CAmount current_fee = result->GetSelectedValue() - recipients_sum - change_amount;
|
||||
|
||||
// The only time that fee_needed should be less than the amount available for fees is when
|
||||
// we are subtracting the fee from the outputs. If this occurs at any other time, it is a bug.
|
||||
if (!coin_selection_params.m_subtract_fee_outputs && fee_needed > nFeeRet) {
|
||||
if (!coin_selection_params.m_subtract_fee_outputs && fee_needed > current_fee) {
|
||||
return util::Error{Untranslated(STR_INTERNAL_BUG("Fee needed > fee paid"))};
|
||||
}
|
||||
|
||||
// If there is a change output and we overpay the fees then increase the change to match the fee needed
|
||||
if (nChangePosInOut != -1 && fee_needed < nFeeRet) {
|
||||
if (nChangePosInOut != -1 && fee_needed < current_fee) {
|
||||
auto& change = txNew.vout.at(nChangePosInOut);
|
||||
change.nValue += nFeeRet - fee_needed;
|
||||
nFeeRet = fee_needed;
|
||||
change.nValue += current_fee - fee_needed;
|
||||
current_fee = fee_needed;
|
||||
}
|
||||
|
||||
// Reduce output values for subtractFeeFromAmount
|
||||
if (coin_selection_params.m_subtract_fee_outputs) {
|
||||
CAmount to_reduce = fee_needed - nFeeRet;
|
||||
CAmount to_reduce = fee_needed - current_fee;
|
||||
int i = 0;
|
||||
bool fFirst = true;
|
||||
for (const auto& recipient : vecSend)
|
||||
|
@ -1008,7 +1007,7 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
|
|||
}
|
||||
++i;
|
||||
}
|
||||
nFeeRet = fee_needed;
|
||||
current_fee = fee_needed;
|
||||
}
|
||||
|
||||
// Give up if change keypool ran out and change is required
|
||||
|
@ -1030,7 +1029,7 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
|
|||
return util::Error{_("Transaction too large")};
|
||||
}
|
||||
|
||||
if (nFeeRet > wallet.m_default_max_tx_fee) {
|
||||
if (current_fee > wallet.m_default_max_tx_fee) {
|
||||
return util::Error{TransactionErrorString(TransactionError::MAX_FEE_EXCEEDED)};
|
||||
}
|
||||
|
||||
|
@ -1046,14 +1045,14 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
|
|||
reservedest.KeepDestination();
|
||||
|
||||
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",
|
||||
nFeeRet, nBytes, feeCalc.returnedTarget, feeCalc.desiredTarget, StringForFeeReason(feeCalc.reason), feeCalc.est.decay,
|
||||
current_fee, nBytes, feeCalc.returnedTarget, feeCalc.desiredTarget, StringForFeeReason(feeCalc.reason), feeCalc.est.decay,
|
||||
feeCalc.est.pass.start, feeCalc.est.pass.end,
|
||||
(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,
|
||||
feeCalc.est.pass.withinTarget, feeCalc.est.pass.totalConfirmed, feeCalc.est.pass.inMempool, feeCalc.est.pass.leftMempool,
|
||||
feeCalc.est.fail.start, feeCalc.est.fail.end,
|
||||
(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,
|
||||
feeCalc.est.fail.withinTarget, feeCalc.est.fail.totalConfirmed, feeCalc.est.fail.inMempool, feeCalc.est.fail.leftMempool);
|
||||
return CreatedTransactionResult(tx, nFeeRet, nChangePosInOut, feeCalc);
|
||||
return CreatedTransactionResult(tx, current_fee, nChangePosInOut, feeCalc);
|
||||
}
|
||||
|
||||
util::Result<CreatedTransactionResult> CreateTransaction(
|
||||
|
|
Loading…
Add table
Reference in a new issue