Bitcoin Forum

Bitcoin => Electrum => Topic started by: Envrin on March 05, 2015, 12:05:38 AM



Title: Question re: Watch Addresses
Post by: Envrin on March 05, 2015, 12:05:38 AM

I do quite a bit of BIP32 work these days, and Electrum seems to be the de-facto wallet that everyone loves.  So I'm trying to sync the online BIP32 systems I develop with Electrum.  This way funds will hit the online system, plus also be picked up by Electrum, so from the client's POV the funds will be going directly into their Electrum wallet, making them happier than a clam.  I notice when I put a BIP32 public key into Electrum, it'll auto-generate and watch the first 20 addresses.

Questions are:

1.) What key index structure is used to generate the addresses?  As long as I ensure the online system uses the same key index structure, both the online system and Electrum should generate and watch the same addresses.

2.) How do I increase that 20 auto-generated addresses to say 100?  My concern is there will be times when 20 addresses in a row go unused, which will break the sync.

3.) At what point does Electrum generate a new batch of addresses to watch for?  Does it wait until all addresses have had funds sent, or how does it handle that?

4.) Is there maybe any type of import functionality, where I can input a CSV file of inputs, and Electrum adds them to the wallet?  This would be the fool proof way, because then I can just have a "Download Inputs" button in the online system, which clients can import into their Electrum wallet.

5.) I can't seem to find any docs on plugin development.  Can someone point me in the right direction?  I have an offline signer (http://github.com/peterscott78/offline_signer) that I would like to integrate with Electrum -- clients can plug in their sends, they go into a pending queue within Electrum, then when ready they can download a JSON file for signing via my app.

Any help or advice would be greatly appreciated.  If it helps, please don't hesitate to get technical, as that's fine with me.

Thanks!


Title: Re: Question re: Watch Addresses
Post by: Abdussamad on March 07, 2015, 10:04:33 AM
1. m/0/i for external chain (receive addresses) and m/1/i for change addresses. 'i' being index. Hardening is not used :(

2. Run this on the console tab:

Code:
wallet.change_gap_limit( '100' )

3. When there are less than gap_limit of unused addresses from the index of the last used address. So when you receive bitcoins it generates new addresses so that you have 100 unused ones (from the index of the last used one).

4. Inputs? No. What use would that be if the private key doesn't belong to the wallet? There is offline functionality. Just copy the master public key from wallets menu to the online device and use the restore switch to create a watch only wallet:

Code:
electrum -w watch_only_file restore

You can then create a transaction using the "send" tab on the watch only wallet and it will ask you to save the transaction to a removable drive which you carry to the offline computer for signing using the load transaction option in the tools menu. Then carry it back to online system for broadcasting.

There is also the ability to create multiple output transactions using csv text: tools menu > create transaction.

5. There is a guide linked in the wiki:

https://electrum.orain.org/wiki/Main_Page


Title: Re: Question re: Watch Addresses
Post by: btchris on March 07, 2015, 05:05:45 PM
1. m/0/i for external chain (receive addresses) and m/1/i for change addresses. 'i' being index. Hardening is not used :(

Does any wallet use hardening at the internal/external (change) level? That's the only level there.... (if you're disappointed by the lack of account support, that's more understandable)


Code:
wallet.change_gap_limit( '100' )

Yikes, you meant this with no single quotes:
Code:
wallet.change_gap_limit( 100 )
(Yikes because Electrum doesn't type-check the argument, and will surprisingly try to create all 4 billion addresses if you pass it a string :o)


Just copy the master public key from wallets menu to the online device and use the restore switch to create a watch only wallet:

Just FYI you can also start a wallet restore, and paste the master public key into the place where you'd normally paste a seed.


Title: Re: Question re: Watch Addresses
Post by: Abdussamad on March 07, 2015, 05:40:46 PM
@btchris:
Great! Love the insights you provide. I liked this post of yours from the other day too:

https://bitcointalk.org/index.php?topic=973997.msg10644190#msg10644190



Title: Re: Question re: Watch Addresses
Post by: btchris on March 07, 2015, 06:05:55 PM
@btchris:
Great! Love the insights you provide. I liked this post of yours from the other day too:

https://bitcointalk.org/index.php?topic=973997.msg10644190#msg10644190

And thank you for the kind words :)

That creates-4-billion-addresses thing was sure a surprise to me. I actually just opened a PR on their repo with a one-line type check to catch anyone who happens to try passing in a string.