Bitcoin Forum
May 22, 2024, 09:57:54 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: When deriving addresses from a PubKey, when to stop checking addresses for BTC?  (Read 1097 times)
racezefi (OP)
Member
**
Offline Offline

Activity: 80
Merit: 14


View Profile
April 19, 2016, 07:04:14 AM
 #1

Hey people, what's up?

Let's say you are deriving the path m/0/0/.
When do you stop deriving addresses and checking their balance? Do all HD implementations (Electrum, myCelium, MultibitHD) use contiguous indexes when creating a new address?

Example, m/0/0/0, m/0/0/1, m/0/0/2.

Hope I'm being clear.

Thanks.
racezefi (OP)
Member
**
Offline Offline

Activity: 80
Merit: 14


View Profile
April 19, 2016, 05:20:48 PM
 #2

In case anyone is wondering:

https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#account-discovery
bitdumper
Sr. Member
****
Offline Offline

Activity: 266
Merit: 250

One world One currency, Bitcoin.


View Profile
April 19, 2016, 05:21:18 PM
 #3

Generally it's 20. If 20 address balance is 0 then it's considered that master key was not used.

CIYAM
Legendary
*
Offline Offline

Activity: 1890
Merit: 1078


Ian Knowles - CIYAM Lead Developer


View Profile WWW
April 19, 2016, 05:24:27 PM
 #4

Generally it's 20. If 20 address balance is 0 then it's considered that master key was not used.

It's not address balance but usage history that matters (as of course the balance might be zero for thousands of used addresses).

(i.e. the algorithm will be searching the spent as well as unspent outputs)

Unfortunately those with ad-sigs tend to post incorrect things (as all they care about is getting paid to post).

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
danda
Full Member
***
Offline Offline

Activity: 201
Merit: 157


View Profile WWW
April 19, 2016, 05:52:28 PM
 #5

The default is to stop after 20.   Unfortunately some wallet software such as very old versions of Copay generated a new address each time the user clicks "receive" button, and therefore may have gaps larger than 20.   As far as I know, they all use contiguous addresses.  Also, if you need change addresses you must check (relative) 1/n in addition to 0/n.

If you're just looking for a quick tool for wallet discovery, you may find this helpful:
CLI: https://github.com/dan-da/hd-wallet-addrs
Web: https://mybitprices.info/hd-wallet-addrs.html

mybitprices.info - wallet auditing   |  hd-wallet-derive - derive keys locally |  hd-wallet-addrs - find used addrs
lightning-nodes - list of LN nodes  |  coinparams - params for 300+ alts  |  jsonrpc-cli - cli jsonrpc client
subaddress-derive-xmr - monero offline wallet tool
racezefi (OP)
Member
**
Offline Offline

Activity: 80
Merit: 14


View Profile
April 20, 2016, 09:14:28 PM
 #6

The default is to stop after 20.   Unfortunately some wallet software such as very old versions of Copay generated a new address each time the user clicks "receive" button, and therefore may have gaps larger than 20.   As far as I know, they all use contiguous addresses.  Also, if you need change addresses you must check (relative) 1/n in addition to 0/n.

If you're just looking for a quick tool for wallet discovery, you may find this helpful:
CLI: https://github.com/dan-da/hd-wallet-addrs
Web: https://mybitprices.info/hd-wallet-addrs.html

That's very useful, thanks, danda!

Thanks everyone for their input.
belcher
Sr. Member
****
Offline Offline

Activity: 261
Merit: 521


View Profile
April 21, 2016, 03:24:57 PM
 #7

There is the concept of a gap limit.

It is explained here because it's also used in JoinMarket https://github.com/JoinMarket-Org/joinmarket/wiki/Using-the-JoinMarket-internal-wallet#what-is-the-gap-limit

It's generally a good idea for it to be configurable so users recovering wallets can try different values.

1HZBd22eQLgbwxjwbCtSjhoPFWxQg8rBd9
JoinMarket - CoinJoin that people will actually use.
PGP fingerprint: 0A8B 038F 5E10 CC27 89BF CFFF EF73 4EA6 77F3 1129
luv2drnkbr
Hero Member
*****
Offline Offline

Activity: 793
Merit: 1016



View Profile
April 23, 2016, 03:21:46 PM
 #8

The standard for most HD wallets is some variant of this:

Main account:  m/0/i
Change account:  m/1/i

where i is an index number, and starts at 0.

Some wallets use longer ones, like m/44'/0'/0'/0/i for main, and m/44'/0'/0'/1/i for change, but you can see the last three parts of the string still have the general format of "m/0/i" (from m/44'/0'/0'/0/i) and "m/1/i" (from m/44'/0'/0'/1/i).

The standard way to scan it is:  You increment i and scan until you find 20 consecutive addresses with no transaction history (not just 0 balance, but no history either), and then you assume that there's nothing more after that.  You do that for the main and for the change account.

That number 20 is arbitrary but is the standard used by most places, and it is referred to as the "gap limit".

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!