<ol>
<li>import all address using "importaddress"</li>
<li>you can get balance using "listunspent", but you must sum all unspent amount per an address.</li>
</ol>

CC BY-SA 3.0
2018-03-12T08:49:59.093Z
2018-03-12T08:49:59.093Z
Egon Son
<blockquote>
  <p>"We'll hopefully soon get support for (...) watch-only wallets, where you can just add addresses you'd like to track, without having their keys."
                                                                  –Pieter Wuille</p>
</blockquote>

<p>From what I've seen, Pieter Wuille and others included this feature in Bitcoin Core <a href="https://bitcoin.org/en/release/v0.10.0#watch-only-wallet-support" rel="noreferrer">release 0.10.0</a>, so that now it is possible to use Bitcoin Core to get the balance of whatever address just by following these steps:</p>

<p>1) Create a new wallet (stop the program, rename the old wallet.dat file, restart the program and it will create a new empty wallet.dat).</p>

<p>2) Start Bitcoin Core, and go to Help > Debugging Window > Console.</p>

<p>3) On the console's command line, execute the following <a href="https://bitcoin.org/en/developer-reference#importaddress" rel="noreferrer">command</a>:</p>

<p>importaddress the_address_you_are_interested_in</p>

<p>Note that this will cause the program to rescan the entire block chain, which can take several minutes.</p>

<p>Then you can close the debugging window. Now the main window of the program shows two columns of balances, the first one is the balance of the normal addresses in the wallet (the ones whose bitcoins you can spend), and the second one is the balance of the watch-only addresses in the wallet. This last one is what you were looking for.</p>

<p>Once you are done, you can stop the program, delete or rename the wallet or move it somewhere esle, and rename the old wallet back to "wallet.dat".</p>

<p>Note that the Bitcoin client must have an updated copy of the entire block chain, as the default rescan=true option of importaddress doesn't accept pruned block chains, and rescan=false won't show the current balance.</p>

<p>I have not tried this and I'm no bitcoin expert, so take this answer with caution.</p>

CC BY-SA 4.0
2020-12-17T15:02:46.563Z
Interesting to know. Would this also be possible on the command-line only? How would I be able to query for the output after the indexing finished?
bomben
CC BY-SA 3.0
2017-06-07T01:23:00.593Z
2017-06-09T14:56:12.237Z
2017-06-09T14:56:12.237Z
Daniel F
<p>This comes from the <a href="https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_Calls_list" rel="noreferrer">Original Bitcoin client/API calls list</a> regarding the command <code>getreceivedbyaddress</code>.</p>

<blockquote>
  <p>Returns the total amount received by  in transactions with at least [minconf] confirmations. While some might consider this obvious, value reported by this only considers <em>receiving</em> transactions. It does not check payments that have been made <em>from</em> this address. In other words, this is not "getaddressbalance". <strong>Works only for addresses in the local wallet, external addresses will always show 0.</strong> [Boldness added by me.]</p>
</blockquote>

<p>Technically you are right; the blockchain carries the information you are looking for. The original client however does not have the function to compute it.</p>

CC BY-SA 3.0
2013-04-23T20:18:21.527Z
I knew that it was noted like this, but I wanted to know why it was so and if there is a workaround method to eventually achieve what `getreceivedbyaddress` cannot.
Steven Roose
CC BY-SA 3.0
2013-10-13T15:44:32.327Z
I'm sorry, but how is it that you're using *getaddressbalance*?  What version of bitcoind are you using?
earthmeLon
CC BY-SA 3.0
2014-09-10T12:39:56.870Z
How can I use `getreceivedbyaddress`? To what should I send it? Is there any simple example of this command or any other?
Incerteza
CC BY-SA 3.0
2015-02-04T12:46:39.830Z
@earthmeLon - I presume that the `getaddressbalance` @jorijnsmit mentioned was just a hypothetical command.
Priidu Neemre
CC BY-SA 4.0
2019-10-06T21:02:05.470Z
I think it does exists via RPC: https://bitcoin.org/en/developer-reference#getreceivedbyaddress
Melroy van den Berg
CC BY-SA 4.0
2020-11-27T19:15:20.360Z
It doesn t returns any amounts in the case of `1 of n` bare multisig even if recognized as ismine.
user2284570
CC BY-SA 3.0
2013-04-22T21:44:34.927Z
2013-04-22T21:44:34.927Z
gosuto
<p>The concept of an "address balance" is based on confusion.</p>

<p>The way Bitcoin is designed, there are three different concepts related: addresses, wallets, and accounts. Wallets are comprised of one or more accounts, each having a balance (which may even be negative). The wallet as a whole has a balance totalling the sum of all accounts (which must always be positive).</p>

