<p>Use it like this:</p>
<pre><code>account=&quot;123abc&quot;
bitcoin-cli -regtest setaccount $address $account
bitcoin-cli -regtest getbalance $account
10.0
</code></pre>

CC BY-SA 4.0
2015-08-13T05:55:09.307Z
2022-10-02T11:35:29.817Z
2022-10-02T11:35:29.817Z
Md Shahadat Hossain
<p><code>getbalance</code> returns the balance of an account, not an address.  <a href="https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list" rel="nofollow">https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list</a></p>

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

<p>Try using <code>getreceivedbyaddress</code> instead.</p>

CC BY-SA 3.0
2014-10-26T18:24:21.313Z
2014-10-26T18:24:21.313Z
Nick ODell
<p>Here is my terminal session: </p>

<pre><code>$ echo $address
mvt7M16caMH1xoJyfWU5orjArfq97jhZ7k
$ bitcoin-cli -regtest getbalance
5899.99990000
$ bitcoin-cli -regtest sendtoaddress $address 10.0
6ed7452f8f11fe25904867b57e127a6b65cb180c2013e667e3d399c4179ff1f0
$ bitcoin-cli -regtest setgenerate true 1 
$ bitcoin-cli -regtest getbalance $address
0.00000000
</code></pre>

<p>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?</p>

CC BY-SA 3.0
2014-10-26T18:10:28.167Z
Is bitcoind in regtest mode? Is the address in your wallet?
Nick ODell
CC BY-SA 3.0
2014-10-26T18:16:02.713Z
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
CC BY-SA 3.0
2014-10-26T18:19:25.170Z
Try `getreceivedbyaddress` instead.
Nick ODell
CC BY-SA 3.0
2014-10-26T18:21:27.587Z
That worked! Now why is that? Did I mistype something some where? Am I misunderstanding a procedure?
Chris Stewart
CC BY-SA 3.0
2014-10-26T18:23:03.367Z
getbalance returns the balance of an account, not an address. https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list I didn't notice it at first.
Nick ODell
<json-rpc><regtest>
Bitcoin RPC getbalance of address I sent coins to on regtest
Chris Stewart
# Bitcoin RPC getbalance of address I sent coins to on regtest

(Asked by: username_0 on 2014-10-26)

Here is my terminal session:

```
$ echo $address
mvt7M16caMH1xoJyfWU5orjArfq97jhZ7k
$ bitcoin-cli -regtest getbalance
5899.99990000
$ bitcoin-cli -regtest sendtoaddress $address 10.0
6ed7452f8f11fe25904867b57e127a6b65cb180c2013e667e3d399c4179ff1f0
$ bitcoin-cli -regtest setgenerate true 1 
$ bitcoin-cli -regtest getbalance $address
0.00000000

```

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?

**Tags:** json-rpc, regtest

> **Comments:**
> **username_1**: Is bitcoind in regtest mode? Is the address in your wallet?  
> **username_0**: 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.  
> **username_1**: Try `getreceivedbyaddress` instead.  
> **username_0**: That worked! Now why is that? Did I mistype something some where? Am I misunderstanding a procedure?  
> **username_1**: getbalance returns the balance of an account, not an address. https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list I didn't notice it at first.  

---

## 2 answers

### Answer by username_1 on 2014-10-26. Score: 4 | Accepted answer

`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.


---

### Answer by username_2 on 2015-08-13. Score: 4

Use it like this:

```
account="123abc"
bitcoin-cli -regtest setaccount $address $account
bitcoin-cli -regtest getbalance $account
10.0

```


---

