10

Say I backup the "seed/key" for a deterministic wallet. I then create 10,000 transactions, resulting in 10,000 new addresses being generated.

Say I then lose the wallet file and I restore from the "seed/key". How does the deterministic wallet know it has to generate 10,000 addresses to get the full balance?

1 Answer 1

9

You've hit upon an important issue, and one that there isn't a perfect solution to.

Your thin client (most clients that use deterministic wallets are thin clients, but not all) goes through the following process:

  1. Generate an address.
  2. Look at the blockchain, and see if it has a balance.
  3. Repeat with next address, unless the addresses we've checked have had a balance of zero for a long time.

The number of empty addresses you're willing to check before giving up is called the gap limit.

The gap limit can't be too low, or there's a possibility that someone will backup from a wallet seed and not see all of their money. (If this happens to you, increase the gap limit and try again.) It also can't be too high, or you'll waste resources on the servers handling Electrum queries.

Your suggested scenario is actually the easiest to solve, because if each of those addresses has a transaction associated with it in the blockchain, the client knows that it showed that address to you at some point, and will keep searching.

6
  • 2
    I suppose a full client could handle a much higher gap limit, since it can check the block chain for an address itself, without querying an external server. Commented Oct 21, 2014 at 5:32
  • So in theory it in possible an existing address is never generated even at high limits, so even if you knew the exact address you couldn't regenerate the private key?
    – jiggunjer
    Commented Sep 24, 2017 at 6:34
  • @jiggunjer No. Set the gap limit high enough, and it will generate every address the client has even shown you, and more.
    – Nick ODell
    Commented Sep 24, 2017 at 14:36
  • @Nick_Odell how do you know? The generation is a random draw from an infinite set. So I don't see how anyone can guarantee a certain address will be drawn even if you keep drawing 24/7.
    – jiggunjer
    Commented Sep 24, 2017 at 15:24
  • @jiggunjer It isn't drawn randomly - it's drawn deterministically from a random number.
    – Nick ODell
    Commented Sep 24, 2017 at 17:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.