@@ -778,7 +778,6 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
778
778
AssertLockHeld (wallet.cs_wallet );
779
779
780
780
// out variables, to be packed into returned result structure
781
- CAmount nFeeRet;
782
781
int nChangePosInOut = change_pos;
783
782
784
783
FastRandomContext rng_fast;
@@ -960,24 +959,24 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
960
959
return util::Error{_ (" Missing solving data for estimating transaction size" )};
961
960
}
962
961
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;
964
963
965
964
// The only time that fee_needed should be less than the amount available for fees is when
966
965
// 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 ) {
968
967
return util::Error{Untranslated (STR_INTERNAL_BUG (" Fee needed > fee paid" ))};
969
968
}
970
969
971
970
// 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 ) {
973
972
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;
976
975
}
977
976
978
977
// Reduce output values for subtractFeeFromAmount
979
978
if (coin_selection_params.m_subtract_fee_outputs ) {
980
- CAmount to_reduce = fee_needed - nFeeRet ;
979
+ CAmount to_reduce = fee_needed - current_fee ;
981
980
int i = 0 ;
982
981
bool fFirst = true ;
983
982
for (const auto & recipient : vecSend)
@@ -1008,7 +1007,7 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
1008
1007
}
1009
1008
++i;
1010
1009
}
1011
- nFeeRet = fee_needed;
1010
+ current_fee = fee_needed;
1012
1011
}
1013
1012
1014
1013
// Give up if change keypool ran out and change is required
@@ -1030,7 +1029,7 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
1030
1029
return util::Error{_ (" Transaction too large" )};
1031
1030
}
1032
1031
1033
- if (nFeeRet > wallet.m_default_max_tx_fee ) {
1032
+ if (current_fee > wallet.m_default_max_tx_fee ) {
1034
1033
return util::Error{TransactionErrorString (TransactionError::MAX_FEE_EXCEEDED)};
1035
1034
}
1036
1035
@@ -1046,14 +1045,14 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
1046
1045
reservedest.KeepDestination ();
1047
1046
1048
1047
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 ,
1050
1049
feeCalc.est .pass .start , feeCalc.est .pass .end ,
1051
1050
(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 ,
1052
1051
feeCalc.est .pass .withinTarget , feeCalc.est .pass .totalConfirmed , feeCalc.est .pass .inMempool , feeCalc.est .pass .leftMempool ,
1053
1052
feeCalc.est .fail .start , feeCalc.est .fail .end ,
1054
1053
(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 ,
1055
1054
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);
1057
1056
}
1058
1057
1059
1058
util::Result<CreatedTransactionResult> CreateTransaction (
0 commit comments