<p>The gap limit is used because there are practically infinite addresses you can generate via Hierarchical Deterministic generation. If you didn't have a limit, the wallet would have to generate <em>all of them</em>, just in case, to see if any where used in transactions. That is impossible, there are just way, way too many possible child addresses.</p>
<blockquote>
<p>Is there the possibility to set it up to infinity?</p>
</blockquote>
<p>This is the same as having no limit, and it's impossible, as above.</p>
<blockquote>
<p>would importing external private keys to my wallet, without scanning, and generating a single address per private key solve the gap limit dilema (in a Bitcoin Core wallet, for example)?</p>
</blockquote>
<p>The gap limit is specific to Hierarchical Deterministic wallets, where you can deterministically generate many addresses from a single short seed. This makes backups super easy - backing up the seed means you've backed up all past <em>and future</em> addresses your wallet will generate. The seed is short so you can even write it down by hand. And HD has other benefits like being able to generate child public keys without access to the secret keys (useful for security, to avoid having secret keys &quot;hot&quot; on internet-connected devices).</p>
<p>If you just imported a few individual keys, you wouldn't need a gap limit, but you'd lose all the benefits of HD wallets. That's how Bitcoin Core's wallet used to work - colloquially known as the &quot;bag of keys&quot; model. HD is definitely the better way to manage keys.</p>

CC BY-SA 4.0
2022-01-02T11:29:50.060Z
Thanks for the answer! The thing is the PK management that I need is very basic: no scanning for past txs, just listening to ones since each address' creation, and I need to not have a limit on the amount of addresses and/or PKs managed by my wallet (or a very big limit). I have two following questions, if I may:

1) Can I import infinite PKs to a Bitcoin Core wallet? 
2) If the gap limit is an issue of HD wallets only, can I create n addresses within a Bitcoin Core wallet without losing the ability to listen to when each address receive a new deposit? @meshcollider
dNyrM
CC BY-SA 4.0
2022-01-02T18:07:07.543Z
The gap limit only applies when restoring a backup. If you are just creating addresses, then of course all the keys will be tracked by the wallet. Specifically, the answer to both 1) and 2) is yes.
meshcollider
CC BY-SA 4.0
2022-01-02T18:20:33.520Z
Awesome! Thanks again for help. @meshcollider
dNyrM
CC BY-SA 4.0
2022-01-01T20:06:02.827Z
2022-01-01T20:06:02.827Z
meshcollider
<p>I know there are a lot of posts on this issue but the majority of them are quite old.</p>
<p>Is there a more modern and &quot;simple&quot; solution for the address gap limit problem? For what I've read, the best one is to use Electrum and set the gap limit to something like 5000. Is there the possibility to set it up to infinity?</p>
<p>If instead of generating new addresses each time, would importing external private keys to my wallet, without scanning, and generating a single address per private key solve the gap limit dilema (in a Bitcoin Core wallet, for example)?</p>
<p>Thanks a lot for any input!</p>

<bip32-hd-wallets><gap-limit>
Bitcoin address gap limit
dNyrM
# Bitcoin address gap limit

(Asked by: username_0 on 2021-12-31)

I know there are a lot of posts on this issue but the majority of them are quite old.

Is there a more modern and "simple" solution for the address gap limit problem? For what I've read, the best one is to use Electrum and set the gap limit to something like 5000. Is there the possibility to set it up to infinity?

If instead of generating new addresses each time, would importing external private keys to my wallet, without scanning, and generating a single address per private key solve the gap limit dilema (in a Bitcoin Core wallet, for example)?

Thanks a lot for any input!

**Tags:** bip32-hd-wallets, gap-limit


---

## 1 answers

### Answer by username_1 on 2022-01-01. Score: 2 | Accepted answer

The gap limit is used because there are practically infinite addresses you can generate via Hierarchical Deterministic generation. If you didn't have a limit, the wallet would have to generate *all of them*, just in case, to see if any where used in transactions. That is impossible, there are just way, way too many possible child addresses.

> Is there the possibility to set it up to infinity?

This is the same as having no limit, and it's impossible, as above.

> would importing external private keys to my wallet, without scanning, and generating a single address per private key solve the gap limit dilema (in a Bitcoin Core wallet, for example)?

The gap limit is specific to Hierarchical Deterministic wallets, where you can deterministically generate many addresses from a single short seed. This makes backups super easy - backing up the seed means you've backed up all past *and future* addresses your wallet will generate. The seed is short so you can even write it down by hand. And HD has other benefits like being able to generate child public keys without access to the secret keys (useful for security, to avoid having secret keys "hot" on internet-connected devices).

If you just imported a few individual keys, you wouldn't need a gap limit, but you'd lose all the benefits of HD wallets. That's how Bitcoin Core's wallet used to work - colloquially known as the "bag of keys" model. HD is definitely the better way to manage keys.

> **Comments:**
> **username_0**: Thanks for the answer! The thing is the PK management that I need is very basic: no scanning for past txs, just listening to ones since each address' creation, and I need to not have a limit on the amount of addresses and/or PKs managed by my wallet (or a very big limit). I have two following questions, if I may:  1) Can I import infinite PKs to a Bitcoin Core wallet?  2) If the gap limit is an issue of HD wallets only, can I create n addresses within a Bitcoin Core wallet without losing the ability to listen to when each address receive a new deposit? @username_1  
> **username_1**: The gap limit only applies when restoring a backup. If you are just creating addresses, then of course all the keys will be tracked by the wallet. Specifically, the answer to both 1) and 2) is yes.  
> **username_0**: Awesome! Thanks again for help. @username_1  

---

