spesmilo / spesmilo/electrum

CoinChooser is prone to create dust

Open
#4,853 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement ✨ topic-wallet 👛
Dominant language
Python
Stars
8.6k
Forks
3.5k
Avg merge
2d 8h
Merged PRs (30d)
61

Description

The default (and currently only) coin selection policy is unlikely to spend small value coins.

This is due to strip_unneeded:
https://github.com/spesmilo/electrum/blob/75e30ddc9dd97f11db19d609d0d1d4780dc3885a/electrum/coinchooser.py#L81-L88

There are (at least) three things to optimise for in a coin selection policy:

  1. user's privacy
  2. fee cost to the user
  3. health of network (e.g. number of UTXOs)

This behaviour is good for the user's privacy in most cases, as selecting a few large value inputs links together fewer coins than selecting many small value inputs.
It is however bad for the network (there will be more UTXOs overall). Further, if feerates rise such that the effective value of the UTXO becomes negative, it will never be spent, making the pollution permanent.


We could have another coin selection policy which consolidates UTXOs. One nice but complex idea would be to monitor historical fee levels. During local minimums it's better to spend many small value inputs; and if fees are high, it's better to spend few high value ones. This would also be cheaper for the user.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading electrum/coinchooser.py, especially the linked strip_unneeded implementation, to understand how the current coin selection policy avoids small-value coins. The issue discusses privacy, fee cost, and UTXO health but does not define a concrete policy or acceptance criteria, so done would require an agreed design and corresponding tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
blockchain
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.