Gap Limit

How many unused addresses in a row a wallet scans during restore before it stops looking.

Basically

Your wallet checks a set number of unused addresses in a row before it assumes there are no more funds. The gap limit is that number.

Key Takeaways

  • The gap limit is a scanning threshold defined in BIP-44. It tells an HD wallet to stop looking for funds after 20 consecutive unused addresses on a derivation path.
  • Exceeding the gap limit causes 'missing balance' problems. Funds exist on-chain but stay invisible when you restore a seed phrase in a new wallet because scanning stops before reaching their addresses.
  • The trade-off is speed versus completeness. A lower gap limit means faster wallet recovery, while a higher gap limit finds funds beyond longer sequences of generated addresses that never received payments.

What Is the Gap Limit?

The gap limit is a wallet configuration parameter that controls how many consecutive unused addresses an HD (hierarchical deterministic) wallet scans before assuming there are no more funds to find. An HD wallet can derive an effectively infinite number of addresses from a single seed phrase, so it needs a stopping rule. The gap limit is that stopping rule.

BIP-44 established the default gap limit of 20 and defines the standard multi-account hierarchy for deterministic wallets. The BIP states: "If the software hits 20 unused addresses in a row, it expects there are no used addresses beyond this point and stops searching the address chain."

The gap limit only matters during wallet discovery, such as when you restore a wallet from a seed phrase, import it into new software, or when the wallet performs account discovery on startup. During normal use, the wallet already knows which addresses it has generated and tracks them internally.

How It Works

The gap limit operates at the address_index level of the BIP-44 derivation path. It counts consecutive unused addresses at that level.

A wallet runs a discovery algorithm when you restore it from a seed. The algorithm checks addresses until it reaches the gap limit.

The algorithm checks for transaction history, not current balance. An address that once received and then spent all its coins still counts as "used." That rule prevents the wallet from stopping too early at addresses that held funds in the past.

The Gap Limit in Practice

Consider a wallet that has generated 50 receiving addresses. The gap limit determines how many of them the wallet checks.

The wallet correctly finds all funds through index 19 in this example, but misses the transaction at index 40. It has already encountered 20 consecutive unused addresses and stopped scanning.

Why It Matters

The gap limit becomes a practical problem whenever many addresses are generated without receiving payments in sequence. BIP-44 explicitly requires wallet software to warn users when they attempt to exceed the gap limit by generating a new address, but not all wallets enforce this warning.

For most individual users who generate addresses one at a time and use them sequentially, the default gap limit of 20 works well. Problems arise in specific scenarios where address generation outpaces address usage.

In all these cases, the funds are not lost because the private keys remain derivable from the seed. The wallet software simply does not know to look for them. The funds will appear if you check those specific addresses in a blockchain explorer or increase the gap limit.

Gap Limit Across Wallet Implementations

Different wallets handle the gap limit with varying degrees of flexibility. Most default to 20, but the ease of changing it depends on the wallet's backend architecture.

Electrum Servers vs. Bitcoin Core

The performance cost of increasing the gap limit depends heavily on the wallet's backend architecture. Each backend handles address lookups differently.

Bitcoin Core and full-node-backed wallets must query the blockchain directly for each address. Scanning 10,000 addresses means 10,000 individual lookups against the chain state, which is resource-intensive and slow on mobile or low-powered devices. SPV wallets using Bloom filters (BIP-37) face an additional constraint: the 36,000-byte filter size limit caps practical scanning at roughly 20,000 addresses before false positive rates degrade privacy.

Electrum servers (ElectrumX, Fulcrum) take a fundamentally different approach: they maintain an address-indexed database of all transactions, so each address lookup is a fast database query rather than a blockchain scan. Increasing the gap limit to hundreds or thousands has minimal performance impact, which makes Electrum-based wallets the practical choice for merchants, exchanges, and power users who need high gap limits. For a deeper look at how this indexing works, see the Electrum server architecture research article.

How to Adjust the Gap Limit

You can increase the gap limit in most wallet software if you suspect your wallet is missing funds because of it. The process varies by wallet.

Wasabi Wallet

After adjusting the gap limit in any wallet, you typically need to rescan the blockchain. The wallet will re-derive addresses up to the new limit and check each one for transaction history.

Wallet Recovery

Wallet recovery is the most common scenario where the gap limit matters because software restoring a seed phrase into a new wallet application must discover all addresses that ever received funds. If the original wallet generated addresses beyond the gap limit through merchant invoicing, CoinJoin, or multi-device use, the recovery wallet will show an incomplete balance until the gap limit is increased.

Merchant Payment Processing

Payment processors generate a unique address for each customer invoice. A store that creates hundreds of invoices daily will quickly exceed the default gap limit. BTCPay Server addresses this by using a rescan gap limit of 10,000, ensuring merchant funds are always discoverable during recovery.

UTXO Management

Users who practise careful coin control or UTXO management may generate many change addresses. Change addresses use a separate internal chain (change = 1), but the same gap limit logic applies. Heavy UTXO activity can push change addresses beyond the default scanning range.

Invisible Funds

The primary risk of the gap limit is an incorrect balance after wallet restoration, which can make you believe funds are lost when they sit at addresses beyond the scanning threshold. The danger is especially high if you discard your seed phrase thinking the wallet is empty. Always increase the gap limit and rescan before concluding that funds are missing.

Performance Tradeoff

Higher gap limits require scanning more addresses, which increases wallet recovery time. On full-node-backed wallets, scanning 10,000 addresses can take minutes or longer depending on hardware, while Electrum server-backed wallets have minimal overhead due to indexed lookups. Choose a gap limit appropriate for your usage pattern: 20 for casual use, 100 or more for merchants and mixing, 1,000 or more for exchanges.

Privacy Implications

Scanning many addresses reveals your interest in those addresses to whatever server processes the queries. SPV wallets using Bloom filters leak address information to connected peers. Running your own full node or Electrum server eliminates this concern since all queries stay local.

Cross-Wallet Compatibility

Not all wallets implement the gap limit identically: some scan only the external chain, others scan both external and internal (change) chains, and some use different default values, such as Wasabi's 21. When moving a seed between wallets, the new wallet may not find all funds if its gap limit behaviour differs from the original. Standardised output descriptors can help ensure consistent address discovery across wallet implementations; for more on wallet portability, see the research on output descriptor wallet portability.

The glossary entry is for informational purposes only and does not constitute financial or investment advice. Always do your own research before using any protocol or technology.

0

← All 1876 glossary terms