HomePhabricator

wallet: Prefer full destination groups in coin selection

Description

wallet: Prefer full destination groups in coin selection

Summary:

  • wallet: Prefer full destination groups in coin selection

When a wallet uses avoid_reuse and has a large number of outputs in
a single destination, it groups these outputs in OutputGroups that
are no larger than OUTPUT_GROUP_MAX_ENTRIES. The goal is to spend
as many outputs as possible from the destination while not breaking
consensus due to a huge number of inputs and also not surprise the
use with high fees. If there are n outputs in a destination and
n > OUTPUT_GROUP_MAX_ENTRIES then this results in one or many groups
of size OUTPUT_GROUP_MAX_ENTRIES and possibly one group of size
< OUTPUT_GROUP_MAX_ENTRIES.

Prior to this commit the coin selection in the case where
n > OUTPUT_GROUP_MAX_ENTRIES was skewed towards the one group of
size < OUTPUT_GROUP_MAX_ENTRIES if it exists and the amount to be
spent by the transaction is smaller than the aggregate of those
of the group size < OUTPUT_GROUP_MAX_ENTRIES. The reason is that
the coin selection decides between the different groups based on
fees and mostly the smaller group will cause smaller fees.

The behavior that users of the avoid_reuse flag seek is that the
full groups of size OUTPUT_GROUP_MAX_ENTRIES get used first. This
commit implements this by pretending that the small group has
a large number of ancestors (one smallet than the maximum allowed
for this wallet). This dumps the small group to the bottom of the
list of priorities in the coin selection algorithm.

  • test: Improve naming and logging of avoid_reuse tests

This is a backport of Core PR17824

Test Plan:

ninja all check-all

Reviewers: #bitcoin_abc, jasonbcox

Reviewed By: #bitcoin_abc, jasonbcox

Subscribers: jasonbcox

Differential Revision: https://reviews.bitcoinabc.org/D7834

Details

Provenance
Fabian Jahr <fjahr@protonmail.com>Authored on Dec 29 2019, 00:58
deadalnixCommitted on Oct 9 2020, 00:19
deadalnixPushed on Oct 9 2020, 00:19
Reviewer
Restricted Project
Differential Revision
D7834: wallet: Prefer full destination groups in coin selection
Parents
rABCd899b47131c5: Merge #18546: Bugfix: Wallet: Safely deal with change in the address book [part…
Branches
Unknown
Tags
Unknown