[wallet] remove MIN_CHANGE

pull/24494/head
glozow 3 years ago
parent a44236addd
commit 46f2fed6c5

@ -13,13 +13,13 @@
using node::NodeContext;
using wallet::AttemptSelection;
using wallet::CHANGE_LOWER;
using wallet::COutput;
using wallet::CWallet;
using wallet::CWalletTx;
using wallet::CoinEligibilityFilter;
using wallet::CoinSelectionParams;
using wallet::CreateDummyWalletDatabase;
using wallet::MIN_CHANGE;
using wallet::OutputGroup;
using wallet::SelectCoinsBnB;
using wallet::TxStateInactive;
@ -67,7 +67,7 @@ static void CoinSelection(benchmark::Bench& bench)
rand,
/* change_output_size= */ 34,
/* change_spend_size= */ 148,
/*min_change_target=*/ MIN_CHANGE,
/*min_change_target=*/ CHANGE_LOWER,
/* effective_feerate= */ CFeeRate(0),
/* long_term_feerate= */ CFeeRate(0),
/* discard_feerate= */ CFeeRate(0),

@ -32,7 +32,6 @@
#include <QTreeWidget>
using wallet::CCoinControl;
using wallet::MIN_CHANGE;
QList<CAmount> CoinControlDialog::payAmounts;
bool CoinControlDialog::fSubtractFeeFromAmount = false;
@ -485,11 +484,10 @@ void CoinControlDialog::updateLabels(CCoinControl& m_coin_control, WalletModel *
if (!CoinControlDialog::fSubtractFeeFromAmount)
nChange -= nPayFee;
// Never create dust outputs; if we would, just add the dust to the fee.
if (nChange > 0 && nChange < MIN_CHANGE)
{
if (nChange > 0) {
// Assumes a p2pkh script size
CTxOut txout(nChange, CScript() << std::vector<unsigned char>(24, 0));
// Never create dust outputs; if we would, just add the dust to the fee.
if (IsDust(txout, model->node().getDustRelayFee()))
{
nPayFee += nChange;

@ -13,18 +13,10 @@
#include <optional>
namespace wallet {
//! target minimum change amount
static constexpr CAmount MIN_CHANGE{COIN / 100};
//! final minimum change amount after paying for fees
static const CAmount MIN_FINAL_CHANGE = MIN_CHANGE/2;
//! lower bound for randomly-chosen target change amount
static constexpr CAmount CHANGE_LOWER{50000};
//! upper bound for randomly-chosen target change amount
static constexpr CAmount CHANGE_UPPER{1000000};
// Ensure that any randomly generated change targets are less than or equal to before.
// Otherwise, tests may fail if funds are not enough to cover change.
static_assert(CHANGE_UPPER <= MIN_CHANGE);
static_assert(CHANGE_LOWER <= MIN_FINAL_CHANGE);
/** A UTXO under consideration for use in funding a new transaction. */
class COutput
@ -104,7 +96,7 @@ struct CoinSelectionParams {
size_t change_spend_size = 0;
/** Mininmum change to target in Knapsack solver: select coins to cover the payment and
* at least this value of change. */
CAmount m_min_change_target{MIN_CHANGE};
CAmount m_min_change_target{0};
/** Cost of creating the change output. */
CAmount m_change_fee{0};
/** The pre-determined minimum value to target when funding a change output. */

Loading…
Cancel
Save