Skip to content

Commit 46f2fed

Browse files
committed
[wallet] remove MIN_CHANGE
1 parent a44236a commit 46f2fed

File tree

3 files changed

+5
-15
lines changed

3 files changed

+5
-15
lines changed

src/bench/coin_selection.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313

1414
using node::NodeContext;
1515
using wallet::AttemptSelection;
16+
using wallet::CHANGE_LOWER;
1617
using wallet::COutput;
1718
using wallet::CWallet;
1819
using wallet::CWalletTx;
1920
using wallet::CoinEligibilityFilter;
2021
using wallet::CoinSelectionParams;
2122
using wallet::CreateDummyWalletDatabase;
22-
using wallet::MIN_CHANGE;
2323
using wallet::OutputGroup;
2424
using wallet::SelectCoinsBnB;
2525
using wallet::TxStateInactive;
@@ -67,7 +67,7 @@ static void CoinSelection(benchmark::Bench& bench)
6767
rand,
6868
/* change_output_size= */ 34,
6969
/* change_spend_size= */ 148,
70-
/*min_change_target=*/ MIN_CHANGE,
70+
/*min_change_target=*/ CHANGE_LOWER,
7171
/* effective_feerate= */ CFeeRate(0),
7272
/* long_term_feerate= */ CFeeRate(0),
7373
/* discard_feerate= */ CFeeRate(0),

src/qt/coincontroldialog.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#include <QTreeWidget>
3333

3434
using wallet::CCoinControl;
35-
using wallet::MIN_CHANGE;
3635

3736
QList<CAmount> CoinControlDialog::payAmounts;
3837
bool CoinControlDialog::fSubtractFeeFromAmount = false;
@@ -485,11 +484,10 @@ void CoinControlDialog::updateLabels(CCoinControl& m_coin_control, WalletModel *
485484
if (!CoinControlDialog::fSubtractFeeFromAmount)
486485
nChange -= nPayFee;
487486

488-
// Never create dust outputs; if we would, just add the dust to the fee.
489-
if (nChange > 0 && nChange < MIN_CHANGE)
490-
{
487+
if (nChange > 0) {
491488
// Assumes a p2pkh script size
492489
CTxOut txout(nChange, CScript() << std::vector<unsigned char>(24, 0));
490+
// Never create dust outputs; if we would, just add the dust to the fee.
493491
if (IsDust(txout, model->node().getDustRelayFee()))
494492
{
495493
nPayFee += nChange;

src/wallet/coinselection.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,10 @@
1313
#include <optional>
1414

1515
namespace wallet {
16-
//! target minimum change amount
17-
static constexpr CAmount MIN_CHANGE{COIN / 100};
18-
//! final minimum change amount after paying for fees
19-
static const CAmount MIN_FINAL_CHANGE = MIN_CHANGE/2;
2016
//! lower bound for randomly-chosen target change amount
2117
static constexpr CAmount CHANGE_LOWER{50000};
2218
//! upper bound for randomly-chosen target change amount
2319
static constexpr CAmount CHANGE_UPPER{1000000};
24-
// Ensure that any randomly generated change targets are less than or equal to before.
25-
// Otherwise, tests may fail if funds are not enough to cover change.
26-
static_assert(CHANGE_UPPER <= MIN_CHANGE);
27-
static_assert(CHANGE_LOWER <= MIN_FINAL_CHANGE);
2820

2921
/** A UTXO under consideration for use in funding a new transaction. */
3022
class COutput
@@ -104,7 +96,7 @@ struct CoinSelectionParams {
10496
size_t change_spend_size = 0;
10597
/** Mininmum change to target in Knapsack solver: select coins to cover the payment and
10698
* at least this value of change. */
107-
CAmount m_min_change_target{MIN_CHANGE};
99+
CAmount m_min_change_target{0};
108100
/** Cost of creating the change output. */
109101
CAmount m_change_fee{0};
110102
/** The pre-determined minimum value to target when funding a change output. */

0 commit comments

Comments
 (0)