<p>There is an alternative way to extract the master extended private key (xprv): in the Electrum console, simply type this:</p>

<pre><code>wallet.get_master_private_key('x/', gui.password_dialog())
</code></pre>

<p>Or for the master private key of a wallet created with Electrum 1.x, it's:</p>

<pre><code>wallet.get_seed(gui.password_dialog())
</code></pre>

<h3>Warning</h3>

<p>Don't ever type your password or a private key into the console. In other words, don't do this:</p>

<pre><code>wallet.get_seed('my-password')
</code></pre>

<p>Everything you type into the console is temporarily stored inside your wallet file <em>unencrypted</em> to make the command history feature (accessed via the up-arrow) work.</p>

CC BY-SA 3.0
2015-04-25T15:15:45.177Z
Where on earth did you find that?! Nice work!
Wizard Of Ozzie
CC BY-SA 3.0
2015-04-25T16:24:30.907Z
Thanks! Someone on Bitcointalk was asking how to do this today, and I thought I'd dig around the Electrum source a bit to see if I could figure out a better way to do this before responding. Afterwards, it made sense to update this answer and get rid of the not-so-safe method that was here before.
Christopher Gurnee
CC BY-SA 3.0
2015-04-25T17:15:27.120Z
`wallet.get_master_private_key('x/', None)` with no password FWIW, not `""`
Wizard Of Ozzie
CC BY-SA 3.0
2015-04-16T15:56:07.673Z
2015-04-25T16:27:50.863Z
2015-04-25T16:27:50.863Z
Christopher Gurnee
<p>Thomas Voegtlin , the developer of Electrum explains the reasoning in the first 10 minutes of this interview. I think he also posted same thing to Bitcoin dev mailing list some time ago.</p>

<p><a href="https://letstalkbitcoin.com/blog/post/epicenter-bitcoin-69-thomas-voegtlin-electrum-spv-wallets-and-bitcoin-aliases" rel="nofollow">https://letstalkbitcoin.com/blog/post/epicenter-bitcoin-69-thomas-voegtlin-electrum-spv-wallets-and-bitcoin-aliases</a></p>

<p>His main point against BIP39 is that it doesn't include a version number, and the requirement of the word list dictionary in order to implement it. </p>

CC BY-SA 3.0
2015-04-12T15:24:27.507Z
2015-04-12T15:24:27.507Z
k kurokawa
<p>Note: July 2017, Electrum v2.8.3... the command is now:</p>

<pre><code>getmasterprivate()
</code></pre>

<p>The password dialog box will automagically pop up ;)</p>

CC BY-SA 3.0
2017-07-11T05:05:07.493Z
Hi HCP, welcome to Bitcoin.SE, and thanks for the update! We usually try to fully address the question in each answer, so, if you could add a little more explanation that would be great. If you just want to update a small part of an existing answer, you can also suggest an edit on it.
Murch
CC BY-SA 3.0
2017-07-11T04:49:16.990Z
2017-07-11T04:49:16.990Z
HCP
<p>I just found <a href="http://www.reddit.com/r/Bitcoin/comments/2zym7e/how_to_export_master_private_key_xprv_on_electrum/" rel="nofollow">this over at /r/Bitcoin:</a>, so apparently there's an exe to do this, but I'm not exactly game, since downloading the link got flagged by chrome.</p>

<p>It appears Electrum uses: <code>m/0/0</code> for wallet addresses and <code>m/1/0</code> for change addresses.</p>

<p><strong><em>EDIT:</em></strong> <a href="https://github.com/vbuterin/pybitcointools/pull/84" rel="nofollow">A pull request has been submitted</a> for code which extracts the root seed from the Electrum 2.0 seed phrase:</p>

<pre><code>def electrumv2_extract_seed(words, password=''):
    """Takes Electrum v2.0 13 word mnemonic string and returns seed. Only works on English for now"""
    # clean-up unicode characters
    mnemonic = words[:]
    try:
        mnemonic = unicodedata.normalize('NFC', unicode(' '.join(words.lower().strip().split()))).encode('utf-8') # a string of 13 words
    except Exception as e:
        raise Exception(str(e))
    rootseed = pbkdf2.PBKDF2(str(mnemonic), str('electrum' + password), 2048,  macmodule=hmac, digestmodule=hashlib.sha512).read(64)
    return rootseed

def electrumv2_mnemonic_to_mprivkey(words, password=''):
    return bip32_master_key(electrumv2_extract_seed(words, password=''))
</code></pre>

<p>This is for use with <a href="https://github.com/vbuterin/pybitcointools" rel="nofollow">pybitcointools</a> as <code>from bitcoin import *</code> in Python 2.7</p>

CC BY-SA 3.0
2015-04-09T01:44:40.627Z
2015-04-14T12:18:14.757Z
2015-04-14T12:18:14.757Z
Wizard Of Ozzie
<p>Electrum 2.0 has been causing me some frustration, insofar as it seems to be a non-standard implementation of BIP32/BIP39 (HD wallets, mnemonic seed, respectively). The wallet in question is a 2of2 multisig wallet (all P2SH), with the 2nd extended public key being created in <em>pybitcointools</em> using </p>

<p><code>bip32_privtopub( bip32_master_key( sha256("a password") ) )</code>, </p>

<p>then imported into Electrum.</p>

