Here is my terminal session:

$ echo $address
$ bitcoin-cli -regtest getbalance
$ bitcoin-cli -regtest sendtoaddress $address 10.0
$ bitcoin-cli -regtest setgenerate true 1 
$ bitcoin-cli -regtest getbalance $address

Shouldn't the balance of this address be 10 now? I thought that by generating a block, I will have that transaction included, which will show up on the addresses balance?

  • Is bitcoind in regtest mode? Is the address in your wallet? – Nick ODell Oct 26 '14 at 18:10
  • I ran bitcoin-cli -regtest getnewaddress, and I also ran bitcoind -regtest -daemon, I think those are the two things you are looking for. If I needed to do anything outside of that, then no. – Chris Stewart Oct 26 '14 at 18:16
  • Try getreceivedbyaddress instead. – Nick ODell Oct 26 '14 at 18:19
  • That worked! Now why is that? Did I mistype something some where? Am I misunderstanding a procedure? – Chris Stewart Oct 26 '14 at 18:21
  • 1
    getbalance returns the balance of an account, not an address. en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list I didn't notice it at first. – Nick ODell Oct 26 '14 at 18:23

getbalance returns the balance of an account, not an address. https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list

If there's no account by the name of mvt7M16caMH1xoJyfWU5orjArfq97jhZ7k, it will return 0.

Try using getreceivedbyaddress instead.

| improve this answer | |

Use it like this:

bitcoin-cli -regtest setaccount $address $account
bitcoin-cli -regtest getbalance $account
  • If this is a shell, shouldn't that be account="123abc" ? – Nick ODell Aug 13 '15 at 6:04
  • i have edited for shell.now it'll works – Md Shahadat Hossain Aug 13 '15 at 6:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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