-
Notifications
You must be signed in to change notification settings - Fork 114
WIP: Coin Selection Page #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
pavlenex
merged 41 commits into
BitcoinDesign:master
from
steady-eddie:feature/coin-selection-page
May 28, 2021
Merged
Changes from 10 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
a708bab
docs(payments): Change Intro
steady-eddie 311ae44
docs(payments): Header Image
steady-eddie dd5b25d
docs(payments): update tone, style, images, and spelling
steady-eddie cc2363d
docs(payments): update
steady-eddie c8c09c5
docs(payments): update image assets
steady-eddie 1f9903c
docs(payments): update current solutions
steady-eddie 7358f63
docs(payments): update automated solutions
steady-eddie fce96b2
docs(payments): update images and text
steady-eddie 1ca5d66
docs(payments): update header
steady-eddie 177462a
docs(payments): update references
steady-eddie 7ae8200
docs(payments): updated assets
steady-eddie 5aca651
docs(payments): update text and article structure
steady-eddie 9cf1172
docs(payments): update header image sizes
steady-eddie 289a48c
docs(payments): update image sizes
steady-eddie 4877e03
docs(payments): update image
steady-eddie 7a8ffa9
docs(payments): update structure
steady-eddie e90597c
docs(payments): update image folder
steady-eddie 2ab8555
Merge remote-tracking branch 'upstream/master' into feature/coin-sele…
steady-eddie c1616a4
docs(payments): update compressed images
steady-eddie 5c733f1
docs(coincontrol): updated structure and spelling
steady-eddie 849f170
docs(coinselection): update header size
steady-eddie 3c6fccc
Merge remote-tracking branch 'upstream/master' into feature/coin-sele…
steady-eddie b9cdb7e
docs(coin-selection): update content and structure
steady-eddie 84ade91
Merge branch 'master' into pr/90
pavlenex 1afe5b3
Apply suggestions from code review
pavlenex 281ad4f
Update guide/payments/coin-selection.md
pavlenex b67fab8
Update guide/payments/coin-selection.md
pavlenex f452f12
optimize images
pavlenex 37c5da1
optimize image batch 2
pavlenex 6d2d687
pros and cons visual formatting
pavlenex f193947
revert formatting
pavlenex a5c4e16
Apply suggestions from code review
pavlenex 42656ec
Update guide/payments/coin-selection.md
pavlenex bd6c627
Apply suggestions from code review
pavlenex 2b06aaa
Update guide/payments/coin-selection.md
pavlenex 65b942a
fix bad formatting that caused tests to fail
pavlenex dddc1b8
Add pros/cons formatting
pavlenex ed87478
Merge branch 'master' into feature/coin-selection-page
pavlenex fc72dc6
nest coin selection under send
pavlenex 9cd116b
Update coin-selection.md
pavlenex 22af876
formatting
pavlenex 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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,30 @@ | ||
| --- | ||
| layout: guide | ||
| title: UTXOs | ||
| nav_order: 1 | ||
| parent: Payments | ||
| permalink: /guide/payments/utxos/ | ||
| main_classes: -no-top-padding | ||
|
|
||
| --- | ||
|
|
||
| # Coin Selection | ||
|
|
||
| ## Intro | ||
|
|
||
| A UTXO is the amount of digital currency remaining after a bitcoin transaction has been executed - essentially, the unspent change left after someone completes a transaction, similar to the change someone receives after conducting a cash transaction at the store. They are processed continuously and are responsible for beginning and ending each bitcoin transaction. They might sound complicated, but they really are quite simple. | ||
|
|
||
| How does this relate to coin selection, you might ask? Because UTXOs allow for transactions to be conducted using miltiple fractions of bitcoin that do not all come from a single previous transaction. Instead, multiple fractions of bitcoin are retrieved by the algorithm to fulfill a spending request. For example, a purchase worth 1 bitcoin may retrieve 0.6 BTC from one byte and 0.4 BTC from another. Change from each of these fractions is then sent to the UTXO database to be spent at a later date. | ||
|
|
||
| For example, my wallet balance is 1 bitcoin (BTC). If I have recently mined a block, this could be a fresh whole bitcoin. However, it is most likely going to be an accumulation of UTXOs (change) from previous bitcoin transactions. So, a balance of 1 BTC is more likely to comprimise of: | ||
|
|
||
| - 0.25 BTC | ||
| - 0.01 BTC | ||
| - 0.56 BTC | ||
| - 0.04 BTC | ||
| - 0.24 BTC | ||
| - ... etc | ||
|
|
||
| These fractions are all UTXOs (unspent change) from previously mined coins. | ||
|
|
||
| Coin selection, therefore, is the choosing of which UTXOs to fund a bitcoin transaction with, in order words, the transactions inputs. | ||
|
pavlenex marked this conversation as resolved.
Outdated
|
||
This file contains hidden or 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,123 @@ | ||
| --- | ||
| layout: guide | ||
| title: Coin Selection | ||
| nav_order: 1 | ||
| parent: Payments | ||
| permalink: /guide/payments/coin-selection/ | ||
| main_classes: -no-top-padding | ||
| --- | ||
|
|
||
| {% include picture.html | ||
| image = "/assets/images/payments/coin-selection-header-0452403.png" | ||
| retina = "/assets/images/payments/coin-selection-header-0452403.png" | ||
| mobile = "/assets/images/payments/coin-selection-header-0452403.png" | ||
| mobileRetina = "/assets/images/payments/coin-selection-header-0452403.png" | ||
| alt-text = "Coin Selection" | ||
| width = 1600 | ||
| height = 900 | ||
| layout = "full-width" | ||
| %} | ||
|
|
||
| # Coin Selection | ||
|
|
||
| Coin selection is the process of choosing which of your Bitcoins to spend when creating and approving a spending transaction. To understand coin selection a little better, one must first have a decent knowledge of Unspent Transaction Outputs (UTXOs)[^2], the amount of digital currency remaining after a bitcoin transaction has been executed. | ||
|
pavlenex marked this conversation as resolved.
Outdated
|
||
|
|
||
| How does this relate to coin selection, you might ask? Because UTXOs allow for transactions to be conducted using miltiple fractions of bitcoin that do not all come from a single previous transaction. Instead, multiple fractions of bitcoin are retrieved by the algorithm to fulfill a spending request. For example, an outward transaction of 1.2 BTC may retrieve UTXOs worth 1 BTC and 0.5 BTC from a users wallet. Change (0.3 BTC) from this transaction is then sent back to the senders address in the form of one of more UTXOs. | ||
|
pavlenex marked this conversation as resolved.
Outdated
pavlenex marked this conversation as resolved.
Outdated
|
||
|
|
||
|  | ||
|
|
||
| Coin selection, therefore, is the choosing of which UTXOs to fund a bitcoin transaction with (i.e the transaction's inputs).[^1] | ||
|
|
||
| ## A Privacy Risk | ||
|
|
||
| Because each UTXO can be traced back on a public ledger to it's newly minted state (a whole bitcoin), we can unearth the digital footprints of bitcoin payments, potentially exposing the private data of senders, receivers, and their various wallet balances along the way (imagine a Russian doll that becomes fragmented into smaller and smaller pieces, contaminating itself with private data along the way). Coin selection, whether an automated or manual process, will most likely result in the breach of privacy for both you as well as your previous senders of bitcoin. However, there are various ways of mitigating how much data is exposed during each transaction. We can reduce this security risk in a few different ways, however, we are left with a design challenge. | ||
|
pavlenex marked this conversation as resolved.
Outdated
|
||
|
|
||
| How do we account for coin selection within a user flow of creating a bitcoin transaction, whilst minimising the risk of a privacy breach? | ||
|
|
||
| ### Scenario | ||
|
|
||
| `A user wants to make a payment of 0.6 BTC to their friend Joe and reveal the least amount of information about the bitcoin they own, and (ideally) they want it to be cheap. It is not an urgent payment.` | ||
|
|
||
| The user's wallet currently has a balance of **2.845 BTC**, and is comprised of 4 UTXOs: | ||
|
|
||
| - 1 BTC from Ed | ||
| - 0.5 BTC from Ed | ||
| - 0.845 BTC from Jane | ||
| - 0.5 from Joe | ||
|
|
||
| These UTXOs can also be grouped into "clusters" from the individual senders (see diagram). | ||
|
|
||
|  | ||
|
pavlenex marked this conversation as resolved.
Outdated
|
||
|
|
||
| #### The Transaction | ||
|
|
||
| Ideally, we want to expose the least amount of information possible to Joe, so it makes sense to use the 0.5 BTC (UTXO) originating from his address, as this does not compromise anyone else's privacy. In an ideal scenario, Joe's cluster contains enough bitcoin to fund the entire transaction request (0.6 BTC), however, in this case it does not. | ||
|
|
||
| The user (or their wallet) must therefore select additional coins to fund the transaction (equalling 0.1 BTC or more), thereby partially exposing coins from another cluster, and the address and balance data of contacts unrecognised by Joe (e.g Ed or Jane). *Note: we could of course use a single UTXO not originating from Joe's address (e.g 0.845 BTC from Jane) to fund the transaction, however, this would be a sure way of exposing Jane's address to Joe and should be avoided if possible.* | ||
|
|
||
| This additional 0.1 BTC could be funded in multiple different ways: | ||
|
|
||
| - **Option 1:** | ||
|
pavlenex marked this conversation as resolved.
Outdated
|
||
| - 0.5 BTC from Joe | ||
| - 0.845 BTC from Jane | ||
| - Total Output: 1.345 BTC (0.745 BTC change) | ||
| - Exposes: Jane to Joe | ||
| - **Option 2:** | ||
| - 0.5 BTC from Joe | ||
| - 0.5 BTC from Ed | ||
| - Total Output: 1 BTC (0.4 BTC change) | ||
| - Exposes: Ed to Joe | ||
| - **Option 3:** | ||
| - 0.5 BTC from Joe | ||
| - 1 BTC from Ed | ||
| - Total Output: 1.5 BTC (0.9 BTC change) | ||
| - Exposes: Ed to Joe | ||
|
|
||
|
pavlenex marked this conversation as resolved.
|
||
| ### The Challenge for Designers | ||
|
|
||
| In each of these scenarios, we are exposing the data of each previous UTXO owner. So the first question we are faced with is, how many people should we expose to Joe? However, we are also faced with the issue of exposing how much BTC we own to Joe. In option 1, Patrick knows I own *at least* 1.345 BTC. In option 2, 1 BTC. And in Option 3, 1.5 BTC. This is another consideration to take into account when selecting coins. | ||
|
pavlenex marked this conversation as resolved.
Outdated
|
||
|
|
||
| The questions designers and developers are faced with are: how much privacy to we want to inherently bake into our wallets payments? Do we want users to have manual selection over which coins they use to fund a transaction? Should this be an automated process? Finally, and perhaps most importantly, how do we translate this privacy risk to the user through the UI? | ||
|
pavlenex marked this conversation as resolved.
Outdated
pavlenex marked this conversation as resolved.
Outdated
|
||
|
|
||
| ### Solutions - Optimising for Privacy | ||
|
|
||
| #### Automatic Coin Selection | ||
|
|
||
| The ideal privacy oriented automated solution would be for bitcoin wallets to automatically select (a cluster of) coins to send from the payee's recognised address (e.g Joe), thereby minimising privacy exposure as a default standard. However, this relies upon there being an existing cluster recognised by the payee's address, as well as this cluster containing enough bitcoin to fund the outgoing transaction. If there is an additional sum of bitcoin required for the transaction input, or perhaps no recognised cluster of coins at all, the wallet could then default to one of the three following options (commonly used by bitcoin wallets today) for coin selection:[^3] | ||
|
pavlenex marked this conversation as resolved.
Outdated
pavlenex marked this conversation as resolved.
Outdated
|
||
|
|
||
| - **Oldest coins first (FIFO):** the default strategy spends the oldest coins first. | ||
| - **Minimize fees (optimize size):** the strategy spends the lowest number of coins to reduce the byte size of the transaction. This strategy results in a low network fee. | ||
| - **Minimize future fees (merge coins):** the strategy spends the maximum number of inputs so that a potential price rise does not make smaller coins economically unspendable. Indeed, if the price of a crypto asset increases too much, smaller coins may worth less than the cost of the network fees to spend them. | ||
|
|
||
| However, with these additional automated coin selection methods, there is likely to be some privacy breach (exposing one or more contact's balance or address, as well as your own to the payee). It would be the wallet provider's responsibility to show that there is some level of privacy risk being taken, and that sensitive information is being comprimised. *Which might then prompt...* | ||
|
|
||
|  | ||
|
|
||
| #### Manual Coin Selection | ||
|
|
||
| If a wallet owner wants to manually mitigate their own privacy risks (or those of others), they could manually select exactly which UTXOs they wish to fund the payment request with. This would need to total the input request (e.g 0.6 BTC), otherwise the transaction would fail. Ideally, the sender would be able to see which contacts/addresses would be exposed, and they can then select coins accordingly (as a precourser, this level of manual coin selection relies somewhat upon contact creation and transaction labelling[^4]. | ||
|
|
||
| Furthermore, in each of the following examples, the design (hierachy of coin information displayed) suggests the user starts of by selecting coins from an already recognised cluster (e.g Joe's) to minimise privacy exposure from the outset. The question therefore becomes, "If this recognised cluster does not contain enough coins to fund the entire transaction, which additional UTXOs/clusters shall I select, and who and what will I exposing in the process?" | ||
|
|
||
|  | ||
|
|
||
| Coin information could either be displayed by: | ||
|
|
||
| **a). Individual UTXOs** | ||
|
|
||
| - This standard privacy oriented coin selection method employed by wallets gives users full control over which exact coins they can select from. This might be multiple UTXOs from one contact, or a mixture of multiple contacts. This solution might be best in optimising for privacy when it comes to balance exposure, however, might also lead to more contacts becoming exposed to the payee. | ||
|
|
||
| **b). UTXO Clusters** | ||
|
|
||
| - This gives user control over which coins to send based on a variety of cluster options. Cluster options could be shown by either: | ||
| - x). Individual Contact Clusters - *minimising multiple contact exposures if possible, as well as enabling more control over balance exposure.* | ||
| - y). Mixed Contact Clusters - *based on the input required (using 1 or more contact's UTXOs), informing the sender of which contacts would become exposed to the payee. This option does not give as much control over balance exposure.* | ||
|
|
||
|
|
||
|
|
||
|
|
||
| [^1]: https://coincentral.com/what-is-coin-selection-and-why-does-it-matter/ | ||
| [^2]: https://www.investopedia.com/terms/u/utxo.asp | ||
| [^3]: https://support.ledger.com/hc/en-us/articles/360015996580-Using-Coin-control#:~:text=Before%20this%20new%20feature%2C%20all,to%20fulfill%20the%20transaction%20amount. | ||
| [^4]: https://www.reddit.com/r/WasabiWallet/comments/eb1zzo/the_importance_of_good_labels/ | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.