Skip to content

Commit

Permalink
Set initial fee to min_fee, use min_fee in change calc
Browse files Browse the repository at this point in the history
  • Loading branch information
Bushstar committed Dec 13, 2020
1 parent b0a01dc commit 1bbd33e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2841,7 +2841,7 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock& locked_chain, const std
// Get the fee rate to use effective values in coin selection
CFeeRate nFeeRateNeeded = GetMinimumFeeRate(*this, coin_control, &feeCalc);

nFeeRet = 0;
nFeeRet = min_fee;
bool pick_new_inputs = true;
CAmount nValueIn = 0;

Expand Down Expand Up @@ -3017,7 +3017,7 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock& locked_chain, const std
// change output. Only try this once.
if (nChangePosInOut == -1 && nSubtractFeeFromAmount == 0 && pick_new_inputs) {
unsigned int tx_size_with_change = nBytes + coin_selection_params.change_output_size + 2; // Add 2 as a buffer in case increasing # of outputs changes compact size
CAmount fee_needed_with_change = GetMinimumFee(*this, tx_size_with_change, coin_control, nullptr);
CAmount fee_needed_with_change = std::max(min_fee, GetMinimumFee(*this, tx_size_with_change, coin_control, nullptr));
CAmount minimum_value_for_change = GetDustThreshold(change_prototype_txout, discard_rate);
if (nFeeRet >= fee_needed_with_change + minimum_value_for_change) {
pick_new_inputs = false;
Expand Down

0 comments on commit 1bbd33e

Please sign in to comment.