From 1bbd33eca9af6c00ed73575eab4527a7e57e436b Mon Sep 17 00:00:00 2001 From: Peter Bushnell Date: Sun, 13 Dec 2020 11:32:34 +0000 Subject: [PATCH] Set initial fee to min_fee, use min_fee in change calc --- src/wallet/wallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 71a788f6d74a6..d21c506e38db0 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -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; @@ -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;