UTXO Consolidation Explained

Explainers Dec 26, 2021

Published: 2021-12-26 at block 715,851
Bitcoin Price: $50,100

Table of Contents

Introduction

Sending Bitcoin transactions can get expensive. In previous blog posts, we’ve explored ways to mitigate transaction fees by:

  1. Sending transactions from Native SegWit Bech32 addresses and
  2. Setting 1 sat/vbyte fee rates for your transactions

Today, we’ll explore another way to save on mining fees: UTXO consolidation.

But first…

What is a UTXO?

A UTXO (Unspent Transaction Output) is an amount of bitcoin assigned to a Bitcoin address. Each time you receive any amount of bitcoin, you’re actually receiving a UTXO.

Example: UTXOs Received at Various Addresses

Contrary to popular belief, Bitcoin is not a system of accounts or balances. Instead, there are only UTXOs assigned to various addresses.

Your wallet sums up all your UTXOs to calculate your bitcoin balance.

Example: Wallets calculate balances by summing up UTXOs at various addresses

So what happens when you send bitcoin to another person?

To better visualize UTXOs in a Bitcoin transaction, let’s use physical cash as an example.

In your physical wallet, you have $1s, $5s, $10s, etc. When you’re buying something, you use those bills as “inputs” for your transaction.

For example, if you want to buy a book for $10, you’d use a $10 bill as your input. Once you’ve purchased that book, you've spent your physical dollars. Now your $10 belongs to someone else - the resulting output of your transaction.

Example: Sending $10 to someone else

But what if you don’t have the perfect inputs?

Let’s say you’re buying that same book for $10, but only have a $20 bill. In this case, you’d use your $20 as your input and instead create two outputs: $10 for the book seller and $10 as “change” for yourself.

Example: Sending $10 to someone else, receiving $10 as change

With this analogy in mind, you can think of UTXOs as the following:

A UTXO is to Bitcoin wallets, what cash is to analog wallets.

Each transaction consumes existing UTXOs and creates new ones. Your wallet will fund your transaction using your UTXOs as inputs and output new UTXOs.

In the cases where you don’t have the perfect amount of UTXOs for a transaction, you’ll receive a new UTXO back as change.

Example: Sending 3 BTC to someone and receiving 0.03 BTC in change

So now that we understand UTXOs…

What’s the issue with having too many UTXOs?

Imagine paying for a $100 item using only $1 bills. The vendor has a more burdensome task of counting all 100 $1 bills compared to just receiving one $100 bill right?

Bitcoin miners are similar. The more UTXOs you use as inputs for a transaction, the more burden miners have. As a result, Bitcoin miners will charge you more in transaction fees. Why?

There are many factors that affect your overall transaction fees.

As covered in other articles, the fee rate and address type you use affect your transaction fees. Additionally, the number of inputs and outputs you use also impacts your overall fees.

The more UTXOs you use as inputs, the larger the size of your transaction. The larger your transaction size, the more miners will charge you.

Using More UTXOs as Inputs Results in Larger Transaction Fees Paid to Miners

If you want to reduce the transaction fee you pay to miners, you want to use as few inputs as possible. Carrying a lot of UTXOs in your wallet will make them more expensive to spend later on.

So it’s important to reduce the number of UTXOs you have, to reduce your future transaction fees.

Fortunately, there’s a strategy to help you cut down on the number of UTXOs you have…

What is UTXO Consolidation?

UTXO consolidation helps you save on future transaction fees. It consumes your existing UTXOs and creates one new UTXO to an address you own.

Examples of UTXO Consolidation: one to the same address; another to a new address

Once you've consolidated your UTXOs, you've reduced the sizes of your future transactions. As a result, you've reduced your future mining fees.

It’s like going to a store and asking them to exchange a bunch of smaller coins (like 10,000 cents) for one larger bill (a $100). You only need to carry one bill and it’s less resource-intensive to spend in the future.

Example: Is it easier to hold and spend 10,000 pennies or one $100 bill?

Similarly, you only need one UTXO to transact. Any extra UTXOs make your future mining fees unnecessarily more expensive.

You might’ve noticed that a consolidation transaction looks like any other transaction.

You might be wondering: why not combine UTXOs later at the point of sale itself? Why consolidate UTXOs upfront and incur an extra transaction fee?

There are a few benefits to consolidating UTXOs in advance like this:

What are the Benefits of UTXO Consolidation?

In addition to the future fee savings mentioned above…

One benefit is that you get to choose when you consolidate.

You don’t want to be in a situation where you’re in a rush to spend unconsolidated UTXOs. If you’re pressed for time, you’ll likely pay high fee rates if there’s network congestion. You’ll also have to input many UTXOs to fund your transaction, resulting in a high transaction fee.

By consolidating UTXOs in advance, you control when you incur these costs.

You’ll still use many UTXOs as inputs, but if you consolidate at a low fee rate (ie. 1 sat/vbyte), you can cut your inevitable costs.

Consolidating UTXOs can be painful in the short term, but relieves a potentially much bigger pain in the future.

UTXO consolidation also gives you an opportunity to update your addresses. For example, you can “roll over” your legacy addresses’ UTXOs to a new Native SegWit Bech32 address.

