How does a wallet rebuild itself from its seed?

0

How does it identify the addresses and transactions on the blockchain in order to rebuild the history of that wallet?

Miyamoto Mustashi

Posted 2019-03-14T01:31:01.963

Reputation: 1

Answers

2

If by seed you are referring to a mnemonic phrase (12 or 24 words is common) then the process goes something like this:

  1. The phrase is hashed (or some other process) to produce random or pseudorandom bytes we will call the "seed"
  2. The byte array seed is passed into BIP32 HD master key algorithm to create a BIP32 master key.
  3. Following a standard like BIP44, the wallet then derives sub-keys sequentially in order. Checking for transaction history of each key's output.
  4. If left alone, this loop would last forever, so standards like BIP44 specify a "gap limit" which means that if gap limit = 20, then "If I generate 20 addresses in a row that all have 0 transactions in their history, I will stop checking addresses" For receiving paths, 20 seems common, for change paths 1 is standard.

Continue this loop until the gap limit is reached.

This type of methodology doesn't work for merchants or large exchanges, so the gap limit logic of "how far do we keep checking" may vary.

But most HD wallets rebuild themselves in this way.

user3074620

Posted 2019-03-14T01:31:01.963

Reputation: 176