<p>Addresses are merely entry points to a wallet; they do not have balances, and should only ever* be used once. Addresses are associated with an account: when coins are received on the address, it credits that account - note that this is a one-way association: the account is <em>not</em> associated with the address, nor the coin received; its balance is simply increased by the amount received. When you spend bitcoins, your wallet chooses coins to spend at (more or less) random, with no concern for how they were received, and will usually use a completely new invisible address internally with itself, that you will not see as an end-user. Overall, these are some of the reasons why it makes little sense to talk about an "address balance".</p>

<p>* While it is fairly common that people reuse addresses for deposits or donations, doing so is harmful to yourself and others using Bitcoin in a number of ways which are outside the scope of this question.</p>

CC BY-SA 3.0
2013-07-02T20:53:17.437Z
On the contrary, accounts and wallets are not real, while only addresses are. I'd say all unspent outputs with a given address constitute the address's balance. There needs to be a way in bitcoind to query the list of unspent outputs for a given address (irrespective of whether it is in my "wallet" or "account")
Jus12
CC BY-SA 4.0
2020-01-30T03:33:29.343Z
@Jus12 You can use the `scantxoutset` RPC for that now, which scans the UTXO set instead of the entire blockchain.
Pieter Wuille
CC BY-SA 3.0
2013-06-12T00:27:29.677Z
2013-06-12T00:27:29.677Z
Luke Dashjr
<p>I have written a program in Python3 that allows you to search for any address on bitcoin core whether it belongs to your wallet or not.</p>
<p>Here is the github link:</p>
<p><a href="https://github.com/ORP967/Bitcoin_Core_RPC_par_address" rel="nofollow noreferrer">https://github.com/ORP967/Bitcoin_Core_RPC_par_address</a></p>
<p>Let me know what you think or if you have any improvements you might have.</p>

CC BY-SA 4.0
2022-01-23T22:59:04.630Z
2022-01-23T22:59:04.630Z
ORP967
<p>By default, what is maintained by the 0.8 blockchain engine is:</p>

<ul>
<li>All blocks</li>
<li>A database with all block headers, and the positions on disk for each block</li>
<li>A database that represents all unspent transaction outputs (UTXOs), indexed by txid, at the current tip of the block chain</li>
<li>Undo files that allow rewinding the effects of blocks on this set of UTXOs.</li>
</ul>

<p>Nothing related to addresses or balances exists at this level. That is just a client-side representation of the data. The balance of a wallet is the sum of the values of the UTXOs that are spendable with the set of keys in the wallet. You could define the balance of an address as the sum of the values of the UTXOs assigned to a script matching a given address (and this is what several sites do), but presenting it this way is quite confusing - it makes many people think that Bitcoin transactions transfer value from one address to another. This is not true, they consume specific outputs of a previous transaction, and merge and split those into new outputs.</p>

<p>The <code>-txindex</code> option you mention, adds one more thing that is maintained by the validation engine:</p>

<ul>
<li>A database with the positions on disk for each <em>transaction</em>, indexed by txid.</li>
</ul>

<p>This was added to make the <code>getrawtransaction</code> command work with historical transactions, but again, this has nothing to do with addresses. A database that indexes the UTXO set by address, or even the entire block chain history by address would be possible, but it would be relatively expensive to maintain, and shouldn't be necessary for normal operations (though it is quite useful for debugging...).</p>

<p>Where such things do belong, is in the wallet. The wallet as presented by the reference client does not use "balance of an address" - it rather sees addresses as entry points into the wallet, but manages the coins in the entire wallet together, regardless of what address they were last sent to. This also confuses people who are used to look at blockexplorer-like websites, when they realize that for example change is always sent to a fresh address.</p>

<p>So, to give a real answer: if you really want to track a balance, you need the wallet interface. Right now, this is quite unflexible, but there are plans to improve this situation soon. We'll hopefully soon get support for multiple wallets, and watch-only wallets, where you can just add addresses you'd like to track, without having their keys.</p>

