What Is Coin Selection and Why Does It Matter?
Coin selection is the process that describes how the algorithms driving Bitcoin choose which of your Bitcoins to spend when you approve a spending transaction.
If you have 1.2 BTC in your wallet and you pay out 0.3, you have 0.9 BTC left, right?
Well, yes. But it isn’t necessarily that simple. After all, you can have $100 in your physical wallet. That $100 could comprise two fifties, or it could be five twenties, or 100 one-dollar bills. Each time you spend one of those paper notes, you will likely get some change back. Over time, if you keep paying with bills, you’ll only have a pile of nickels and dimes left over.
That 1.2 BTC in your digital wallet is no different. The difference with BTC is that when you approve a BTC spend, you also have to pay the transaction fees. So the process of choosing which specific Bitcoins are handed over in the spend is more of a costly one.
Coin Selection in Action
Let’s go back to your hypothetical wallet with 1.2 BTC in it. Knowing it’s unlikely that you actually have one whole BTC and 0.2 BTC, let’s assume you have the following:
- 0.5 BTC
- 0.4 BTC
- 0.2 BTC
- 0.1 BTC
Now, when spending 0.3 BTC, you’d hope the algorithm would combine the 0.2 and 0.1 BTC to reach the spend value. It makes good sense, and given how Bitcoin calculates fees, there are lower costs in doing it this way.
The good news is that this is likely to happen. However, this is only since the Bitcoin developer team updated the algorithm earlier this year, to ensure more streamlined coin selection. Before this update, the coin selection process was a little less sophisticated.
Continuing with the above scenario, when you approved the 0.3 BTC spend, the older version of the algorithm would almost always create a change output. This means it would invariably have taken the 0.4 or 0.5 BTC, and return the change of 0.1 or 0.2 BTC to your wallet, less the fees.
While the algorithm update is good news for the future, the fact is that there are years of Bitcoin transactions that happened before this update. This has created a digital equivalent of everyone having a wallet comprising 70% nickels and dimes, and perhaps 30% notes of value. The difference being that you can’t take your Bitcoin wallet into the bank and ask them to change all of those Satoshis back into Bitcoins for you.
How Does This Happen?
Bitcoin runs on a concept called UTXO, or unspent transaction output. This is essentially the same concept that prevents a double-spend from happening. Each time a spend transaction is authorized, the Bitcoin algorithm ensures that the wallet contains at least the value of the spend plus fees before the PoW consensus protocol approves the transaction.
Bitcoin opted for the UTXO mechanism because it keeps the proof of work algorithm simple. It also permits parallel processing across multiple accounts, which enhances scalability. Finally, it allows for Simple Payment Verifications (SPV), lightweight clients that can verify a payment’s inclusion in the blockchain without downloading the full database.
However, UTXO has some drawbacks. Most notably, it doesn’t work for smart contract platforms given that each output can only be owned by one person. As explained by Vitalik Buterin, this is why Ethereum opted for a different model, often called the Account/Balance Model. Although this model offers some benefits over UTXO, scalability is not one of them. Thus, for all the many benefits Ethereum offers, scalability is an issue that continues to plague its developers.
The upshot is that yes, Bitcoin has now updated the algorithm. Coin selection is a more sophisticated process as a result, targeting UXTO values that best match transaction value. But, the situation remains that there are many, many tiny pieces of Bitcoin now circulating.
Last year, one Bitcoin developer attempted a complex calculation to work out the possible value of these tiny pieces. He concluded that Bitcoin is comparable to a vault, two-thirds full of low-value trinkets, and one-third full of high-value items. Eventually, fees for moving the trinkets out of the vault could end up being more than the value of the trinkets themselves.
A Possible Solution?
It was blockchain developer Mark Erhardt who first proposed how to optimize the Bitcoin coin selection algorithm. Although, it was Andrew Chow who implemented the update. Erhardt now works for BitGo, which develops enterprise cryptocurrency solutions for institutional investors. There, he has developed Predictive UTXO, which helps to offset the fees involved in spending many small UXTO values.
Bitcoin transaction fees are lower when there is less traffic on the network, and much higher when traffic is high. This is why many people were complaining about high fees during December 2017 when Bitcoin’s value spiked at nearly $20k.
Predictive UTXO uses an algorithm to bundle together the tiniest fragments of BTC in transactions when fees are lower. When fees go up, it will minimize transaction sizes to offset the increase. In this way, Predictive UTXO is saving up to 30 percent on fees for BitGo clients.
If Predictive UTXO could be rolled out across other exchanges and wallets, it will provide some cushioning against the fees involved in spending the tiny BTC fragments that now exist in many of our wallets.
If you’re interested in knowing more about coin selection in general, here is an excellent presentation explaining coin selection and UTXO in detail. Warning: it is a long one!
Some people may consider that fees are so small so as not to matter. While fees can end up being pennies on the dollar, savvy investors know that compound interest matters. If we can reduce fees and reinvest the difference, they are potentially worth far more in years to come. At least, assuming the price of BTC goes up.
As my grandmother used to say, take care of the pennies, and the pounds will take care of themselves. Pounds refers to sterling, but the principle also stands for dollars – and your Bitcoins.
This week in crypto: Craig Wright sues everyone, Forbes rolls out the blockchain three comma club, and...
There is much to understand when discussing the current state of Bitcoin mining energy usage and how...
Will Bitcoin ever replace fiat? We take a sober view of some fundamental differences and ponder why...
ABOUT THE AUTHOR
ABOUT THE AUTHOR
Sarah ran away from a corporate job so she could travel the world. After doing that, she found herself a much-loved new career as a freelance blockchain technology writer. She’s authored and ghostwritten more than 250 pieces on blockchain and cryptocurrencies. In addition to writing and researching, she also runs her own websites – find out more at sarahrothrie.com. You can usually locate her somewhere near the food.