It is known, that UTXOs stored in chainstate database.

But how to get them in simple txt view? Not ballances, but each UTXO.


With vanilla Bitcoin Core, there is no efficient way to do this.

I see two options:

a) Slow and very inefficient RPC loop (not recommended)

  1. Get the genesis block hash (RPC getblockhash 0)
  2. Get the block with all transaction (RPC getblock <hash> 2, 2 stands for verbosity with transaction)
  3. Loop through all transactions and all its outputs, call gettxout <txid> <n> (where n is the outputs index)
  4. If gettxout returns an object, the output is unspent (UTXO), dump it to a text file

This may take a couple of hours or days (depending on your machine).

b) Fast way by patching Core (0.17.1)

  1. Change the code of the function call GetUTXOStats(), apply a text file dump in the utxo set loop (while (pcursor->Valid()) {)
  2. Compile
  3. Call RPC gettxoutsetinfo and let your added code dump data per UTXO to a file (or similar)

https://github.com/in3rsha/bitcoin-utxo-dump seems to work well too, if you don't want to patch Bitcoin Core.

As per README, once you've fully synced the blockchain, quit the Bitcoin server and run:

sudo apt install libleveldb-dev
go get github.com/in3rsha/bitcoin-utxo-dump
bitcoin-utxo-dump -db /path/to/.bitcoin/chainstate/

This produces a large utxodump.csv file with about 8GB size (about 2x the chainstate/ directory size) in 14 minutes when I tried it, with format:


Here's a quick script to import that CSV into sqlite3 which is more manageable:

echo | sqlite3 utxodump.sqlite3 \
-cmd 'CREATE TABLE utxo(
  count INT,
  txid CHAR(64),
  vout INT,
  amount INT,
  type CHAR(12),
  address CHAR(34)
)' \
-cmd 'CREATE UNIQUE INDEX utxo_txid_vout
  ON utxo(txid, vout);' \
-cmd '.mode csv' \
-cmd '.import utxodump.csv utxo'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.