Bitcoin Forum
May 22, 2024, 05:44:45 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How does the wallets know which addresses to recover in Hardware Wallet recovery  (Read 199 times)
johnokeefe09 (OP)
Newbie
*
Offline Offline

Activity: 112
Merit: 0


View Profile
June 16, 2018, 12:10:45 AM
 #1

I have been reading the BIP32 proposal explaining how HD works but it didn't mention on any point how one wallet in one phone can recover from a simple mnemonic seed.

   1. Does it just try all possible addresses related to that seed's master key by doing the entire blockchain look up for addresses at the same time ? (This seems impractical imo).

   2. Are there standards on the max nth of address to generate from the wallet side ?

RGBKey
Hero Member
*****
Offline Offline

Activity: 854
Merit: 658


rgbkey.github.io/pgp.txt


View Profile WWW
June 16, 2018, 01:17:44 AM
 #2

I believe they generate up to a certain amount by default, that can be configured to be larger if it's not generating all the addresses that you've used.
HCP
Legendary
*
Offline Offline

Activity: 2086
Merit: 4316

<insert witty quote here>


View Profile
June 16, 2018, 04:42:58 AM
Merited by Welsh (1), HeRetiK (1)
 #3

I have been reading the BIP32 proposal explaining how HD works but it didn't mention on any point how one wallet in one phone can recover from a simple mnemonic seed.
   1. Does it just try all possible addresses related to that seed's master key by doing the entire blockchain look up for addresses at the same time ? (This seems impractical imo).
Most wallet implement what is known as the "Gap Limit" method of address generation. Essentially, they will continue to generate (and check) addresses until they have found N consecutive addresses that are "unused". In this instance, "unused" means there are no transactions to said address on the blockchain. It is generally NOT related to current balance... but to whether or not the address shows up in any transactions

For instance, imagine that our Gap Limit was 5... and we had a wallet that looked like this:
Address1 - 2 txes - Balance 0 BTC
Address2 - unused
Address3 - unused
Address4 - 1 tx - Balance 0.1 BTC
Address5 - unused
Address6 - unused
Address7 - unused
Address8 - unused
Address9 - unused
Address10 - 1 tx - Balance 0.1 BTC

With a Gap Limit of 5... during a restore... the wallet would likely stop generating addresses at Address9, and tell us we only have 0.1 BTC, as Address9 would have been the 5th address in a row with no transaction history found.

If the Gap Limit was more than 5, then during the restore, it would also find Address10 and show the full balance of 0.2 BTC.


Quote
   2. Are there standards on the max nth of address to generate from the wallet side ?
Not really... it is usually up to the wallet developer what value they use... and likely related to the wallets system of generating new addresses.

I know that, by default, Electrum uses a Gap Limit of 25 for receive addresses (and only 5 for change addresses). I believe MultiBit HD used to use a Gap Limit of 50 or 100... but MultiBit HD had this weird system where every single time you displayed the "receive" tab, it would generate a new address (regardless of whether or not you wanted a new address). So you could end up with a LOT of unused addresses and large "gaps".

It's a balancing act really... gap limit too large means a long wait for the user while the wallet generates and checks addresses during restore... gap limit too small means you might miss addresses/balance during restore.

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
Xynerise
Sr. Member
****
Offline Offline

Activity: 322
Merit: 363

39twH4PSYgDSzU7sLnRoDfthR6gWYrrPoD


View Profile
June 16, 2018, 04:57:47 AM
 #4

Quote
Does it just try all possible addresses related to that seed's master key by doing the entire blockchain look up for addresses at the same time ? (This seems impractical imo).
When a HD wallet syncs it generates a set of addresses from the derivation path m/k'/0/i, then it scans the blockchain for transactions related to those addresses. If there are transactions related to that address (even if the address is empty), it generates more addresses until the gap limit is reached.
The gap limit is a certain number of addresses in a row which have no transactions at all.

Quote
Are there standards on the max nth of address to generate from the wallet side ?
The default gap limit is 20.
Other wallets may have different implementations.
witch
Sr. Member
****
Offline Offline

Activity: 616
Merit: 250



View Profile
June 20, 2018, 09:50:13 PM
 #5

I have been reading the BIP32 proposal explaining how HD works but it didn't mention on any point how one wallet in one phone can recover from a simple mnemonic seed.

   1. Does it just try all possible addresses related to that seed's master key by doing the entire blockchain look up for addresses at the same time ? (This seems impractical imo).

   2. Are there standards on the max nth of address to generate from the wallet side ?


As far as I know there are standard recommendation drafts that determine how to generate it from the wallet side.

You should reach out to the support of the appropriate hardware wallet you are using, like Trezor or similar.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!