Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: jhawkings on September 02, 2020, 02:13:24 PM



Title: sending to an address generated with your xpub key
Post by: jhawkings on September 02, 2020, 02:13:24 PM
Hi,

I currently use Electrum wallet but I do not always have the wallet on me, it's currently only used on a laptop which is rarely online. So I was thinking of generating an address from my xpub key and creating a generator on my dev site which I can access with phone, or at work.

If I send to an address that has been generated using my xpub will it appear in my Electrum wallet even if Electrum has not generated that address keypair yet? or is there a way I can tell electrum to generate this keypair forcefully using the HD path for example?

Thanks for help.


Title: Re: sending to an address generated with your xpub key
Post by: jackg on September 02, 2020, 02:16:30 PM
Yeah anything generated by your xpub will be on both wallets. If you have an android phone I'd recommend getting the electrum app itself and scanning the xpub straight into that.

You may want to search "electrum change gap limit on console" too see how to add more addresses by using a simple command.


Title: Re: sending to an address generated with your xpub key
Post by: BrewMaster on September 02, 2020, 04:01:05 PM
that is the whole point of HD wallets using BIP32 with non-hardened keys, you can produce the same public key from both the xprv and the xpub. and wallets like Electrum do use this scheme to make offline storage and setups like what you are trying to do easily possible.

if you generate the keys automatically they will be sequential and should show up automatically in any wallet you use unless you manually generated a key way down the line at a very high index in which case you have to change the gap as jackg pointed out.


Title: Re: sending to an address generated with your xpub key
Post by: Abdussamad on September 03, 2020, 07:07:00 PM
Hi,

I currently use Electrum wallet but I do not always have the wallet on me, it's currently only used on a laptop which is rarely online. So I was thinking of generating an address from my xpub key and creating a generator on my dev site which I can access with phone, or at work.

If I send to an address that has been generated using my xpub will it appear in my Electrum wallet even if Electrum has not generated that address keypair yet? or is there a way I can tell electrum to generate this keypair forcefully using the HD path for example?

Thanks for help.

addresses should be created at m/0/i where m is the xpub, and i is the index. by default electrum maintains a gap limit or readahead window of 20 unused addresses. as you send money to old addresses new addresses are automatically created to maintain this readahead window.

if you create gaps of unused addresses larger than that gap limit then you will have to raise the gap limit on the laptop so that it sees the addresses you've used.

the easiest way to ensure that you generate the right addresses  is to use electrum itself on your dev site. create a watch only wallet using the xpub and then use the add_request command to get addresses via jsonrpc.


https://electrum.readthedocs.io/en/latest/jsonrpc.html