Skip to content
Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.

Bitcoin UTXO Dump

Warning: This tool may corrupt your chainstate database. If it does, you will need to run bitcoind -reindex-chainstate the next time you run bitcoin, and this usually takes around a day to complete. It's not a terrible problem, but it can be annoying. I'm not entirely sure why it happens, so if you can figure out how to fix it, that would be cool.

You can get around this issue by first copying the chainstate database to an alternate location and then run bitcoin-utxo-dump pointing to this alternate location. Here's a example:

# 0. stop bitcoin daemon
bitcoin-cli stop

# 1. copy the chaninstate data to an alternative location
rsync --delete -av ~/.bitcoin/chainstate/ ~/bitcoin-chainstate-clone/

# 2. now run the bitcoin-utxo-dump pointing to this alternate location
bitcoin-utxo-dump -db ~/bitcoin-chainstate-clone/

Get a list of every unspent bitcoin in the blockchain.

The program iterates over each entry in Bitcoin Core's chainstate LevelDB database. It decompresses and decodes the data, and produces a human-readable text dump of all the UTXOs (unspent transaction outputs).

Example CSV Results:



First of all, you need to have a full copy of the blockchain. You also need to install LevelDB:

sudo apt install bitcoind
sudo apt install libleveldb-dev

After that, if you have Go installed you can do:

go install

This will create a binary called bitcoin-utxo-dump, which you can call from the command line:

$ bitcoin-utxo-dump

This will start dumping all of the UTXO database to a file called utxodump.csv.

NOTE: This program reads the chainstate LevelDB database created by bitcoind, so you will need to download and sync bitcoind for this script to work. In other words, this script reads your own local copy of the blockchain.

NOTE: LevelDB wasn't designed to be accessed by multiple programs at the same time, so make sure bitcoind isn't running before you start (bitcoin-cli stop should do it).


The basic command is:

$ bitcoin-utxo-dump

You can view the results in the terminal with the -v (verbose) flag (but this will make the script run about 3 times slower):

$ bitcoin-utxo-dump -v

The results will be written to the file in the current directory called utxodump.csv. You can choose your own filename with the -o option:

$ bitcoin-utxo-dump -o ~/Desktop/utxodump.txt

If you know that the chainstate LevelDB folder is in a different location to the default (e.g. you want to get a UTXO dump of the Testnet blockchain), use the -db option:

$ bitcoin-utxo-dump -db ~/.bitcoin/testnet3/chainstate/

By default this script does not convert the public keys inside P2PK locking scripts to addresses (because technically they do not have an address). However, sometimes it may be useful to get addresses for them anyway for use with other APIs, so the following option allows you to return the "address" for UTXOs with P2PK locking scripts:

$ bitcoin-utxo-dump -p2pkaddresses

You can select what data the script outputs from the chainstate database with the -f (fields) option. This is useful if you know what data you need and want to reduce the size of the results file.

$ bitcoin-utxo-dump -f count,txid,vout,address
$ bitcoin-utxo-dump -f count,txid,vout,height,coinbase,amount,script,type,address # all possible fields
  • count - The count of the number of UTXOs in the database.
  • txid - Transaction ID for the output.
  • vout - The index number of the transaction output (which output in the transaction is it?).
  • height - The height of the block the transaction was mined in.
  • coinbase - Whether the output is from a coinbase transaction (i.e. claiming a block reward).
  • amount - The value of the output in satoshis.
  • script - Details about the locking script placed on the output. For a P2PKH this is the hash160 of the compressed public key. For a P2PK script this a compressed public key (sometimes with a prefix to indicate that the original script contained an uncompressed public key). For a P2SH script this is the hash160 of the script. For everything else it's the complete scriptpubkey.
  • type - The type of locking script (e.g. P2PK, P2PKH, P2SH, P2MS, P2WPKH, P2WSH, or non-standard)
  • address - The address the output is locked to (this is generally just the locking script in a shorter format with user-friendly characters).

All other options can be found with -h:

$ bitcoin-utxo-dump -h


How long does this script take to run?

It takes me about 20 minutes to get all the UTXOs.

This obviously this depends on how big the UTXO database is and how fast your computer is. For me, the UTXO database had 52 million entries, and I'm using a Thinkpad X220 (with a SSD).

Either way, I'd probably make a cup of tea after it starts running.

How big is the file?

The file should be around 7GB (roughly 2.5 times the size of the LevelDB database: du -h ~/.bitcoin/chainstate/).

Again, this depends on how many entries are in the UTXO database, but it also depends what fields you choose to have in the results:

$ bitcoin-utxo-dump -f address # small file
$ bitcoin-utxo-dump -f count,txid,vout,amount,type,address # bigger file
$ bitcoin-utxo-dump -f count,txid,vout,height,coinbase,amount,nsize,script,type,address # biggest file

What versions of bitcoin does this tool work with?

This tool works for Bitcoin Core 0.15.1 and above. You can check your version with bitcoind --version.

Older versions of bitcoind have a different chainstate LevelDB structure. The structure was updated in 0.15.1 to make reading from the database more memory-efficient. Here's an interesting talk by Chris Jeffrey that explains how you could crash Bitcoin Core with the old chainstate database structure.

Nonetheless, if you really want to parse an old-style chainstate database, try one of the similar tools at the bottom of this page.

How does this program work?

This program just iterates through all the entries in the LevelDB database at ~/.bitcoin/chainstate.

However, the data inside ~/.bitcoin/chainstate has been obfuscated (to prevent triggering anti-virus software) and compressed (to reduce the size on disk), so it's far from being human-readable. This script just deobfuscates each entry and decodes/decompresses the data to get human-readable data for each UTXO in the database.

Can I parse the chainstate LevelDB myself?

Sure. Most programming languages seem to have libraries for reading a LevelDB database.

The trickier part is decoding the data for each UTXO in the database:

       type                          txid (little-endian)                      index (varint)
           \                               |                                  /
    key:   430000155b9869d56c66d9e86e3c01de38e3892a42b99949fe109ac034fff6583900

    value: 71a9e87d62de25953e189f706bcf59263f15de1bf6c893bda9b045 <- obfuscated
           b12dcefd8f872536b12dcefd8f872536b12dcefd8f872536b12dce <- extended obfuscateKey
           c0842680ed5900a38f35518de4487c108e3810e6794fb68b189d8b <- deobfuscated (XOR)
            /      |    \                   |
       varint   varint   varint          script <- P2PKH/P2SH hash160, P2PK public key, or complete script
          |        |     nSize
          |        |
          |     amount (compressesed)
   <------------------> \
          height         coinbase


  • This script was inspired by the bitcoin_tools repo made by Sergi Delgado Segura. I wanted to see if I could get a faster dump of the UTXO database by writing the program in Go, in addition to getting the addresses for each of the UTXOs. The decoding and decompressing code in his repo helped me to write this tool.

Similar Tools



Get a list of UTXOs (unspent transaction outputs) from your Bitcoin Core client.







No releases published


No packages published