In effect, you’re killing two birds with one stone. You're consolidating UTXOs and updating your addresses.

Example: Consolidating UTXOs from Native Segwit and Wrapped SegWit addresses into a new Native SegWit address

Finally, you reduce the entire Bitcoin network’s UTXO set by consolidating UTXOs. This makes it easier for anyone to run a full node. Reducing the UTXO set improves Bitcoin’s accessibility, decentralization, and security.

The Bitcoin Network’s Complete UTXO Set - a spike in 2017 with continued growth to ATHs this in 2021 (statoshi.info - unspent transaction output set https://statoshi.info:3000/d/000000009/unspent-transaction-output-set?viewPanel=6&orgId=1&from=now-5y&to=now&refresh=10m)

All this is rosy, but there have to be tradeoffs right?

What are the Disadvantages of UTXO Consolidation?

Well, you still have to pay a transaction fee to consolidate your existing UTXOs.

But the primary disadvantage of UTXO consolidation is that it’s harmful to privacy. Why?

You're connecting previously-unrelated addresses and UTXOs. It lets others know that these inputs are all controlled by the same entity.

Now an outside observer can track your previous UTXO addresses and histories. They can also track your future transactions.

Example: Chainalysis diagram https://twitter.com/chainalysis/status/1289355514564861954?s=20

Yet, this privacy issue isn’t as important for public entities.

For example, if a charity uses one static donation address, its UTXOs are available for all to see. In this case, UTXO consolidation would not leak any new information to an outsider.

This leads us to the question…

Who is UTXO Consolidation Useful For?

UTXO consolidation makes sense for entities who have many UTXOs. Like exchanges or merchants who receive many transactions.  

It also makes sense for those who use static public addresses.

Finally, individuals who prefer fee savings over privacy might find UTXO consolidation helpful.

So if you’re interested in consolidating UTXOs…

How do I Consolidate UTXOs?

You can simply send your max balance to an address you own.

Automatic Coin Selection by https://bitcoin.design/guide/payments/send/coin-selection/

If your wallet offers “coin control,” you can manually select which UTXOs you’d like to consolidate.

Manual Coin Selection by https://bitcoin.design/guide/payments/send/coin-selection/
Coin Control in Electrum Wallet https://bitcoinelectrum.com/how-to-spend-specific-utxos-in-electrum/

What is UTXO Batching?

Using many UTXOs as inputs or outputs increases a transaction’s size and respective fees.

UTXO batching creates many UTXO outputs to a variety of receivers in one transaction. By batching UTXOs, you reduce the number of change outputs you would've otherwise created. So batching helps you save on future fees too.

In other words, batching is to outputs what consolidation is to inputs.

Example: Batching UTXOs

Batching is very useful for entities that transact often. For example, employers can batch UTXOs when processing payroll payments to employees.

Exchanges often batch UTXOs when sending out “withdrawal” payments to their customers.

Real Example: 152 outputs in a batching transaction https://mempool.space/tx/6be9f2847cee23e2e6bd5543e50a3ca8245b7dc2165db9eb7d75af7c8f76713d

What is UTXO Management?

UTXO management is a topic outside the scope of this article.

But if you’re interested in using your UTXOs in the most cost-effective and privacy-preserving way, check out the following topics: labeling, coin control, and change avoidance.

Conclusion

In summary:

  1. UTXOs are to bitcoin wallets, what physical bills are to analog wallets.
  2. You use UTXOs as inputs to transactions, which increases the size of your transaction.
  3. The larger your transaction size, the more fees you must pay to miners.
  4. To reduce your future fees, you can consolidate UTXOs.
  5. You consolidate UTXOs by sending a new transaction to yourself at a low fee rate.
  6. Consider your privacy before consolidating UTXOs.
  7. You can also batch UTXOs if you’re looking to pay many recipients.
  8. UTXO management and coin control is for advanced users, but worth digging into.

If you found this article helpful, let me know on Twitter!

And don't forget to subscribe to the mailing list below:


Notes

  • Some addresses and transactions in the examples above are fictional to demonstrate concepts.
  • When you use UTXOs as inputs, you remove UTXOs from the UTXO set. You also output new UTXOs, adding to the UTXO set. In other words, UTXOs can only be used to fund new transactions as inputs. This helps prevent double-spending and fraud.
  • You can sum up the network's complete UTXO set to calculate the total circulating supply of bitcoin. This independent verification of the money supply is unique to Bitcoin. Try doing this with the USD money supply ;)
  • Each input adds 41 or more vbytes to a transaction. Usually 69 vbytes.
  • Maintaining a lot of UTXOs is not only bad for you. It’s also bad for the entire Bitcoin network: all Bitcoin nodes must manage and maintain the entire UTXO set. A bigger UTXO set requires more computational resources from each node.
  • You can't consolidate an unlimited number of UTXOs in a single transaction. You must conform to the dimensions of the block size.
  • Don't consolidate all your UTXOs if you need to spend BTC while you're waiting for confirmations. And only consolidate UTXOs that have already been confirmed.
  • Batching is sometimes called a “Distributing Transaction”

Tags