1

I'm looking to create an index on addresses in my bitcoin full node in order to fetch the balances of a list of addresses from the blockchain for an academic project without using the public explorers. For that I installed the Bitcoin Core client (version 22) and configured it as follows:

# [core]
# Maintain a full transaction index, used by the getrawtransaction rpc call.
txindex=1
addrindex=1

# Maintain coinstats index used by the gettxoutsetinfo RPC.
coinstatsindex=1
# Run in the background as a daemon and accept commands.
daemon=1


# [rpc]
# Accept command line and JSON-RPC commands.
server=1
# Accept public REST requests.
rest=1
# rpc auth settings
rpcauth=*******

dbcache=1000

And after that, I installed the bitcoin-rpc-explorer to create a private explorer which is pointed to my bitcoin node correctly (below in my env file for this explorer with the rest of the parameters set to default):

BTCEXP_COIN=BTC
BTCEXP_BITCOIND_HOST=127.0.0.1
BTCEXP_BITCOIND_PORT=8332
BTCEXP_BITCOIND_USER=*******
BTCEXP_BITCOIND_PASS=*******
BTCEXP_BITCOIND_COOKIE=/path/to/bitcoind/.cookie
BTCEXP_BITCOIND_RPC_TIMEOUT=5000

However, when I insert an address in the search bar, I get this message

No address API is configured.
See the example configuration file for help setting up an address API.

which points me to the sample config file of the bitcoin node github repo (https://github.com/janoside/btc-rpc-explorer/blob/master/.env-sample)

so I checked my node's indexes with the getindexinfo command and I got this:

{
  "txindex": {
    "synced": true,
    "best_block_height": 764153
  },
  "coinstatsindex": {
    "synced": true,
    "best_block_height": 764153
  }
}

So it would seem that addrindex is not working for some reason. I did some research and a comment mentioned that support for this index has been removed from recent versions of Bitcoin Core and that I should use an Electrum server and Electrum Wallet for this and another link mentioned an addrindex patch to install.

So does anyone know what exactly to do in this situation and what the optimal solution is? And is there any recommended addrindex patch for Bitcoin Core if any?

3
  • addrindex has never been a supported feature in Bitcoin Core. Commented Nov 21, 2022 at 17:53
  • is there any alternative for it that you know of? How do the public blockchain explorers provide the service of viewing an address' data and balance so quickly?
    – Helmi
    Commented Nov 22, 2022 at 11:11
  • There are lots of software indexers, including Electrum servers like electrs, that can provide pre-aggregated address information. Bitcoin Core just isn't one of those. Commented Nov 22, 2022 at 14:01

1 Answer 1

1

So does anyone know what exactly to do in this situation and what the optimal solution is?

I don't, however the btc-rpc-explorer document you referred to) says

# Select optional "address API" to display address tx lists and balances
# Options: electrum, electrumx, blockchain.com, blockchair.com, blockcypher.com

Which seems to me to suggest you might need one of those to use with the addrindex api it provides.


I'm looking to create an index on addresses in my bitcoin full node in order to fetch the balances of a list of addresses from the blockchain for an academic project without using the public explorers.

This seems like it might be similar to How can I take a "snapshot" of the bitcoin blockchain and analyze it? - maybe you could consider a similar approach and perhaps build your own indexes if you need to track changing balances forward in time?

If the number of addresses of interest is small and known in advance, I think you can import them and perform a rescan and then use the Bitcin core RPC API getbalance, getbalances or listreceivedbyaddress to retrieve balances for those specific imported "watch-only" addresses.


Related:

5
  • Yes, I've seen the optional address api which seems to tae an electrum server as input or some other public server. but I dont understand the need for one of those. Shouldn't Bitcoin core support such a necessary index? I did some research on ElectrumX and it seems to require some similar resources to that of the bitcoin full node, which what I'd like to avoid. So I'm looking into exploring the addrindex patches if there's any decent functioning one. Unfortunately, the number of addresses is not small enough to insert them manually, for each rescan takes about a minute (I've tried it)
    – Helmi
    Commented Nov 22, 2022 at 9:08
  • I guess Bitcoin core is primarily a wallet and not a research tool. Obviously a wallet only needs to keep an index of addresses and transactions relevant to the normal wallet user. That is those relating to private keys in the wallet or to imported addresses Commented Nov 22, 2022 at 12:04
  • is there any way to create this address index? I've seen mention of addrindex patch to the bitcoin core and mention of electrum server and electrum wallet but I'm not sure if it will help me reach what I want.
    – Helmi
    Commented Nov 22, 2022 at 13:55
  • See amended answer. Patch seems abandoned. Writing your own index seems worth considering. Either from block data or using callback? Commented Nov 22, 2022 at 14:12
  • Bitcoin Core is primarily a full node, which is used to create your own verified copy of the UTXO set (the “ledger”), by parsing the blockchain (the “transaction journal”). It's not a block explorer. Bitcoin Core has never provided address information with the exception of the Bitcoin Core wallet tracking its own addresses.
    – Murch
    Commented Dec 23, 2022 at 20:32

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.