How do you get the balance of an address in your wallet using the rpc interface?

3

1

The current rpc interface only allows you to see either 1. The balance of the entire wallet 2. How much was received by an address (which is okay... if you never spend)

Basically, I want to know how to get the balance of a specific address in my wallet. I've searched high and low and cannot find anything.

Randy McKnight

Posted 2012-07-15T22:08:55.673

Reputation: 33

Answers

3

If you are only using Bitcoin through RPC commands, you might want to look into accounts. Using those you can just call getbalance and you will know how much Bitcoins are in each of the accounts.

If you are using only addresses, you can only see how many Bitcoins you received with it through listreceivedbyaddress, which can be not reliable if you spend any money from them.

All in all, you ought to just use accounts, as they can encompass many addresses and provide a lot of functionality for separating your coins into many parts in the same wallet.

ThePiachu

Posted 2012-07-15T22:08:55.673

Reputation: 41 594

I think I will be using the multiple account suggestion. Thanks for your help!Randy McKnight 2012-07-17T13:08:51.283

2

The current rpc interface don't have a command to check balance of a address

老板鱼丸粗面

Posted 2012-07-15T22:08:55.673

Reputation: 31

0

getinfo also includes a "balance" field that encompasses all spendable Bitcoin. Getbalance and listreceivedbyaddress can do slightly more advanced things, including confirmation count, but you don't seem to need them.

Reference this: https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list

Lodewijk

Posted 2012-07-15T22:08:55.673

Reputation: 1 447