<blockquote>
  <p>The gap limit is the maximum number of consecutive unused addresses in your deterministic sequence of addresses. Electrum uses a gap limit to stop looking for addresses, it is set to 5 by default, so the client get all addresses until 5 unused addresses are found.</p>
</blockquote>

<p><a href="https://electrum.org/faq.html#gap-limit" rel="nofollow">https://electrum.org/faq.html#gap-limit</a></p>

<p>If you used a different gap limit when creating the addresses, then you need to keep record of it or remember it. Addresses that appeared beyond the gap limit won't be found unless you set the gap limit you used.</p>

<p>For example: Using MPK on a web server you used gap limit 40 to create 40 addresses for your web store. Then you had 39 open orders that are not paid and the address number 40 has a payment.</p>

<p>When you restore with gap limit 5 (default in the client) you'll have 5 unused empty addresses, you won't see the other 34 that are also unused but related to open orders neither you'll see or have balance for the address number 40 that has a payment on it.</p>

CC BY-SA 3.0
2014-08-14T10:27:12.360Z
2014-08-14T10:27:12.360Z
rdymac
<p>If I want to know the total balance in all the addresses which can be generated in a deterministic wallet (like electrum or armory).</p>

<p>I have the master public key allowing me to derive an infinite number of public keys.</p>

<p>What is the number of addresses I should generate to check the balance ?</p>

<p>I suppose I can stop if the last X addresses don't have any transactions.</p>

<p>What is the value of X for electrum and armory (when recovering from a backup) ?</p>

<electrum><armory><deterministic-wallets><gap-limit>
Where to stop key derivation when looking at balance of a deterministic wallet
leszek.hanusz
# Where to stop key derivation when looking at balance of a deterministic wallet

(Asked by: username_0 on 2014-08-13)

If I want to know the total balance in all the addresses which can be generated in a deterministic wallet (like electrum or armory).

I have the master public key allowing me to derive an infinite number of public keys.

What is the number of addresses I should generate to check the balance ?

I suppose I can stop if the last X addresses don't have any transactions.

What is the value of X for electrum and armory (when recovering from a backup) ?

**Tags:** electrum, armory, deterministic-wallets, gap-limit


---

## 1 answers

### Answer by username_1 on 2014-08-14. Score: 2

> The gap limit is the maximum number of consecutive unused addresses in your deterministic sequence of addresses. Electrum uses a gap limit to stop looking for addresses, it is set to 5 by default, so the client get all addresses until 5 unused addresses are found.

<https://electrum.org/faq.html#gap-limit>

If you used a different gap limit when creating the addresses, then you need to keep record of it or remember it. Addresses that appeared beyond the gap limit won't be found unless you set the gap limit you used.

For example: Using MPK on a web server you used gap limit 40 to create 40 addresses for your web store. Then you had 39 open orders that are not paid and the address number 40 has a payment.

When you restore with gap limit 5 (default in the client) you'll have 5 unused empty addresses, you won't see the other 34 that are also unused but related to open orders neither you'll see or have balance for the address number 40 that has a payment on it.


---

