This repository has been archived by the owner on Aug 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
[Coin Selection Chapter] Add outline and initial notes #22
Open
murchandamus
wants to merge
1
commit into
bitcoinops:master
Choose a base branch
from
murchandamus:coin-selection
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Intro | ||
Coin Selection refers to the process of picking inputs from a wallet's Unspent Transaction Output (UTXO) Pool to fund a transaction. | ||
|
||
# Problem Description | ||
First and foremost, the selected input set must provide sufficient funds to pay for the transaction's intended outputs at the determined fee rate. | ||
The selection hereby has a bit of recursive feedback on the selection target in that it determines the necessity of change outputs, additional witness bytes to the transaction header, and inputs need to pay for their own inclusion. | ||
After achieving these requirements, other considerations come into play. | ||
|
||
# Dimensions of the Problem | ||
|
||
## Smallest transaction pays lowest fees | ||
Generally, the smallest possible transaction is the cheapest to get included in a block. | ||
So, it may seem obvious that one could save fees by always building transactions with a single input. | ||
However, this would likely require the creation of a change ouput which would mean that the sending wallet's UTXO count would remain constant, while new UTXO get created for the recipients. | ||
If the wallet also frequently receives incoming transactions, optimizing for this dimension exclusively can lead to a quickly bloating UTXO pool. | ||
|
||
## Every UTXO has to be spent eventually | ||
Given that Bitcoin balance is only accessible[^1] by spending the corresponding UTXO, every UTXO must be spent eventually. | ||
Assuming that there will be some periods of time in the future in which block inclusion remains continuously restricted to high fee rates, it may be preferable to spend low-value UTXO at earlier low-fee periods. | ||
Otherwise, low-value UTXO may become economically unspendable for the duration of such a fee rate spike when the cost to spend a UTXO exceeds the UTXO's value. | ||
Strategies to pre-empt this situation include consolidating UTXO periodically, using different coin selection strategies at different fee rate levels, or simply prioritizing the consumption of low-value UTXO. | ||
|
||
## Privacy | ||
While Bitcoin has some nice privacy property in the sense that payments are associated only with a pseudonym of the owner rather than their identity immediately, it is far from anonymous. | ||
Where people are concerned to limit their traceability and improve their privacy, they may have vastly different requirements for their coin selection. | ||
Chainalysis has generally been doing well to assume that any UTXO used together in one transaction indicate being owned by the same wallet. | ||
[Coinjoin with 100 participants via Wasabi] | ||
[Spend everything from same address.] | ||
[Address reuse.] | ||
[Manual selection.] | ||
[Separation of funds by concerns.] | ||
[Coinjoin with recipient.] | ||
|
||
## Individual Usage Pattern | ||
- Small UTXO Pools for end-users | ||
- Large incoming to outgoing imbalance for merchants | ||
- High frequency of sending makes batching viable and attractive | ||
- Sending frequency correlated with trading activity corresponds to times of high fees (-> consolidations) | ||
|
||
## Global UTXO Set | ||
- CONOP influence of large UTXO Set | ||
|
||
## Significance of omitting change outputs | ||
|
||
# Simple workable solution: Random Selection | ||
|
||
# Heuristic-based UTXO Management, e.g. Branch and Bound | ||
|
||
# Coin Control | ||
|
||
# Do nots | ||
## Largest First Selection | ||
|
||
# Additional UTXO Management Strategies (link to consolidation and batching) | ||
# Outlook: New Address formats | ||
|
||
[^1]: Barring direct transfer of UTXO ownership e.g. per hardware wallets or layer-two constructions such as state-chains. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we mention needing to refresh timelocks? For example, the Green wallet considers this in their coin selection algorithm. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to make sure this bullet point is capturing what I think it is, we plan to write about the 2nd point in Jameson's post, "For high volume wallets that send more than one transaction every few blocks it’s important to keep plenty of confirmed UTXOs available."
https://medium.com/@lopp/the-challenges-of-optimizing-unspent-output-selection-a3e5d05d13ef
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that was mostly based on the notion that every transaction performs only a single payment. Wallets that batch payments can subsist on way fewer UTXOs.