CC BY-SA 3.0
2013-04-23T10:17:07.583Z
Maybe you should add a small section on how to calculate the information I am looking for using the current bitcoind functionality. I suppose I have to use `listunspent` or something like that? Or is it really just impossible?
Steven Roose
CC BY-SA 3.0
2013-04-23T19:46:27.130Z
It's just impossible, unless you have a wallet with the keys in it.
Pieter Wuille
CC BY-SA 3.0
2013-04-23T19:48:30.873Z
Well, not impossible in theory: if you have -txindex enabled, you can iterate through all blocks using `getblockhash` and `getblock`, iterate through all transactions in each block using `getrawtransaction`, and look for outputs crediting the address you want, or being consumed in an input. This would likely take hours...
Pieter Wuille
CC BY-SA 3.0
2013-04-23T20:17:10.630Z
Is this because the client only checks for transactions including addresses in the wallet? I cannot see a reason why private keys would be needed for that process.
If I'm right, this is just a shortcoming from the original client that only wants to index balances for it's own addresses. And that, if implemented, it could even so do this for any other address?
Steven Roose
CC BY-SA 3.0
2013-04-23T22:05:50.517Z
It doesn't index any address balances at all, but for addresses known to the wallet, it tracks them (during download/sync/rescan of the blockchain). And this is indeed a shortcoming. There's a planned feature to allow "watch-only wallets", which would allow importing addresses instead of keys.
Pieter Wuille
CC BY-SA 3.0
2013-07-23T19:38:01.977Z
It looks like this might almost be possible soon: https://github.com/bitcoin/bitcoin/pull/2121
Do Not Track Me
CC BY-SA 3.0
2014-02-25T06:35:15.670Z
Has the situation changed ? Is there any way now ?
coding_idiot
CC BY-SA 3.0
2017-06-09T23:29:02.550Z
Yes, use watch-only addresses.
Pieter Wuille
CC BY-SA 4.0
2020-07-22T10:06:05.157Z
@PieterWuille Hi, are there some changes connected with bitcoin address balance detection? Could I receive the balance for some bitcoin address from the deployed full node directly? I mean without UTXOs parsing?
Dmytro Zarezenko
CC BY-SA 4.0
2023-05-17T08:28:00.093Z
@PieterWuille This (accepted) answer that you wrote ten years ago has become outdated and is no longer correct. I was going to prepend new information to your answer, but I thought you might want to do it yourself. Your answer would certainly be better than mine! Thank you for your years of dedication to Bitcoin.
bitsmack
CC BY-SA 3.0
2013-04-22T22:25:28.937Z
2013-04-22T22:25:28.937Z
Pieter Wuille
<p>I want to see the balance of some address using bitcoind.</p>

<p>I set <code>txindex=1</code> and did a <code>-reindex</code> to get all transactions indexed.</p>

