<p><a href="https://github.com/in3rsha/bitcoin-utxo-dump" rel="nofollow noreferrer">https://github.com/in3rsha/bitcoin-utxo-dump</a> seems to work well too, if you don't want to patch Bitcoin Core.</p>
<p>As per README, once you've fully synced the blockchain, quit the Bitcoin server and run:</p>
<pre><code>sudo apt install libleveldb-dev
go get github.com/in3rsha/bitcoin-utxo-dump
bitcoin-utxo-dump -db /path/to/.bitcoin/chainstate/
</code></pre>
<p>This produces a large <code>utxodump.csv</code> file with about 8GB size (about 2x the chainstate/ directory size) in 14 minutes when I tried it, with format:</p>
<pre><code>count,txid,vout,amount,type,address
1,033e83e3204b0cc28724e147f6fd140529b2537249f9c61c9de9972750030000,0,65279,p2pkh,1KaPHfvVWNZADup3Yc26SfVdkTDvvHySVX
2,e1c9467a885a156e56a29d9c854e65674d581ad75611b02290454b4862060000,1,9466355,p2pkh,1LpCmEejWLNfZigApMPwUY9nZTS8NTJCNS
3,a1f28c43f1f3d4821d0db42707737ea90616613099234f905dfc6ae2b4060000,1,339500,p2pkh,1FuphZ7xVPGrxthQT1S8X7nNQNByYxAT3V
4,818f5b9e3ede69da765d4c24684e813057c9b1f059e098661369b0a2ee060000,0,300000,p2pkh,18Y9yhjU9g2jjJmvaUy7TmUNZH9iPzQ4dd
5,d2f5e439152d076593a145581f8d76ea2e48ed155285b9a245cd42dd06070000,0,100000,p2pkh,1EKHTvovYWHfUJ6i9vsoidyTPQauCPH1qC
6,ea0c69fbd2389556b01771948ffc0507cf303bdc5a1b91b31acf9ecf6a070000,1,27668,p2pkh,1fkEhLpPKdmKtaxKdp4yDp1c87dF7GDub
7,05eafead65250a24b1592f8a006cbeab16a7b17ed2616507c5e0bd67bd070000,1,32000,p2pkh,15KmfJcGNfL29vpsSJ37uPzTQfr8Qe17Gq
8,2c0c985d384160d8c50c438bc67e639fe6047a7f2bac00a1238ca6a6d3070000,0,41936,p2pkh,17up1oPxBMTfZdehzy4v81KzLRHGDNX8ff
9,8261170b7ae26be70bd9e8f0e4bf19ce3571bb6464cdf9e478c471d372080000,1,4528208,p2pkh,1P6Ae7unrSjtx9J5SjWuwAdZBoWcbcjzBZ
...
</code></pre>
<p>Here's a quick script to import that CSV into sqlite3 which is more manageable:</p>
<pre><code>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'
</code></pre>
<p>I used that here BTW: <a href="https://github.com/cirosantilli/bitcoin-strings-with-txids/tree/7e95546479508e9fe5158dad6bc8601e2b4e02ee#utxo_nonstandard" rel="nofollow noreferrer">https://github.com/cirosantilli/bitcoin-strings-with-txids/tree/7e95546479508e9fe5158dad6bc8601e2b4e02ee#utxo_nonstandard</a> to try and find unspent puzzles that I might be able to solve, but I didn't :-(</p>

CC BY-SA 4.0
2024-10-18T01:56:45.220Z
Currently utxodump gives error: `Couldn't open LevelDB.` `file missing`.
pbies
CC BY-SA 4.0
2024-10-18T07:39:55.553Z
@pbies are you sure your bitcoin data isn't in a custom directory and try pointing to it with `-db`? E.g. bitcoin snap on Ubuntu has custom location `~/snap/bitcoin-core/`
Ciro Santilli OurBigBook.com
CC BY-SA 4.0
2024-10-18T12:07:20.490Z
Folders are ok.
pbies
CC BY-SA 4.0
2021-01-27T23:17:44.537Z
2022-02-05T16:21:24.780Z
2022-02-05T16:21:24.780Z
Ciro Santilli OurBigBook.com
<p>With vanilla Bitcoin Core, there is no efficient way to do this.</p>

<p>I see two options:</p>

<h3>a) Slow and very inefficient RPC loop (not recommended)</h3>

