From 2acad036575ec998f8bbe4f10f6206b1c8ad3d23 Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Mon, 31 Aug 2020 15:10:49 -0400 Subject: Remove OutputGroup non-default constructors --- src/wallet/coinselection.h | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'src/wallet/coinselection.h') diff --git a/src/wallet/coinselection.h b/src/wallet/coinselection.h index 49c1134ec6..1a0373eba1 100644 --- a/src/wallet/coinselection.h +++ b/src/wallet/coinselection.h @@ -81,17 +81,6 @@ struct OutputGroup CAmount long_term_fee{0}; OutputGroup() {} - OutputGroup(std::vector&& outputs, bool from_me, CAmount value, int depth, size_t ancestors, size_t descendants) - : m_outputs(std::move(outputs)) - , m_from_me(from_me) - , m_value(value) - , m_depth(depth) - , m_ancestors(ancestors) - , m_descendants(descendants) - {} - OutputGroup(const CInputCoin& output, int depth, bool from_me, size_t ancestors, size_t descendants) : OutputGroup() { - Insert(output, depth, from_me, ancestors, descendants); - } void Insert(const CInputCoin& output, int depth, bool from_me, size_t ancestors, size_t descendants); std::vector::iterator Discard(const CInputCoin& output); bool EligibleForSpending(const CoinEligibilityFilter& eligibility_filter) const; -- cgit v1.2.3 From 99b399aba5d27476b61b4865cc39553d03965d57 Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Mon, 31 Aug 2020 15:56:30 -0400 Subject: Move fee setting of OutputGroup to Insert OutputGroup will handle the fee and effective value computations inside of Insert. It now needs to take the effective feerate and long term feerates as arguments to its constructor. --- src/wallet/coinselection.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/wallet/coinselection.h') diff --git a/src/wallet/coinselection.h b/src/wallet/coinselection.h index 1a0373eba1..721f1a22eb 100644 --- a/src/wallet/coinselection.h +++ b/src/wallet/coinselection.h @@ -6,11 +6,10 @@ #define BITCOIN_WALLET_COINSELECTION_H #include +#include #include #include -class CFeeRate; - //! target minimum change amount static constexpr CAmount MIN_CHANGE{COIN / 100}; //! final minimum change amount after paying for fees @@ -78,15 +77,20 @@ struct OutputGroup size_t m_descendants{0}; CAmount effective_value{0}; CAmount fee{0}; + CFeeRate m_effective_feerate{0}; CAmount long_term_fee{0}; + CFeeRate m_long_term_feerate{0}; OutputGroup() {} + OutputGroup(const CFeeRate& effective_feerate, const CFeeRate& long_term_feerate) : + m_effective_feerate(effective_feerate), + m_long_term_feerate(long_term_feerate) + {} + void Insert(const CInputCoin& output, int depth, bool from_me, size_t ancestors, size_t descendants); std::vector::iterator Discard(const CInputCoin& output); bool EligibleForSpending(const CoinEligibilityFilter& eligibility_filter) const; - //! Update the OutputGroup's fee, long_term_fee, and effective_value based on the given feerates - void SetFees(const CFeeRate effective_feerate, const CFeeRate long_term_feerate); OutputGroup GetPositiveOnlyGroup(); }; -- cgit v1.2.3 From 416d74fb1687ae1d47a58c153d09d9afe0b6dc60 Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Mon, 31 Aug 2020 16:45:39 -0400 Subject: Move OutputGroup positive only filtering into Insert --- src/wallet/coinselection.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/wallet/coinselection.h') diff --git a/src/wallet/coinselection.h b/src/wallet/coinselection.h index 721f1a22eb..6e3b8c3915 100644 --- a/src/wallet/coinselection.h +++ b/src/wallet/coinselection.h @@ -87,11 +87,8 @@ struct OutputGroup m_long_term_feerate(long_term_feerate) {} - void Insert(const CInputCoin& output, int depth, bool from_me, size_t ancestors, size_t descendants); - std::vector::iterator Discard(const CInputCoin& output); + void Insert(const CInputCoin& output, int depth, bool from_me, size_t ancestors, size_t descendants, bool positive_only); bool EligibleForSpending(const CoinEligibilityFilter& eligibility_filter) const; - - OutputGroup GetPositiveOnlyGroup(); }; bool SelectCoinsBnB(std::vector& utxo_pool, const CAmount& target_value, const CAmount& cost_of_change, std::set& out_set, CAmount& value_ret, CAmount not_input_fees); -- cgit v1.2.3 From f6b305273910db0e46798d361413a7e878cb45f7 Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Thu, 1 Oct 2020 13:43:17 -0400 Subject: Explicitly filter out partial groups when we don't want them Instead of hacking OutputGroup::m_ancestors to discourage the inclusion of partial groups via the eligibility filter, add a parameter to the eligibility filter that indicates whether we want to include the group. Then for those partial groups, don't return them in GroupOutputs if we indicate they aren't desired. --- src/wallet/coinselection.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/wallet/coinselection.h') diff --git a/src/wallet/coinselection.h b/src/wallet/coinselection.h index 6e3b8c3915..5d9a410dce 100644 --- a/src/wallet/coinselection.h +++ b/src/wallet/coinselection.h @@ -62,9 +62,11 @@ struct CoinEligibilityFilter const int conf_theirs; const uint64_t max_ancestors; const uint64_t max_descendants; + const bool m_include_partial_groups{false}; //! Include partial destination groups when avoid_reuse and there are full groups CoinEligibilityFilter(int conf_mine, int conf_theirs, uint64_t max_ancestors) : conf_mine(conf_mine), conf_theirs(conf_theirs), max_ancestors(max_ancestors), max_descendants(max_ancestors) {} CoinEligibilityFilter(int conf_mine, int conf_theirs, uint64_t max_ancestors, uint64_t max_descendants) : conf_mine(conf_mine), conf_theirs(conf_theirs), max_ancestors(max_ancestors), max_descendants(max_descendants) {} + CoinEligibilityFilter(int conf_mine, int conf_theirs, uint64_t max_ancestors, uint64_t max_descendants, bool include_partial) : conf_mine(conf_mine), conf_theirs(conf_theirs), max_ancestors(max_ancestors), max_descendants(max_descendants), m_include_partial_groups(include_partial) {} }; struct OutputGroup -- cgit v1.2.3