diff options
-rw-r--r-- | src/bench/coin_selection.cpp | 4 | ||||
-rw-r--r-- | src/qt/coincontroldialog.cpp | 6 | ||||
-rw-r--r-- | src/wallet/coinselection.h | 10 |
3 files changed, 5 insertions, 15 deletions
diff --git a/src/bench/coin_selection.cpp b/src/bench/coin_selection.cpp index 76f1ab3976..18a780646f 100644 --- a/src/bench/coin_selection.cpp +++ b/src/bench/coin_selection.cpp @@ -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), diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp index d7a2aaaf19..1f66cb4d19 100644 --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -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; diff --git a/src/wallet/coinselection.h b/src/wallet/coinselection.h index 1da9f86cb5..2e20efa8c1 100644 --- a/src/wallet/coinselection.h +++ b/src/wallet/coinselection.h @@ -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. */ |