<p>But still, there doesn't seem to be a way to get balances of an address. <code>getreceivedbyaddress</code> doesn't work with addresses out of your own wallet (I hoped it would after a <code>-txindex=1 -reindex</code>, but it didn't).</p>

<p>I'm wondering why blockexplorer.com's <code>getreceivedbyaddress</code> can do this for any address but the default client cannot. If you download and sync the whole blockchain, you should be able to query it for any information, right?</p>

CC BY-SA 3.0
2013-04-22T14:24:17.220Z
While I don't know the answer to your question, I would like to point out that `txindex` is not relevant here, as the client does not need the full index to get the balance for any given address.
Tom van der Woerdt
CC BY-SA 3.0
2013-04-22T15:26:40.357Z
I thought it might, but indeed it doesn't seem to be so.
Steven Roose
CC BY-SA 3.0
2014-02-25T06:34:51.187Z
found any solution ?
coding_idiot
CC BY-SA 3.0
2014-02-26T12:05:13.317Z
@coding_idiot It's not possible (intentionally) to query for any information using bitcoind. It only maintains an index for transactions that are relevant for your wallet.
Steven Roose
CC BY-SA 3.0
2018-04-02T02:58:16.270Z
You can use api of some bitcoin exploer like https://api.blockcypher.com/v1/btc/main/addrs/38DGj87axzmQiZeAd1w1y5FEmuu5a7pfBa.   There is also some opensource exploer like https://github.com/blockcypher/explorer
LF-DevJourney
<client><bitcoind><api>
How to get an address's balance with the bitcoin client?
Steven Roose
# How to get an address's balance with the bitcoin client?

(Asked by: username_0 on 2013-04-22)

I want to see the balance of some address using bitcoind.

I set `txindex=1` and did a `-reindex` to get all transactions indexed.

But still, there doesn't seem to be a way to get balances of an address. `getreceivedbyaddress` doesn't work with addresses out of your own wallet (I hoped it would after a `-txindex=1 -reindex`, but it didn't).

I'm wondering why blockexplorer.com's `getreceivedbyaddress` can do this for any address but the default client cannot. If you download and sync the whole blockchain, you should be able to query it for any information, right?

**Tags:** client, bitcoind, api

> **Comments:**
> **username_1**: While I don't know the answer to your question, I would like to point out that `txindex` is not relevant here, as the client does not need the full index to get the balance for any given address.  
> **username_0**: I thought it might, but indeed it doesn't seem to be so.  
> **username_2**: found any solution ?  
> **username_0**: @username_2 It's not possible (intentionally) to query for any information using bitcoind. It only maintains an index for transactions that are relevant for your wallet.  
> **username_3**: You can use api of some bitcoin exploer like https://api.blockcypher.com/v1/btc/main/addrs/38DGj87axzmQiZeAd1w1y5FEmuu5a7pfBa.   There is also some opensource exploer like https://github.com/blockcypher/explorer  

---

## 6 answers

### Answer by username_15 on 2013-04-22. Score: 26 | Accepted answer

By default, what is maintained by the 0.8 blockchain engine is:

* All blocks
* A database with all block headers, and the positions on disk for each block
* A database that represents all unspent transaction outputs (UTXOs), indexed by txid, at the current tip of the block chain
* Undo files that allow rewinding the effects of blocks on this set of UTXOs.

Nothing related to addresses or balances exists at this level. That is just a client-side representation of the data. The balance of a wallet is the sum of the values of the UTXOs that are spendable with the set of keys in the wallet. You could define the balance of an address as the sum of the values of the UTXOs assigned to a script matching a given address (and this is what several sites do), but presenting it this way is quite confusing - it makes many people think that Bitcoin transactions transfer value from one address to another. This is not true, they consume specific outputs of a previous transaction, and merge and split those into new outputs.

The `-txindex` option you mention, adds one more thing that is maintained by the validation engine:

* A database with the positions on disk for each *transaction*, indexed by txid.

This was added to make the `getrawtransaction` command work with historical transactions, but again, this has nothing to do with addresses. A database that indexes the UTXO set by address, or even the entire block chain history by address would be possible, but it would be relatively expensive to maintain, and shouldn't be necessary for normal operations (though it is quite useful for debugging...).

Where such things do belong, is in the wallet. The wallet as presented by the reference client does not use "balance of an address" - it rather sees addresses as entry points into the wallet, but manages the coins in the entire wallet together, regardless of what address they were last sent to. This also confuses people who are used to look at blockexplorer-like websites, when they realize that for example change is always sent to a fresh address.

So, to give a real answer: if you really want to track a balance, you need the wallet interface. Right now, this is quite unflexible, but there are plans to improve this situation soon. We'll hopefully soon get support for multiple wallets, and watch-only wallets, where you can just add addresses you'd like to track, without having their keys.

> **Comments:**
> **username_0**: Maybe you should add a small section on how to calculate the information I am looking for using the current bitcoind functionality. I suppose I have to use `listunspent` or something like that? Or is it really just impossible?  
> **username_15**: It's just impossible, unless you have a wallet with the keys in it.  
> **username_15**: Well, not impossible in theory: if you have -txindex enabled, you can iterate through all blocks using `getblockhash` and `getblock`, iterate through all transactions in each block using `getrawtransaction`, and look for outputs crediting the address you want, or being consumed in an input. This would likely take hours...  
> **username_0**: Is this because the client only checks for transactions including addresses in the wallet? I cannot see a reason why private keys would be needed for that process. If I'm right, this is just a shortcoming from the original client that only wants to index balances for it's own addresses. And that, if implemented, it could even so do this for any other address?  
> **username_15**: It doesn't index any address balances at all, but for addresses known to the wallet, it tracks them (during download/sync/rescan of the blockchain). And this is indeed a shortcoming. There's a planned feature to allow "watch-only wallets", which would allow importing addresses instead of keys.  
> **username_17**: It looks like this might almost be possible soon: https://github.com/bitcoin/bitcoin/pull/2121  
> **username_2**: Has the situation changed ? Is there any way now ?  
> **username_15**: Yes, use watch-only addresses.  
> **username_18**: @username_15 Hi, are there some changes connected with bitcoin address balance detection? Could I receive the balance for some bitcoin address from the deployed full node directly? I mean without UTXOs parsing?  
> **username_19**: @username_15 This (accepted) answer that you wrote ten years ago has become outdated and is no longer correct. I was going to prepend new information to your answer, but I thought you might want to do it yourself. Your answer would certainly be better than mine! Thank you for your years of dedication to Bitcoin.  

---

### Answer by username_4 on 2018-03-12. Score: 9

1. import all address using "importaddress"
2. you can get balance using "listunspent", but you must sum all unspent amount per an address.


---

### Answer by username_5 on 2017-06-07. Score: 5

> "We'll hopefully soon get support for (...) watch-only wallets, where you can just add addresses you'd like to track, without having their keys."
> –username_15 username_15

From what I've seen, username_15 username_15 and others included this feature in Bitcoin Core [release 0.10.0](https://bitcoin.org/en/release/v0.10.0#watch-only-wallet-support), so that now it is possible to use Bitcoin Core to get the balance of whatever address just by following these steps:

1) Create a new wallet (stop the program, rename the old wallet.dat file, restart the program and it will create a new empty wallet.dat).

2) Start Bitcoin Core, and go to Help > Debugging Window > Console.

