Bitcoin

Lightning Network – Get balance/UTXO of an address from Bitcoin Core, Blockbook or other solutions

In my application, I want to get the balance and UTXO set of some Bitcoin addresses. I’m primarily trying to achieve this using full nodes (Bitcoin Core, RPC), but I’m open to other solutions as well. I run my own node.

Here are the solutions I considered:

  1. use scantxoutset RPC command. This works for any address and returns both the UTXO and the total balance. But it is rather slow (On testnet it takes about a minute, not sure on mainnet.) Another downside is that it doesn’t show unconfirmed transactions.

  2. use listunspent RPC command. Unfortunately, this only works for addresses loaded into the node’s wallet and not for other addresses.

  3. Use 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. use blockbook On top of a BTC node, e.g. api/v2/utxo/<address>). This seems like a good solution, but requires additional software.

Ultimately, a notification solution for new transactions on a set of addresses would be nice, but polling is a viable solution (e.g. every 10 seconds if the address set is small).

Any other suggestions on how to achieve this using a full node or other available software would be appreciated.

I’m also curious how Lightning node implementations solve this problem, as they may require very similar functionality (LND, C-lightning, LDK).

I’m including it here for reference.

Related Articles

Back to top button