Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: btc_enigma on July 31, 2015, 09:59:59 AM



Title: getting balance of xpub key using bitcoind
Post by: btc_enigma on July 31, 2015, 09:59:59 AM
I want to know how https://blockchain.info/xpub/xpub6CUGRUonZSQ4TWtTMmzXdrXDtypWKiKrhko4egpiMZbpiaQL2jkwSB1icqYh2cfDfVxdx4df189oLKnC5fSwqPfgyP3hooxujYzAu3fDVmz
works ?

How does it calculate the balance from utxo  ? Does it match each address in utxo to check if it is a child of given xpub key (I don't think so), or it always computes say 10 child addresses and shows their balance.

Sorry, couldn't find answer in other places. Feel free to point me it post if its already answered.


Title: Re: getting balance of xpub key using bitcoind
Post by: Muhammed Zakir on July 31, 2015, 11:01:54 AM
AFAIK it derives tree and scan external chain addresses to see transactions.


Title: Re: getting balance of xpub key using bitcoind
Post by: btc_enigma on July 31, 2015, 11:06:22 AM
AFAIK it derives tree and scan external chain addresses to see transactions.

Do you know  how far does it derive the tree(depth and breath) ?


Title: Re: getting balance of xpub key using bitcoind
Post by: Muhammed Zakir on July 31, 2015, 11:53:44 AM
AFAIK it derives tree and scan external chain addresses to see transactions.

Do you know  how far does it derive the tree(depth and breath) ?

It stops searching until "X" number of consecutive unused addresses is found, where X is gap limit. By default, gap limit is 20 but it depends on wallet software. I think you can also go with 20 as gap limit.


Title: Re: getting balance of xpub key using bitcoind
Post by: btc_enigma on August 01, 2015, 07:11:22 AM
AFAIK it derives tree and scan external chain addresses to see transactions.

Do you know  how far does it derive the tree(depth and breath) ?

It stops searching until "X" number of consecutive unused addresses is found, where X is gap limit. By default, gap limit is 20 but it depends on wallet software. I think you can also go with 20 as gap limit.

Thanks MZ,  now I had a look at Account discovery in  https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki and it seems to match what you described. Also had a look at  HD wallets
 (https://onedrive.live.com/view.aspx?resid=584F122BA17116EE!313&app=Excel)
I  see wallets using m/44'/0'/0'/c/i , and also m/0/0'/a'/c/i . I would assume https://blockchain.info/xpub/xpub6CUGRUonZSQ4TWtTMmzXdrXDtypWKiKrhko4egpiMZbpiaQL2jkwSB1icqYh2cfDfVxdx4df189oLKnC5fSwqPfgyP3hooxujYzAu3fDVmz is searching using m/c/i .

I think its easiest for blockonomics  to ask user to enter wallet name so that we use the appropriate path to import addresses.


Title: Re: getting balance of xpub key using bitcoind
Post by: Muhammed Zakir on August 01, 2015, 12:03:27 PM
-snip-
I think its easiest for blockonomics  to ask user to enter wallet name so that we use the appropriate path to import addresses.

That is a good idea. Feel free to ask if you have any doubt/problem. Good luck!


Title: Re: getting balance of xpub key using bitcoind
Post by: btc_enigma on August 11, 2015, 04:56:54 AM
HI MZ,

Would it possible for you to help us test xpub search in blockonomics, find details here https://bitcointalk.org/index.php?topic=880995.msg12105873#msg12105873


Thanks