Browsed by
Category: dash

Dash node address balance querying error – ‘No information available for address’

Dash node address balance querying error – ‘No information available for address’

1 Solution

For those weary Googlers looking for the solution to the above error from the dash-cli.  When starting the dash daemon, the -addressindex=1 option must be set. If the blockchain has already been downloaded, you can enable address indexing by following the below steps:

  1. stop the daemon
  2. restart the daemon with the addressIndex and reIndex option enabled:
    dashd -rpcallowip=::/0 -reindex=1 -addressindex=1 -txindex=1
  3. wait for the blockchain to reindex

NOTE: enabling address indexing will increase the dash disk usage from about 3GB to 5GB (as of time of writing).

2 Problem

I recently starting working in blockchain and cryptocurrency development. My first hands-on project involved setting up a RESTApi that would directly talk with a Dash node daemon through the dash-cli command. I know, I could have just used an existing api implementation, like insight-api-dash, but that would be too easy.

I set up a dash node using a modified Dockerfile from docker-dashd. However, testing the node with the sample command:

dashd getaddressbalance '{"addresses": ["XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg"]}'

Resulted in the error message ‘No information available for address‘. Google searches resulted in no solutions; I decided to delve into the dash source code.

3 Discovery

After downloading the source and searching for the particular error string, I found the error getting returned from the getaddressbalance rpc procedure (rpcmisc.cpp):

for (std::vector<std::pair<uint160, int> >::iterator it = addresses.begin(); it != addresses.end(); it++) {
    if (!GetAddressIndex((*it).first, (*it).second, addressIndex)) {
        throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address");
    }
}

Interesting…but not really useful for figuring out why the procedure wasn’t returning the expected data. I needed to dig a little further, so I looked into the GetAddressIndex function. The function performed a few precondition checks that potentially would log an error message. I had previously checked the docker logs for the container but must have missed any meaningful messages. I took a closer look at the logs and found an interesting error message, ‘address index not enabled‘.

I was getting close and realized I probably missed an option during the initial start of the daemon. With more than 100 options to use, I wasn’t surprised. A few more minutes of digging and I found the answer I needed in main.cpp:

fAddressIndex = GetBoolArg("-addressindex", DEFAULT_ADDRESSINDEX);

Turns out I need to explicitly enable addressIndexing to perform the getaddressbalance and other address specific queries.

4 Solution

Once the problem was known, the solution is fairly simple. I just needed to restart the dash daemon with address indexing enabled.

Take #1, I stopped the daemon, added the option to the command, and restarted. I attempted another getaddressbalance and I received the same error message. Confused, I took a look at the logs and was greeted by an error message stating I needed to specify the -reindex=1 option for address indexing to take effect.

Take #2, I stopped the daemon, added the two options, restarted the daemon, executed the query and success!