<p>If you have the master private key for an HD wallet, then software can easily generate derivative addresses, and check the balance of those addresses against the UTXO set. </p>

<blockquote>
  <p>am I supposed to keep generating addresses and check every single one to see if it has any balance?</p>
</blockquote>

<p>Wallet software will have a set number of addresses it generates and checks for a balance upon wallet initialization (maybe 50? this will vary and is configurable in some software). The wallet will probably include some logic like "look 50 addresses past the last used address found". You can design this to fit your need, for example if you were a merchant accepting payments on a busy website, you might need a higher bound, in case 50 customers in a row generate a payment address but then don't complete checkout. </p>

<blockquote>
  <p>Are you supposed to store both the master key and the addresses that you generate to receive payments?</p>
</blockquote>

<p>The wallet software will do this for you, but ultimately you do not need to explicitly keep a list of every private key / public address derived from your master key in order to access your funds later. If you have the master private key saved you will be able to recreate all derived keys from it. </p>

CC BY-SA 3.0
2017-12-17T05:18:39.593Z
Thanks for the clarifications. I'm developing the "wallet" software so I guess I'm responsible to keep track of addresses. As far as I understand the point is that you need to generate addresses "blindly"/sequentially until you find the funds you are expecting.
Books
CC BY-SA 3.0
2017-12-21T20:35:04.327Z
@Books yea, thats pretty much it, I wouldn't really call it 'blindly', but calling it sequential makes sense.
chytrik
CC BY-SA 3.0
2017-12-17T02:58:31.143Z
2017-12-17T02:58:31.143Z
chytrik
<p>I'm trying to find the balance of specific addresses in a wallet. I basically have the master key which I use to generate addresses but I wonder, is it possible to find the derived addresses that have any balance and how can I query it (the balance of the addresses, and thus the wallet)?</p>

<p>I know I can generate infinite derived(child) addresses from the master key so, am I supposed to keep generating addresses and check every single one to see if it has any balance? Are you supposed to store both the master key and the addresses that you generate to receive payments? </p>

<address-generation><balance>
How to find the wallet balance?
Books
# How to find the wallet balance?

(Asked by: username_0 on 2017-12-17)

I'm trying to find the balance of specific addresses in a wallet. I basically have the master key which I use to generate addresses but I wonder, is it possible to find the derived addresses that have any balance and how can I query it (the balance of the addresses, and thus the wallet)?

I know I can generate infinite derived(child) addresses from the master key so, am I supposed to keep generating addresses and check every single one to see if it has any balance? Are you supposed to store both the master key and the addresses that you generate to receive payments?

**Tags:** address-generation, balance


---

## 1 answers

### Answer by username_1 on 2017-12-17. Score: 1 | Accepted answer

If you have the master private key for an HD wallet, then software can easily generate derivative addresses, and check the balance of those addresses against the UTXO set.

> am I supposed to keep generating addresses and check every single one to see if it has any balance?

Wallet software will have a set number of addresses it generates and checks for a balance upon wallet initialization (maybe 50? this will vary and is configurable in some software). The wallet will probably include some logic like "look 50 addresses past the last used address found". You can design this to fit your need, for example if you were a merchant accepting payments on a busy website, you might need a higher bound, in case 50 customers in a row generate a payment address but then don't complete checkout.

> Are you supposed to store both the master key and the addresses that you generate to receive payments?

The wallet software will do this for you, but ultimately you do not need to explicitly keep a list of every private key / public address derived from your master key in order to access your funds later. If you have the master private key saved you will be able to recreate all derived keys from it.

> **Comments:**
> **username_0**: Thanks for the clarifications. I'm developing the "wallet" software so I guess I'm responsible to keep track of addresses. As far as I understand the point is that you need to generate addresses "blindly"/sequentially until you find the funds you are expecting.  
> **username_1**: @username_0 yea, thats pretty much it, I wouldn't really call it 'blindly', but calling it sequential makes sense.  

---

