Bitcoin Forum
September 22, 2018, 07:50:43 PM *
News: ♦♦ New info! Bitcoin Core users absolutely must upgrade to previously-announced 0.16.3 [Torrent]. All Bitcoin users should temporarily trust confirmations slightly less. More info.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: How does an HD wallet know about addresses created from Master Public Key?  (Read 258 times)
boogersguy
Newbie
*
Offline Offline

Activity: 19
Merit: 0


View Profile
December 11, 2017, 11:50:43 AM
 #1


Say I have an Electrum HD wallet and give my Master Public Key to an external service (like CoinSimple for example: https://coinsimple.com/support/how-can-i-accept-bitcoin-directly-to-my-electrum-wallet-using-coinsimple/ )

That service can use my MPK to derive addresses that receive money in transactions.

How does the Electrum wallet know about those transactions? 
Does the wallet make RPC function calls internally to search/import for these transactions and addresses? 

1537645843
Hero Member
*
Offline Offline

Posts: 1537645843

View Profile Personal Message (Offline)

Ignore
1537645843
Reply with quote  #2

1537645843
Report to moderator
1537645843
Hero Member
*
Offline Offline

Posts: 1537645843

View Profile Personal Message (Offline)

Ignore
1537645843
Reply with quote  #2

1537645843
Report to moderator
1537645843
Hero Member
*
Offline Offline

Posts: 1537645843

View Profile Personal Message (Offline)

Ignore
1537645843
Reply with quote  #2

1537645843
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1537645843
Hero Member
*
Offline Offline

Posts: 1537645843

View Profile Personal Message (Offline)

Ignore
1537645843
Reply with quote  #2

1537645843
Report to moderator
1537645843
Hero Member
*
Offline Offline

Posts: 1537645843

View Profile Personal Message (Offline)

Ignore
1537645843
Reply with quote  #2

1537645843
Report to moderator
1537645843
Hero Member
*
Offline Offline

Posts: 1537645843

View Profile Personal Message (Offline)

Ignore
1537645843
Reply with quote  #2

1537645843
Report to moderator
ranochigo
Legendary
*
Offline Offline

Activity: 1554
Merit: 1089


View Profile WWW
December 11, 2017, 01:49:23 PM
 #2

How does the Electrum wallet know about those transactions? 
Electrum has the same master public key that is used in the service you've stated. With that, Electrum will constantly query for transactions in addresses within the gap limit.

For example, your gap limit is 25 addresses. After the initial address generated by default by Electrum, Electrum will continue to look for transactions in the next 25 address. If the next address has a transaction associated with it, Electrum will query another 25 addresses after it, and so on.
Does the wallet make RPC function calls internally to search/import for these transactions and addresses? 
Nope.

boogersguy
Newbie
*
Offline Offline

Activity: 19
Merit: 0


View Profile
December 11, 2017, 04:24:16 PM
 #3

Electrum has the same master public key that is used in the service you've stated. With that, Electrum will constantly query for transactions in addresses within the gap limit.

For example, your gap limit is 25 addresses. After the initial address generated by default by Electrum, Electrum will continue to look for transactions in the next 25 address. If the next address has a transaction associated with it, Electrum will query another 25 addresses after it, and so on.

Thanks!

Is there a way to tell Electrum to query beyond the gap limit?  Or, better yet, is there a way to tell Electrum to look for an address that was derived in an external application (like that CoinSimple example I gave) that might be beyond the configured gap limit?

Here's my actual problem:  I have a developer that is using a source code library that can take a MPK and derive a child address from it.  He wrote a test program that did this (using the MPK from my electrum wallet), and I sent a small amount of coin to it.  However, this address never appears in the Electrum wallet.  But it must be a valid child address because it was generated from the same master public key (MPK) and the transaction was successfully broadcast and included in a block.

Thanks in advance for any of your input.
bob123
Hero Member
*****
Offline Offline

Activity: 686
Merit: 568



View Profile WWW
December 11, 2017, 06:57:34 PM
 #4

Is there a way to tell Electrum to query beyond the gap limit?

You can set the gap limit with this command:
Code:
wallet.storage.put('gap_limit',[i]X[/i])
Or you could create a bunch of new addresses to see if its contained in there:
Code:
for i in range(0, X): print wallet.create_new_address(false)
false: for recieving addresses
true: for change adresses


Here's my actual problem:  I have a developer that is using a source code library that can take a MPK and derive a child address from it.  He wrote a test program that did this (using the MPK from my electrum wallet), and I sent a small amount of coin to it.  However, this address never appears in the Electrum wallet.  But it must be a valid child address because it was generated from the same master public key (MPK) and the transaction was successfully broadcast and included in a block.

Are you sure this address was derived correctly? He may have used the derivation path for change adresses?
The standard derivation path for electrum is 0/0/ for recieving and 0/1/ for change addresses (i think).

boogersguy
Newbie
*
Offline Offline

Activity: 19
Merit: 0


View Profile
December 11, 2017, 08:49:28 PM
 #5

You can set the gap limit with this command:
Code:
wallet.storage.put('gap_limit',[i]X[/i])
Or you could create a bunch of new addresses to see if its contained in there:
Code:
for i in range(0, X): print wallet.create_new_address(false)
false: for recieving addresses
true: for change adresses

I thought about doing this too.  I'll try it if all else fails.

Are you sure this address was derived correctly? He may have used the derivation path for change adresses?
The standard derivation path for electrum is 0/0/ for recieving and 0/1/ for change addresses (i think).

This is a good question and I don't know the answer. I'll ask him and find out. Maybe he's doing it incorrectly.
Thanks for your answer.
HCP
Hero Member
*****
Offline Offline

Activity: 728
Merit: 923

<insert witty quote here>


View Profile
December 11, 2017, 10:38:56 PM
 #6

I suspect you'll find it is the derivation path he is using is incorrect.

I'll guess he has gone with the "standard" m/44'/0'/0' derivation path specified in BIP44 and used by hardware wallets etc... most likely used if it was done by a "library". The problem is that Electrum uses a derivation path of m/0

Both paths will generate "valid" public keys/addresses... but they'll be different.

boogersguy
Newbie
*
Offline Offline

Activity: 19
Merit: 0


View Profile
December 12, 2017, 03:06:16 AM
 #7

I suspect you'll find it is the derivation path he is using is incorrect.

I'll guess he has gone with the "standard" m/44'/0'/0' derivation path specified in BIP44 and used by hardware wallets etc... most likely used if it was done by a "library". The problem is that Electrum uses a derivation path of m/0

Both paths will generate "valid" public keys/addresses... but they'll be different.

THANK YOU!

Your tip ultimately directed me to this link: https://bitcoin.stackexchange.com/questions/36955/what-bip32-derivation-path-does-electrum-use

Using the same logic from the approved answer on StackExchange, we updated our code and, voila, the addresses generated match the ones in Electrum

You made my day, HCP (and bob123)

Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!