1

The listunspent Bitcoin Core RPC method by default works only for addresses loaded in the wallet. Does it work for any address if the node has full index (txindex=1)?

(Technically it could I think, but since this is a 'wallet' RPC, it may be restricted.)

2 Answers 2

2

Correct, this is a wallet RPC, so it only deals with outputs belonging to the wallet.

If you want to query the entire unspent transaction output set, you can use the scantxoutset RPC. It doesn't even depend on txindex=1.

2
  • I have not considered scantxoutset, because it is marked experimental. It works, but I find it quite slow.
    – OptOut
    Nov 21, 2022 at 17:04
  • 2
    It's slow because it scans through the entire UTXO set, which is currently a few gigabytes of data. Nov 21, 2022 at 17:44
2

The Bitcoin Core Wallet tracks addresses associated with its own keys. listunspent is a wallet RPC that refers to the wallet data only. Beyond the wallet's tracking of its own data, Bitcoin Core does not have functionality to keep an address index regardless of whether txindex is used or not. I surmise that address tracking was never prioritized by a Bitcoin Core contributor (or even pushed back upon by others) due to the intended single-use nature of addresses.

If you want to keep track of UTXOs per address you may want to look into blockchain explorer projects such as esplora or mempool.space.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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