• Forum has been upgraded, all links, images, etc are as they were. Please see Official Announcements for more information

How to get other wallet's balance using dash-cli

programonauta

New member
Is it possible get the balance of an specific address (not stored on my computer) using dash-cli?

I mean: I'd like the same result using the API, but my goal is only to understand how it works behind the scenes, inspecting the source code, not an actual problem that could be solved using API.

Thanks
 
What API?

Hi @demo,

Calling this API: explorer.dash.org / chain/Dash/q/addressbalance (I put some spaces in URL due Forum software was blocking my post with the complete URL)

I get the balance, but I'd like to know if there is some way to explore blockchain in the dash-cli.
 
Exactly, what I'd like to know is how to gather the information using dash-cli.
Dash-cli is similar to bitcoin-cli which seems better documented.
Read there in order to gather whatever information you may want (except the governance info which is dash specific)
https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list

Or even better, use as documentation source the console of your dash-qt.

You should use the "getaddressbalance" call of your dash-cli
 
Last edited:
I'm still a bit confused, it looks like the dash-cli commands refer only to addresses on the wallet stored on the local machine.

For instance I got a actual transaction on blockcypher, see this link.

And when I try to get info of this transaction I got:

Code:
$ dash-cli gettransaction "ec9d79c55135a70a55ef6078487d1274d9aae404fd1bd004e3f495e4d38e440e"
error code: -5
error message:
Invalid or non-wallet transaction id
 
Your question is about blockgeeks?

I registered in the very beginning of this site and some times I look some articles.

But what grabbed my attention was the values in ETH on each question. Does some one pay for answered questions?

Yes. They do pay. Interesting isnt it?
And I really wonder, if people are paying for questions, why you and me should answer questions for free?
What is our motivation to do everything for free, while others are paid for doing the same job?
 
Last edited:
Yes. They do pay. Interesting isnt it?
And I really wonder, if people are paying for questions, why you and me should answer questions for free?
What is our motivation to do everything for free, while others are paid for doing the same job?

Maybe I still see in a "romantic" way, but I do believe in the power of community. I do with others what I'd like people do with me.

The interesting thing is that normally we receive much more than we give, mainly because when we face some problems that someone already faced before and the community solved and turn it publish.

I'm 51 years old, when I started programming computers there was no internet, neither this idea of free software, open source, something like that. Was very difficult get information when you got stuck in a problem. I had tons of books, reference cards, magazines...
 
Coming back to the topic,

Looking for in the Bitcoin documentation, I found out the bx (bitcoin explorer) in this repo of github.

But I didn't find any repo like that to Dash
 
Starting dashd with the -addressindex argument will cause it to reindex the entire blockchain and allow you to query balances of addresses not included in your wallet. This function is usually used for the dashd powering websites like block explorers, and the indexing can take some time.
See here for documentation on command line arguments: https://dashpay.atlassian.net/wiki/spaces/DOC/pages/48136206/Command+line+arguments
 
Hi @strophy

Probably I'm doing something wrong.

I started dashd with -addressindex, and I'm sure it's runnning for a long time (about 7hours), and when I try get balance from any address I get zero.

Code:
$ ps -ef | grep dash
ricardo  11409     1  6 11:27 ?        00:25:00 dashd -addressindex -daemon
ricardo  11436 11144  0 18:17 pts/0    00:00:00 grep --color=auto dash

$ dash-cli getbalance '{"addresses": ["XmzFesqawm8JrpsmNg4S93Pg6joXGd9rxF"]}'
0.00000000

Verifying on Dash Explorer, the balance of this Address is 0.30647744 DASH.
 
Last edited:
@strophy Yes, the CLI argument (addressindex) is correct. FYI - you can add the following to your dash.conf file if you want to always start with that option enabled:
Code:
addressindex=1

@programonauta If I understand your question, the `getaddressbalance` RPC command that @demo mentioned is the one that does what you are attempting to do.

Hi @thefez, I tried the getaddressbalance command and the output was:

Code:
$ ps -ef | grep dashd
ricardo     17     1  0 15:30 ?        00:00:25 dashd -addressindex -daemon
ricardo     60     2  0 18:25 tty1     00:00:00 grep --color=auto dashd

$ dash-cli getaddressbalance '{"addresses": ["XmzFesqawm8JrpsmNg4S93Pg6joXGd9rxF"]}'
error code: -5
error message:
No information available for address

The main objective to me is understand how to explore blockchain, and then study the source code to (who knows) start to contribute with some code, trying to solve issues etc.

If you guys have another path to achieve this, I appreciate :)
 
@programonauta I think I have seen that error when my index was not present or incomplete. For what you are doing, I would recommend using Testnet (start dashd with the
Code:
-testnet
argument). Its blockchain is smaller, so you will be able to reindex faster. You will also be able to experiment with things without risking any funds.

I just re-enabled addressindex on my Testnet node and started it with -reindex. It now returns balance info for a randomly selected Testnet address. I think you are almost there. I would definitely try Testnet though.
 
Back
Top