mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
wallet: accurate SelectionResult::m_target
SelectionResult::m_target should be equal to actual selection target. Selection target is the sum of all recipient amounts plus non input fees. So we need to remove change_fee from the m_target. It's safe because change target is always greater than the change fee, so we can always cover fees if change output is created.
This commit is contained in:
@@ -166,6 +166,12 @@ std::optional<SelectionResult> SelectCoinsSRD(const std::vector<OutputGroup>& ut
|
||||
{
|
||||
SelectionResult result(target_value, SelectionAlgorithm::SRD);
|
||||
|
||||
// Include change for SRD as we want to avoid making really small change if the selection just
|
||||
// barely meets the target. Just use the lower bound change target instead of the randomly
|
||||
// generated one, since SRD will result in a random change amount anyway; avoid making the
|
||||
// target needlessly large.
|
||||
target_value += CHANGE_LOWER;
|
||||
|
||||
std::vector<size_t> indexes;
|
||||
indexes.resize(utxo_pool.size());
|
||||
std::iota(indexes.begin(), indexes.end(), 0);
|
||||
|
||||
Reference in New Issue
Block a user