Bitcoin Forum
May 08, 2024, 10:42:16 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How does an HD wallet know about addresses created from Master Public Key?  (Read 355 times)
boogersguy (OP)
Newbie
*
Offline Offline

Activity: 21
Merit: 2


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? 

1715164936
Hero Member
*
Offline Offline

Posts: 1715164936

View Profile Personal Message (Offline)

Ignore
1715164936
Reply with quote  #2

1715164936
Report to moderator
1715164936
Hero Member
*
Offline Offline

Posts: 1715164936

View Profile Personal Message (Offline)

Ignore
1715164936
Reply with quote  #2

1715164936
Report to moderator
1715164936
Hero Member
*
Offline Offline

Posts: 1715164936

View Profile Personal Message (Offline)

Ignore
1715164936
Reply with quote  #2

1715164936
Report to moderator
The network tries to produce one block per 10 minutes. It does this by automatically adjusting how difficult it is to produce blocks.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
ranochigo
Legendary
*
Offline Offline

Activity: 2968
Merit: 4168



View Profile
December 11, 2017, 01:49:23 PM
Merited by ABCbits (2)
 #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.

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
boogersguy (OP)
Newbie
*
Offline Offline

Activity: 21
Merit: 2


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
Legendary
*
Offline Offline

Activity: 1624
Merit: 2481



View Profile WWW
December 11, 2017, 06:57:34 PM
Last edit: December 11, 2017, 07:16:27 PM by bob123
 #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 (OP)
Newbie
*
Offline Offline

Activity: 21
Merit: 2


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
Legendary
*
Offline Offline

Activity: 2086
Merit: 4316

<insert witty quote here>


View Profile
December 11, 2017, 10:38:56 PM
Merited by xtraelv (1)
 #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.

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


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
boogersguy (OP)
Newbie
*
Offline Offline

Activity: 21
Merit: 2


View Profile
December 12, 2017, 03:06:16 AM
Merited by ABCbits (1), xtraelv (1)
 #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:  

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