3) On the console's command line, execute the following [command](https://bitcoin.org/en/developer-reference#importaddress):

importaddress the\_address\_you\_are\_interested\_in

Note that this will cause the program to rescan the entire block chain, which can take several minutes.

Then you can close the debugging window. Now the main window of the program shows two columns of balances, the first one is the balance of the normal addresses in the wallet (the ones whose bitcoins you can spend), and the second one is the balance of the watch-only addresses in the wallet. This last one is what you were looking for.

Once you are done, you can stop the program, delete or rename the wallet or move it somewhere esle, and rename the old wallet back to "wallet.dat".

Note that the Bitcoin client must have an updated copy of the entire block chain, as the default rescan=true option of importaddress doesn't accept pruned block chains, and rescan=false won't show the current balance.

I have not tried this and I'm no bitcoin expert, so take this answer with caution.

> **Comments:**
> **username_6**: Interesting to know. Would this also be possible on the command-line only? How would I be able to query for the output after the indexing finished?  

---

### Answer by username_7 on 2013-04-22. Score: 4

This comes from the [Original Bitcoin client/API calls list](https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_Calls_list) regarding the command `getreceivedbyaddress`.

> Returns the total amount received by in transactions with at least [minconf] confirmations. While some might consider this obvious, value reported by this only considers *receiving* transactions. It does not check payments that have been made *from* this address. In other words, this is not "getaddressbalance". **Works only for addresses in the local wallet, external addresses will always show 0.** [Boldness added by me.]

Technically you are right; the blockchain carries the information you are looking for. The original client however does not have the function to compute it.

> **Comments:**
> **username_0**: I knew that it was noted like this, but I wanted to know why it was so and if there is a workaround method to eventually achieve what `getreceivedbyaddress` cannot.  
> **username_8**: I'm sorry, but how is it that you're using *getaddressbalance*?  What version of bitcoind are you using?  
> **username_9**: How can I use `getreceivedbyaddress`? To what should I send it? Is there any simple example of this command or any other?  
> **username_10**: @username_8 - I presume that the `getaddressbalance` @jorijnsmit mentioned was just a hypothetical command.  
> **username_11**: I think it does exists via RPC: https://bitcoin.org/en/developer-reference#getreceivedbyaddress  
> **username_12**: It doesn t returns any amounts in the case of `1 of n` bare multisig even if recognized as ismine.  

---

### Answer by username_13 on 2013-06-12. Score: 4

The concept of an "address balance" is based on confusion.

The way Bitcoin is designed, there are three different concepts related: addresses, wallets, and accounts. Wallets are comprised of one or more accounts, each having a balance (which may even be negative). The wallet as a whole has a balance totalling the sum of all accounts (which must always be positive).

Addresses are merely entry points to a wallet; they do not have balances, and should only ever\* be used once. Addresses are associated with an account: when coins are received on the address, it credits that account - note that this is a one-way association: the account is *not* associated with the address, nor the coin received; its balance is simply increased by the amount received. When you spend bitcoins, your wallet chooses coins to spend at (more or less) random, with no concern for how they were received, and will usually use a completely new invisible address internally with itself, that you will not see as an end-user. Overall, these are some of the reasons why it makes little sense to talk about an "address balance".

\* While it is fairly common that people reuse addresses for deposits or donations, doing so is harmful to yourself and others using Bitcoin in a number of ways which are outside the scope of this question.

> **Comments:**
> **username_14**: On the contrary, accounts and wallets are not real, while only addresses are. I'd say all unspent outputs with a given address constitute the address's balance. There needs to be a way in bitcoind to query the list of unspent outputs for a given address (irrespective of whether it is in my "wallet" or "account")  
> **username_15**: @username_14 You can use the `scantxoutset` RPC for that now, which scans the UTXO set instead of the entire blockchain.  

---

### Answer by username_16 on 2022-01-23. Score: 1

I have written a program in Python3 that allows you to search for any address on bitcoin core whether it belongs to your wallet or not.

Here is the github link:

<https://github.com/username_16/Bitcoin_Core_RPC_par_address>

Let me know what you think or if you have any improvements you might have.


---

