Bitcoin Forum

Bitcoin => Electrum => Topic started by: Sidney986 on May 30, 2020, 05:56:01 PM



Title: Electrum Private Key
Post by: Sidney986 on May 30, 2020, 05:56:01 PM
I note when exporting my private keys from BTC Electrum that the keys contain a colon character and several letters before it.  Is this part of the private key or should I only consider all characters after the colon as the private key?


Title: Re: Electrum Private Key
Post by: jackg on May 30, 2020, 06:38:12 PM
Characters before the key give the type of address, you should note all of it down or at least note the type at the top of where your putting it.

But is there a reason you're not using the mnemonic? It's not a good idea and is considered insecure to write down the key the way you're doing it.


Title: Re: Electrum Private Key
Post by: o_e_l_e_o on May 30, 2020, 06:39:51 PM
I note when exporting my private keys from BTC Electrum that the keys contain a colon character and several letters before it.  Is this part of the private key or should I only consider all characters after the colon as the private key?
The letters after the colon, beginning with a "K" or a "L", are your private key.

The letters before the colon tell Electrum what kind of address to generate from the private key.

"p2pkh" generates Legacy addresses beginning with "1"
"p2wpkh-p2sh" generates Nested SegWit addresses beginning with "3"
"p2wpkh" generates Native SegWit addresses beginning with "bc1"


Title: Re: Electrum Private Key
Post by: Sidney986 on May 31, 2020, 01:05:35 AM
Thanks.

No worries about security.  I sign using another computer, air gapped via Ubuntu.

So would the seed keys or private keys for the segwit wallet created in Electrum work on other bitcoin apps? 

I plan to keep using Electrum for air gapped signing as feel it's safer, but would still like this information should there be a future problem with Electrum.





Title: Re: Electrum Private Key
Post by: pooya87 on May 31, 2020, 03:18:03 AM
So would the seed keys or private keys for the segwit wallet created in Electrum work on other bitcoin apps? 

seed phrase (mnemonic) no, because Electrum uses a different way of creating those words that no other wallet supports (one or two may let you import the same seed but it won't be their default settings).
private keys yes, because private keys use a universal format (WIF, which is string after the colon) that is recognizable by all wallets but you may need to take additional steps to let the wallet know what type of address you were using (the part before the colon)


Title: Re: Electrum Private Key
Post by: Chikito on May 31, 2020, 04:26:20 AM
So would the seed keys or private keys for the segwit wallet created in Electrum work on other bitcoin apps? 
Like pooya87 said, electrum seed different like others.

If you Eager to trying electrum seed to another wallet, you have to read this

But you can derive the master private key itself from electrums seed (with several code snippets available on github), which then is compatible with most wallets.

And this

yes, not directly but a slightly modified BIP39 tool can derive from electrum seed mnemonic just fine
I just need to change 2 lines of code on iancoleman BIP39 tool to make it work for electrum seed mnemonic


Title: Re: Electrum Private Key
Post by: pooya87 on May 31, 2020, 06:52:29 AM
But you can derive the master private key itself from electrums seed (with several code snippets available on github), which then is compatible with most wallets.

there is a much better way of getting the master private/public key from the Electrum seed phrase that keeps you secure while avoiding possible bugs in those third party codes.
- remove the wallet password if you have any (Wallet > Password > enter previous pass and remove new one as empty)
- open the wallet location in explorer
- open wallet file in a text editor
- search for xprv (it is under "keystore") copy that!
- remember to re-encrypt the wallet file


Title: Re: Electrum Private Key
Post by: o_e_l_e_o on May 31, 2020, 08:00:57 AM
Or, if you already have Electrum installed and working on an airgapped computer as in OP's case, you can just pull the master private key directly from Electrum itself.

Remove the wallet password as pooya87 has said
If you don't have the console enabled, click View > Show Console
In the console, enter wallet.keystore.xprv
Then again go to Wallet > Password to re-enable your password


Title: Re: Electrum Private Key
Post by: nc50lc on May 31, 2020, 08:24:05 AM
Or, if you already have Electrum installed and working on an airgapped computer as in OP's case, you can just pull the master private key directly from Electrum itself.
Or Or,  :D  Just use getmasterprivate() and Electrum will prompt you to enter your password.
The Master private key will be displayed after entering the passphrase.


Title: Re: Electrum Private Key
Post by: o_e_l_e_o on May 31, 2020, 08:53:28 AM
Or Or,  :D  Just use getmasterprivate() and Electrum will prompt you to enter your password.
Huh. Didn't realize that prompted you for your password in a pop up box, rather than like the wallet.keystore.get_master_private_key('password') command, where you have to enter the password directly in the console, which then saves your password in plain text in your Electrum config file.


Title: Re: Electrum Private Key
Post by: pooya87 on May 31, 2020, 11:13:21 AM
~which then saves your password in plain text in your Electrum config file.

that was changed in 2b52ee2 (https://github.com/spesmilo/electrum/commit/2b52ee26e64b56b364e9dc3ed2150fceef925e08) about a year ago and the console history is now being stored in the wallet file instead of the config file. consequently it is encrypted in the same way that the wallet file is encrypted.
i believe that means any version >= 3.3.7 according to the release dates.


Title: Re: Electrum Private Key
Post by: Abdussamad on May 31, 2020, 05:13:45 PM
electrum will keep deriving new private keys from your seed and it'll keep moving coins to addresses corresponding to those private keys. in order to spend those coins you will need those newly generated private keys. that is why a private key export is a dangerous thing because it gives you a false sense of security. you think you have a good and complete backup but you don't. what you should be backing up is the seed. all private keys past, present and future are derived from that so if you have it's sufficient.


Title: Re: Electrum Private Key
Post by: Sidney986 on May 31, 2020, 09:11:37 PM
Just realised that I didn't save the seed keys from the Electrum wallet created about 2 years ago because I did not want to hold my Bitcoin on a hot wallet which is what Electrum is.

I just saved the public key to a txt file with the private key/s thinking this was all I needed for signing transations air gapped.  I did not realise those seed keys may be usefull to create my private keys.

So will my private key/s created over 2 years ago still work in the new versions of Electrum?   :o

It's possible that the keys were created in bitaddress offline version and used in Electrum for air gapped signing, but so long ago it's difficult to rememer at my old age.


Title: Re: Electrum Private Key
Post by: o_e_l_e_o on May 31, 2020, 09:23:53 PM
Yes, your keys will still work.

Simply create a new Electrum wallet, select "Import bitcoin addresses or private keys", and paste in your private keys, prefaced with the address type and a colon as we discussed higher up in this thread. It makes no difference if the keys were originally created on Electrum, bitaddress, or some other wallet or service - they will still import to Electrum just fine.

If you want to use Electrum as an airgapped wallet, then the best set up is to create a wallet on your airgapped machine, back up the seed phrase on to paper, export the extended public key, and then import the extended public key in to a new Electrum wallet on an internet enabled device. This will create a "watch only" wallet on the internet enabled device, which you can use to watch your addresses and to create transactions which you then transfer to your airgapped device to be signed, before transferring the signed transaction back to your live device to be broadcast.


Title: Re: Electrum Private Key
Post by: Sidney986 on June 01, 2020, 04:52:52 PM
I thank all of you for the indepth replies.  Much appreciated. :)