An electrum wallet (legacy, testnet)
C# code for below windows application that returns 10 addresses from one XPUB using NBitcoin
var pubkey = ExtPubKey.Parse(textBox1.Text, Network.TestNet);
for (uint i=0; i < 10; i++)
{
var Address = pubkey.Derive(0).Derive(i).PubKey.GetAddress(ScriptPubKeyType.Legacy, Network.TestNet);
richTextBox1.AppendText(Address.ToString());
richTextBox1.AppendText("\n");
}
The gap limit is the maximum number of consecutive unused addresses in your deterministic sequence of addresses. Electrum uses it in order to stop looking for addresses. In Electrum, it is set to 20 by default, so the client will get all addresses until 20 unused addresses are found.
Electrum will generate new addresses as you use them, until it hits the gap limit. Addresses beyond the gap limit will not automatically be recovered from the seed. To recover them will require either increasing the client’s gap limit or generating new addresses until the used addresses are found. If you wish to generate more than one address, you can use a “for” loop. For example, if you wanted to generate 50 addresses, you could do this:
[wallet.create_new_address(False) for i in range(50)]
https://electrum.readthedocs.io/en/latest/faq.html#gap-limit
If I run the above code with i < 50
in for
loop I get 50 addresses from the XPUB
Gap limit can be changed with: wallet.change_gap_limit(50)
Now I see 50 addresses instead of 20 (excluding change addresses) in electrum wallet same as returned by the code above: