mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-30 05:52:33 +02:00
[wallet] remove MIN_CHANGE
This commit is contained in:
parent
a44236addd
commit
46f2fed6c5
@ -13,13 +13,13 @@
|
|||||||
|
|
||||||
using node::NodeContext;
|
using node::NodeContext;
|
||||||
using wallet::AttemptSelection;
|
using wallet::AttemptSelection;
|
||||||
|
using wallet::CHANGE_LOWER;
|
||||||
using wallet::COutput;
|
using wallet::COutput;
|
||||||
using wallet::CWallet;
|
using wallet::CWallet;
|
||||||
using wallet::CWalletTx;
|
using wallet::CWalletTx;
|
||||||
using wallet::CoinEligibilityFilter;
|
using wallet::CoinEligibilityFilter;
|
||||||
using wallet::CoinSelectionParams;
|
using wallet::CoinSelectionParams;
|
||||||
using wallet::CreateDummyWalletDatabase;
|
using wallet::CreateDummyWalletDatabase;
|
||||||
using wallet::MIN_CHANGE;
|
|
||||||
using wallet::OutputGroup;
|
using wallet::OutputGroup;
|
||||||
using wallet::SelectCoinsBnB;
|
using wallet::SelectCoinsBnB;
|
||||||
using wallet::TxStateInactive;
|
using wallet::TxStateInactive;
|
||||||
@ -67,7 +67,7 @@ static void CoinSelection(benchmark::Bench& bench)
|
|||||||
rand,
|
rand,
|
||||||
/* change_output_size= */ 34,
|
/* change_output_size= */ 34,
|
||||||
/* change_spend_size= */ 148,
|
/* change_spend_size= */ 148,
|
||||||
/*min_change_target=*/ MIN_CHANGE,
|
/*min_change_target=*/ CHANGE_LOWER,
|
||||||
/* effective_feerate= */ CFeeRate(0),
|
/* effective_feerate= */ CFeeRate(0),
|
||||||
/* long_term_feerate= */ CFeeRate(0),
|
/* long_term_feerate= */ CFeeRate(0),
|
||||||
/* discard_feerate= */ CFeeRate(0),
|
/* discard_feerate= */ CFeeRate(0),
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
#include <QTreeWidget>
|
#include <QTreeWidget>
|
||||||
|
|
||||||
using wallet::CCoinControl;
|
using wallet::CCoinControl;
|
||||||
using wallet::MIN_CHANGE;
|
|
||||||
|
|
||||||
QList<CAmount> CoinControlDialog::payAmounts;
|
QList<CAmount> CoinControlDialog::payAmounts;
|
||||||
bool CoinControlDialog::fSubtractFeeFromAmount = false;
|
bool CoinControlDialog::fSubtractFeeFromAmount = false;
|
||||||
@ -485,11 +484,10 @@ void CoinControlDialog::updateLabels(CCoinControl& m_coin_control, WalletModel *
|
|||||||
if (!CoinControlDialog::fSubtractFeeFromAmount)
|
if (!CoinControlDialog::fSubtractFeeFromAmount)
|
||||||
nChange -= nPayFee;
|
nChange -= nPayFee;
|
||||||
|
|
||||||
// Never create dust outputs; if we would, just add the dust to the fee.
|
if (nChange > 0) {
|
||||||
if (nChange > 0 && nChange < MIN_CHANGE)
|
|
||||||
{
|
|
||||||
// Assumes a p2pkh script size
|
// Assumes a p2pkh script size
|
||||||
CTxOut txout(nChange, CScript() << std::vector<unsigned char>(24, 0));
|
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()))
|
if (IsDust(txout, model->node().getDustRelayFee()))
|
||||||
{
|
{
|
||||||
nPayFee += nChange;
|
nPayFee += nChange;
|
||||||
|
@ -13,18 +13,10 @@
|
|||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
namespace wallet {
|
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
|
//! lower bound for randomly-chosen target change amount
|
||||||
static constexpr CAmount CHANGE_LOWER{50000};
|
static constexpr CAmount CHANGE_LOWER{50000};
|
||||||
//! upper bound for randomly-chosen target change amount
|
//! upper bound for randomly-chosen target change amount
|
||||||
static constexpr CAmount CHANGE_UPPER{1000000};
|
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. */
|
/** A UTXO under consideration for use in funding a new transaction. */
|
||||||
class COutput
|
class COutput
|
||||||
@ -104,7 +96,7 @@ struct CoinSelectionParams {
|
|||||||
size_t change_spend_size = 0;
|
size_t change_spend_size = 0;
|
||||||
/** Mininmum change to target in Knapsack solver: select coins to cover the payment and
|
/** Mininmum change to target in Knapsack solver: select coins to cover the payment and
|
||||||
* at least this value of change. */
|
* 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. */
|
/** Cost of creating the change output. */
|
||||||
CAmount m_change_fee{0};
|
CAmount m_change_fee{0};
|
||||||
/** The pre-determined minimum value to target when funding a change output. */
|
/** The pre-determined minimum value to target when funding a change output. */
|
||||||
|
Loading…
Reference in New Issue
Block a user