<p>In my application I would like to obtain the balance and UTXO set of some Bitcoin addresses. I'm primarily looking to achieve this using a full node (Bitcoin Core, RPC), but I am also open to other solutions. I run my own node.</p>
<p>Here are the solutions I have considered:</p>
<ol>
<li><p>Using <code>scantxoutset</code> RPC command. This works with any address, returns both UTXOs and total balance. However, it is rather <em>slow</em> (for testnet it is on the order of 1 minute, not sure on mainnet). Another disadvantage is that it does not show unconfirmed transactions.</p>
</li>
<li><p>Using <code>listunspent</code> RPC command. Unfortunately this works only with addresses that are loaded in the wallet of the node, so not with any addresses.</p>
</li>
<li><p>Using an external explorer site/API. This is not a good solution due to concerns about availability, trust (source of truth), and access (permissions, rate limits).</p>
</li>
<li><p>Using <code>blockbook</code> on top of the BTC node (e.g. <code>api/v2/utxo/&lt;address&gt;</code>). This seems to be a good solution, but it requires an extra piece of software.</p>
</li>
</ol>
<p>Eventually a notification solution for new transactions to a set of addresses would be also nice, but polling is a workable solution (e.g. every 10 secs, the set of addresses is typically small).</p>
<p><em>I would appreciate any other suggestions regarding how to achieve this with a full node, or involving some other available software.</em></p>
<p>I'm also curious how Lightning node implementations solve this, as they probably need very similar functionality (LND, C-lightning, LDK).</p>
<p>I include here for reference:</p>
<ul>
<li>links to RPC commands
<a href="https://developer.bitcoin.org/reference/rpc/scantxoutset.html" rel="nofollow noreferrer">scantxoutset</a>
<a href="https://developer.bitcoin.org/reference/rpc/listunspent.html" rel="nofollow noreferrer">listunspent</a></li>
<li><a href="https://github.com/trezor/blockbook" rel="nofollow noreferrer">Blockbook</a> and its <a href="https://github.com/trezor/blockbook/blob/master/docs/api.md" rel="nofollow noreferrer">API</a></li>
<li>and a <a href="https://bitcoin.stackexchange.com/questions/116058/does-listunspent-work-for-any-address-is-txindex-1">previous question</a> of mine regarding <code>listunspents</code> command</li>
</ul>

CC BY-SA 4.0
2022-12-06T13:12:07.423Z
Did you see https://bitcoin.stackexchange.com/a/116175/101498?
Antoine Poinsot
CC BY-SA 4.0
2022-12-06T13:15:04.550Z
No, I haven't, thanks for referencing.
OptOut
CC BY-SA 4.0
2023-01-03T08:34:07.443Z
Using an `Electrum` server is also another good solution for number 4.
OptOut
<bitcoin-core><lightning-network><balance><utxo-set><scantxoutset>
Obtaining balance/UTXOs of an address from Bitcoin Core, blockbook, or some other solution
OptOut
# Obtaining balance/UTXOs of an address from Bitcoin Core, blockbook, or some other solution

(Asked by: username_0 on 2022-12-06)

In my application I would like to obtain the balance and UTXO set of some Bitcoin addresses. I'm primarily looking to achieve this using a full node (Bitcoin Core, RPC), but I am also open to other solutions. I run my own node.

Here are the solutions I have considered:

1. Using `scantxoutset` RPC command. This works with any address, returns both UTXOs and total balance. However, it is rather *slow* (for testnet it is on the order of 1 minute, not sure on mainnet). Another disadvantage is that it does not show unconfirmed transactions.
2. Using `listunspent` RPC command. Unfortunately this works only with addresses that are loaded in the wallet of the node, so not with any addresses.
3. Using an external explorer site/API. This is not a good solution due to concerns about availability, trust (source of truth), and access (permissions, rate limits).
4. Using `blockbook` on top of the BTC node (e.g. `api/v2/utxo/<address>`). This seems to be a good solution, but it requires an extra piece of software.

Eventually a notification solution for new transactions to a set of addresses would be also nice, but polling is a workable solution (e.g. every 10 secs, the set of addresses is typically small).

*I would appreciate any other suggestions regarding how to achieve this with a full node, or involving some other available software.*

I'm also curious how Lightning node implementations solve this, as they probably need very similar functionality (LND, C-lightning, LDK).

I include here for reference:

* links to RPC commands
  [scantxoutset](https://developer.bitcoin.org/reference/rpc/scantxoutset.html)
  [listunspent](https://developer.bitcoin.org/reference/rpc/listunspent.html)
* [Blockbook](https://github.com/trezor/blockbook) and its [API](https://github.com/trezor/blockbook/blob/master/docs/api.md)
* and a [previous question](https://bitcoin.stackexchange.com/questions/116058/does-listunspent-work-for-any-address-is-txindex-1) of mine regarding `listunspents` command

**Tags:** bitcoin-core, lightning-network, balance, utxo-set, scantxoutset

> **Comments:**
> **username_1**: Did you see https://bitcoin.stackexchange.com/a/116175/101498?  
> **username_0**: No, I haven't, thanks for referencing.  
> **username_0**: Using an `Electrum` server is also another good solution for number 4.  

---

## 0 answers