<ol>
<li>Get the genesis block hash (RPC <code>getblockhash 0</code>)</li>
<li>Get the block with all transaction (RPC <code>getblock &lt;hash&gt; 2</code>, <em>2 stands for verbosity with transaction</em>)</li>
<li>Loop through all transactions and all its outputs, call <code>gettxout &lt;txid&gt; &lt;n&gt;</code> (<em>where <code>n</code> is the outputs index</em>)</li>
<li>If <code>gettxout</code> returns an object, the output is unspent (UTXO), dump it to a text file</li>
</ol>

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

<h3>b) Fast way by patching Core (0.17.1)</h3>

<ol>
<li>Change the code of the function call <code>GetUTXOStats()</code>, apply a text file dump in the utxo set loop (<code>while (pcursor-&gt;Valid()) {</code>)</li>
<li>Compile</li>
<li>Call RPC <code>gettxoutsetinfo</code> and let your added code dump data per UTXO to a file (or similar)</li>
</ol>

CC BY-SA 4.0
2019-01-10T06:32:18.880Z
2019-01-10T06:32:18.880Z
Jonas Schnelli
<p>I know that UTXOs are stored in chainstate database.</p>
<p>But how can I get them in simple txt view? Not balances, but each UTXO.</p>

<development><utxo>
How to find all UTXOs?
Denis Leonov
# How to find all UTXOs?

(Asked by: username_0 on 2019-01-10)

I know that UTXOs are stored in chainstate database.

But how can I get them in simple txt view? Not balances, but each UTXO.

**Tags:** development, utxo


---

## 2 answers

### Answer by username_3 on 2019-01-10. Score: 10 | Accepted answer

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)


---

### Answer by username_1 on 2021-01-27. Score: 1

<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:

```
count,txid,vout,amount,type,address
1,033e83e3204b0cc28724e147f6fd140529b2537249f9c61c9de9972750030000,0,65279,p2pkh,1KaPHfvVWNZADup3Yc26SfVdkTDvvHySVX
2,e1c9467a885a156e56a29d9c854e65674d581ad75611b02290454b4862060000,1,9466355,p2pkh,1LpCmEejWLNfZigApMPwUY9nZTS8NTJCNS
3,a1f28c43f1f3d4821d0db42707737ea90616613099234f905dfc6ae2b4060000,1,339500,p2pkh,1FuphZ7xVPGrxthQT1S8X7nNQNByYxAT3V
4,818f5b9e3ede69da765d4c24684e813057c9b1f059e098661369b0a2ee060000,0,300000,p2pkh,18Y9yhjU9g2jjJmvaUy7TmUNZH9iPzQ4dd
5,d2f5e439152d076593a145581f8d76ea2e48ed155285b9a245cd42dd06070000,0,100000,p2pkh,1EKHTvovYWHfUJ6i9vsoidyTPQauCPH1qC
6,ea0c69fbd2389556b01771948ffc0507cf303bdc5a1b91b31acf9ecf6a070000,1,27668,p2pkh,1fkEhLpPKdmKtaxKdp4yDp1c87dF7GDub
7,05eafead65250a24b1592f8a006cbeab16a7b17ed2616507c5e0bd67bd070000,1,32000,p2pkh,15KmfJcGNfL29vpsSJ37uPzTQfr8Qe17Gq
8,2c0c985d384160d8c50c438bc67e639fe6047a7f2bac00a1238ca6a6d3070000,0,41936,p2pkh,17up1oPxBMTfZdehzy4v81KzLRHGDNX8ff
9,8261170b7ae26be70bd9e8f0e4bf19ce3571bb6464cdf9e478c471d372080000,1,4528208,p2pkh,1P6Ae7unrSjtx9J5SjWuwAdZBoWcbcjzBZ
...

```

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'

```

I used that here BTW: <https://github.com/cirosantilli/bitcoin-strings-with-txids/tree/7e95546479508e9fe5158dad6bc8601e2b4e02ee#utxo_nonstandard> to try and find unspent puzzles that I might be able to solve, but I didn't :-(

> **Comments:**
> **username_2**: Currently utxodump gives error: `Couldn't open LevelDB.` `file missing`.  
> **username_1**: @username_2 are you sure your bitcoin data isn't in a custom directory and try pointing to it with `-db`? E.g. bitcoin snap on Ubuntu has custom location `~/snap/bitcoin-core/`  
> **username_2**: Folders are ok.  

---

