BitcoinDatabase.com
All posts
Guides

What Is the Gap Limit in a Bitcoin Wallet? (And Missing Funds)

What is the gap limit: the number of consecutive unused addresses a wallet will scan before it stops looking, usually 20. Why it exists, how it can make a restored balance appear missing, and how to recover funds beyond the gap.

By the BitcoinDatabase team

July 2026 · 8 min read

The short answer

The gap limit is the number of consecutive unused addresses a Bitcoin wallet will scan before it assumes there are no more funds and stops looking. The standard, set by BIP 44, is 20. When a wallet restores from a seed or an extended public key, it derives addresses one after another and checks each for history. If it finds 20 in a row that were never used, it concludes the account is finished. This is why funds sent to an address far past your last active one can appear missing after a restore: the coins are safe on the chain, but the wallet gave up scanning before it reached them.

The gap limit is one of those quiet HD wallet rules that nobody notices until a restored wallet shows the wrong balance. Once you understand why it exists and how to work around it, a scary looking case of missing bitcoin becomes a solvable one.

What is the gap limit in a Bitcoin wallet?

The gap limit is a cap on how many empty addresses a wallet tolerates in a row before it stops deriving new ones. Modern wallets are hierarchical deterministic, meaning a single seed generates an effectively unlimited sequence of addresses through an extended public key. Because that sequence is infinite, a restoring wallet needs a stopping rule, otherwise it would scan forever. The gap limit is that rule. As it walks the derivation path, it keeps a running count of consecutive addresses with zero transaction history. The moment that count hits the limit, usually 20, it decides the remaining addresses are all unused and ends the scan.

Why is the gap limit 20?

The gap limit is 20 because BIP 44, the standard that defines HD account structure, specifies 20 as the default, and most wallets simply follow it. The number is a compromise. Set it too low and a wallet might stop before finding legitimately used addresses that happen to sit after a run of skipped ones. Set it too high and every restore becomes slow, since the wallet has to query the history of far more addresses than it will ever need. Twenty consecutive unused addresses was judged large enough that normal wallet use almost never leaves that big a gap, while staying small enough that scanning stays fast.

How does the gap limit cause missing funds?

The gap limit causes apparent missing funds when a payment lands on an address that sits beyond a run of 20 unused ones. Picture a wallet that has used address index 5, then you manually generate address 40 and receive coins there, skipping everything in between. On restore, the wallet derives index 6, 7, 8 and so on, finds nothing, and by index 25 it has seen 20 empty addresses in a row. It stops. Index 40, where your coins actually are, is never checked, so the balance looks short. The bitcoin is not lost. The wallet simply never scanned far enough to see it.

Situation What the wallet does
Addresses used in sequence Finds all funds; gaps never exceed the limit
One address skipped far ahead Stops after 20 empties; the far address is missed
Manual address generation Can create a gap larger than 20 by accident
Gap limit raised before restore Scans further and recovers the funds

How do I recover funds beyond the gap limit?

To recover funds past the gap limit, you need to make the wallet scan further than 20 empty addresses. The most common fixes are to raise the gap limit setting in a wallet that exposes it, such as Electrum, then rescan; or to import the specific derivation path or address where you know the coins landed. Some wallets let you set the gap limit to a few hundred temporarily, which forces a deeper scan across the whole account. Because the addresses are all deterministic, nothing is at risk in doing this: you are only asking the software to look at more of the same sequence it already knows how to generate.

Can I check an address past the gap without my wallet?

Yes, you can check any address for history independently of your wallet by querying the chain directly, which is often the fastest way to confirm coins are really there before you fiddle with wallet settings. If you have the extended public key, you can derive the addresses and check each one over an API. BitcoinDatabase indexes every address on the chain, so you can look up a balance and full history for any derived address, or watch a whole wallet through an xpub balance API that walks the derivation path for you. That confirms the funds exist and tells you exactly which index to import, all without exposing a private key.

Does raising the gap limit put my coins at risk?

No, raising the gap limit does not put your coins at risk, because it only changes how far the wallet scans, not anything about your keys or the coins themselves. The gap limit is a search setting, not a security control. A higher limit means the wallet queries the history of more addresses during a restore, which takes longer and uses more bandwidth, but every address it checks is one your seed already deterministically controls. The only real trade-off is speed. Once your funds are found, you can leave the limit high or return it to the default without affecting the balance.

Query the derivation path directly

The gap limit is really a symptom of how HD wallets work: one key, an endless sequence of addresses, and a stopping rule that occasionally stops too soon. When you can query the chain yourself, that stopping rule stops being a mystery, because you can check any index directly and see exactly where the money is. BitcoinDatabase lets you resolve balances and history for any address or extended public key over a clean API, SQL or dashboards, so a confusing restore becomes a lookup. Try it from the console above, and this is informational on-chain data only, not financial advice.

Query Console
btc
try:

Hit Run to query the fully-indexed Bitcoin blockchain.

BTC

30-day trend

informational on-chain data · not financial advice

REST API · SQL · dashboards, one indexed dataset. Querying the indexed Bitcoin blockchain ...

Query the Bitcoin blockchain yourself

Pull balances, UTXOs, transactions, on-chain metrics and fund flows from the fully indexed Bitcoin blockchain by REST API, SQL and dashboards. Indexed since 2009, new blocks within seconds, no node to run.

Query the whole Bitcoin blockchain

BitcoinDatabase indexes the public Bitcoin blockchain block by block and returns balances, UTXOs, transactions, on-chain metrics and fund flows by REST API, SQL and dashboards, with no node to run.

REST + SQL + dashboards · indexed since 2009 · new blocks within seconds

Informational on-chain data only · not financial, investment or legal advice · AML features are compliance tooling to support your own review.