Glossary | UTXO
$2,620.25/BTCBuy

UTXO

A UTXO is an Unspent Transaction Output.

After an output has been "used up" in a transaction, it cannot be used again. So a spent output is like a corpse.

Unspent outputs, however, are alive. They are available to be used in new transactions (as long as you can unlock them), which makes them useful. That's why there is a distinction between spent outputs and unspent outputs (UTXOs).

Where are UTXOs used?

1. Verifying Transactions

A node will verify the transactions it receives by checking that its inputs have not already been spent.

So if you want to create your own bitcoin transaction, you must use UTXOs in your inputs:

The new transaction is referring to an unspent output. All good.

The new transaction is referring to an unspent output. All good.

However, if you try and use an output that has already been used in another transaction, your transaction will be rejected by nodes.

The new transaction is referring to a spent output. Nodes will reject this transaction.

The new transaction is referring to a spent output. Nodes will reject this transaction.

2. Address Balances

If you want to work out the balance of an address, add up all of the unspent outputs that are locked to that address.

UTXO Database

Because UTXOs are needed to verify every transaction your node receives, the UTXOs are stored in their own database.

~/.bitcoin/chainstate/

This database allows your node to quickly verify transactions, by checking to see if the transaction's inputs are available in the UTXO database.

Notes

gettxoutsetinfo

This command gives you stats on this UTXO database:

$ bitcoin-cli gettxoutsetinfo

{
  "height": 454974,
  "bestblock": "000000000000000001afbfe1209aee1882e8a8930bc1e020c4a37d98f72640d7",
  "transactions": 17707300,
  "txouts": 45845906,
  "bytes_serialized": 1791822745,
  "hash_serialized": "ed1bdcca4e08eb8270800d08b2f9dd7ce926f4ff9b1d7304b71c7a075a69098c",
  "total_amount": 16187023.59866495
}

Resources