<p>Given the 13 word seed, which itself is non standard since the last word is a checksum, it's proven impossible to export the <code>xpriv</code> key from Electrum. </p>

<p>How is a mnemonic seed converted to a BIP32 standard extended private key (given the client itself won't allow it)? : <strong>EDIT1</strong>: <em>with great difficulty, see my <a href="https://bitcoin.stackexchange.com/a/36840/9382">answer</a> below</em></p>

<p><strong>(REFOCUSED) QUESTION</strong>: *why does Electrum:</p>

<ul>
<li>stray from BIP0039?</li>
<li>make exporting the master BIP32 private key <em>impossible?</em></li>
<li>return partially signed P2SH hex Txs which are malformed?</li>
</ul>

<electrum><thin-clients><bip32-hd-wallets><p2sh><mnemonic-seed>
Electrum 2.0: non-BIP39/32 standardisation complicates matters immensely. Why?
Wizard Of Ozzie
# Electrum 2.0: non-BIP39/32 standardisation complicates matters immensely. Why?

(Asked by: username_0 on 2015-04-09)

Electrum 2.0 has been causing me some frustration, insofar as it seems to be a non-standard implementation of BIP32/BIP39 (HD wallets, mnemonic seed, respectively). The wallet in question is a 2of2 multisig wallet (all P2SH), with the 2nd extended public key being created in *pybitcointools* using

`bip32_privtopub( bip32_master_key( sha256("a password") ) )`,

then imported into Electrum.

Given the 13 word seed, which itself is non standard since the last word is a checksum, it's proven impossible to export the `xpriv` key from Electrum.

How is a mnemonic seed converted to a BIP32 standard extended private key (given the client itself won't allow it)? : **EDIT1**: *with great difficulty, see my [answer](https://bitcoin.stackexchange.com/a/36840/9382) below*

**(REFOCUSED) QUESTION**: \*why does Electrum:

* stray from BIP0039?
* make exporting the master BIP32 private key *impossible?*
* return partially signed P2SH hex Txs which are malformed?

**Tags:** electrum, thin-clients, bip32-hd-wallets, p2sh, mnemonic-seed


---

## 4 answers

### Answer by username_1 on 2015-04-16. Score: 2 | Accepted answer

There is an alternative way to extract the master extended private key (xprv): in the Electrum console, simply type this:
wallet.get_master_private_key('x/', gui.password_dialog())

Or for the master private key of a wallet created with Electrum 1.x, it's:
wallet.get_seed(gui.password_dialog())

Warning
Don't ever type your password or a private key into the console. In other words, don't do this:
wallet.get_seed('my-password')

Everything you type into the console is temporarily stored inside your wallet file unencrypted to make the command history feature (accessed via the up-arrow) work.

> **Comments:**
> **username_0**: Where on earth did you find that?! Nice work!  
> **username_1**: Thanks! Someone on Bitcointalk was asking how to do this today, and I thought I'd dig around the Electrum source a bit to see if I could figure out a better way to do this before responding. Afterwards, it made sense to update this answer and get rid of the not-so-safe method that was here before.  
> **username_0**: `wallet.get_master_private_key('x/', None)` with no password FWIW, not `""`  

---

### Answer by username_2 on 2015-04-12. Score: 3

Thomas Voegtlin , the developer of Electrum explains the reasoning in the first 10 minutes of this interview. I think he also posted same thing to Bitcoin dev mailing list some time ago.

<https://letstalkbitcoin.com/blog/post/epicenter-bitcoin-69-thomas-voegtlin-electrum-spv-wallets-and-bitcoin-aliases>

His main point against BIP39 is that it doesn't include a version number, and the requirement of the word list dictionary in order to implement it.


---

### Answer by username_3 on 2017-07-11. Score: 2

Note: July 2017, Electrum v2.8.3... the command is now:
getmasterprivate()

The password dialog box will automagically pop up ;)

> **Comments:**
> **username_4**: Hi username_3, welcome to Bitcoin.SE, and thanks for the update! We usually try to fully address the question in each answer, so, if you could add a little more explanation that would be great. If you just want to update a small part of an existing answer, you can also suggest an edit on it.  

---

### Answer by username_0 on 2015-04-09. Score: 0

I just found this over at /r/Bitcoin:, so apparently there's an exe to do this, but I'm not exactly game, since downloading the link got flagged by chrome.
It appears Electrum uses: m/0/0 for wallet addresses and m/1/0 for change addresses.
EDIT: A pull request has been submitted for code which extracts the root seed from the Electrum 2.0 seed phrase:
def electrumv2_extract_seed(words, password=''):
    """Takes Electrum v2.0 13 word mnemonic string and returns seed. Only works on English for now"""
    # clean-up unicode characters
    mnemonic = words[:]
    try:
        mnemonic = unicodedata.normalize('NFC', unicode(' '.join(words.lower().strip().split()))).encode('utf-8') # a string of 13 words
    except Exception as e:
        raise Exception(str(e))
    rootseed = pbkdf2.PBKDF2(str(mnemonic), str('electrum' + password), 2048,  macmodule=hmac, digestmodule=hashlib.sha512).read(64)
    return rootseed

def electrumv2_mnemonic_to_mprivkey(words, password=''):
    return bip32_master_key(electrumv2_extract_seed(words, password=''))

This is for use with pybitcointools as from bitcoin import * in Python 2.7


---

