<p>The derivation path you used is incorrect. Electrum does not use bip44. Anyway here's one way to do this for p2pkh addresses:</p>

<pre><code>from electrum import bitcoin
from electrum import keystore

seed = "&lt;seed here&gt;"
change = False
address_index = 0


k = keystore.from_seed( seed, '', False )
print( bitcoin.pubkey_to_address('p2pkh', k.derive_pubkey( change, address_index ) ) )
</code></pre>

CC BY-SA 4.0
2020-07-01T04:28:02.680Z
Greetings! Are you able to successfully import electrum into python, load a wallet, connect to the Official BTC network, and the list the balance of said wallet? I can't seem to figure out how to do that after spending a lot of time looking at their docs. the quick_start in scripts seems very helpful but it connects to a test-net and not the actual bitcoin network.
Sidharth Ghoshal
CC BY-SA 4.0
2020-07-02T07:04:24.670Z
@frogeyedpeas you should probably ask for help with that in #electrum irc channel on freenode.
Abdussamad
CC BY-SA 4.0
2018-11-23T03:33:53.897Z
2018-11-23T03:33:53.897Z
Abdussamad
<p>What am I doing wrong here? I'm trying to generate bitcoin addresses from the seed but they do not match with ones from electrum application. Did I miss something? And I also have trouble with generating wifs, as it seems they removed method bitcoin.SecretToASecret(prv, compressed=True), but I can't find with what they replaced it.</p>

<pre><code>from electrum import bitcoin
from electrum import keystore
from electrum.mnemonic import Mnemonic

defaultseed = "face circle glad valley exhibit find man oblige kingdom scorpion fish misery"

m44_0_0_0_0 = {
    'address': '1ALSQR3C68JLj5rtJHv594r5cviTqoXMNr',  # compressed by default
    'private_key': 'Ky9mddDtaqcLC1vv6egmgQpiZh8Lgh111LnJSyJENxJs3oW93bjD'
}

if __name__ == '__main__':

    password = ''
    bip32_seed = Mnemonic.mnemonic_to_seed(defaultseed, password)

    # m / purpose' / coin_type' / account' / change / address_index
    derivation = "m/44'/0'/0'/"
    xtype = keystore.xtype_from_derivation(derivation)
    # print('seed: {}'.format(repr(bip32_seed)))
    xprv, xpub = bitcoin.bip32_root(bip32_seed, xtype)
    # print('root: {0}  {1}'.format(xprv, xpub))

    xprv, xpub = bitcoin.bip32_private_derivation(xprv, 'm/', derivation)  # 1st account

    # generate first receiving addresses:
    i = 0
    prv, pub = bitcoin.bip32_private_derivation(xprv, "", "0/{index}".format(index=i))

    pub = bitcoin.deserialize_xkey(pub, False)[-1]
    prv = bitcoin.deserialize_xkey(prv, True)[-1]
    addr = bitcoin.public_key_to_p2pkh(pub)

    wif = 'how to generate wif from {prv} using electrum'

    print('{index:2}: {addr}  {wif}'.format(index=i, addr=addr, wif=wif))
</code></pre>

<electrum><python>
Python: How generate bitcoin addresses using electrum library
Katherine
# Python: How generate bitcoin addresses using electrum library

(Asked by: username_0 on 2018-11-16)

What am I doing wrong here? I'm trying to generate bitcoin addresses from the seed but they do not match with ones from electrum application. Did I miss something? And I also have trouble with generating wifs, as it seems they removed method bitcoin.SecretToASecret(prv, compressed=True), but I can't find with what they replaced it.

```
from electrum import bitcoin
from electrum import keystore
from electrum.mnemonic import Mnemonic

defaultseed = "face circle glad valley exhibit find man oblige kingdom scorpion fish misery"

m44_0_0_0_0 = {
    'address': '1ALSQR3C68JLj5rtJHv594r5cviTqoXMNr',  # compressed by default
    'private_key': 'Ky9mddDtaqcLC1vv6egmgQpiZh8Lgh111LnJSyJENxJs3oW93bjD'
}

if __name__ == '__main__':

    password = ''
    bip32_seed = Mnemonic.mnemonic_to_seed(defaultseed, password)

    # m / purpose' / coin_type' / account' / change / address_index
    derivation = "m/44'/0'/0'/"
    xtype = keystore.xtype_from_derivation(derivation)
    # print('seed: {}'.format(repr(bip32_seed)))
    xprv, xpub = bitcoin.bip32_root(bip32_seed, xtype)
    # print('root: {0}  {1}'.format(xprv, xpub))

    xprv, xpub = bitcoin.bip32_private_derivation(xprv, 'm/', derivation)  # 1st account

    # generate first receiving addresses:
    i = 0
    prv, pub = bitcoin.bip32_private_derivation(xprv, "", "0/{index}".format(index=i))

    pub = bitcoin.deserialize_xkey(pub, False)[-1]
    prv = bitcoin.deserialize_xkey(prv, True)[-1]
    addr = bitcoin.public_key_to_p2pkh(pub)

    wif = 'how to generate wif from {prv} using electrum'

    print('{index:2}: {addr}  {wif}'.format(index=i, addr=addr, wif=wif))

```

**Tags:** electrum, python


---

## 1 answers

### Answer by username_1 on 2018-11-23. Score: 5

The derivation path you used is incorrect. Electrum does not use bip44. Anyway here's one way to do this for p2pkh addresses:

```
from electrum import bitcoin
from electrum import keystore

seed = "<seed here>"
change = False
address_index = 0

k = keystore.from_seed( seed, '', False )
print( bitcoin.pubkey_to_address('p2pkh', k.derive_pubkey( change, address_index ) ) )

```

> **Comments:**
> **username_2**: Greetings! Are you able to successfully import electrum into python, load a wallet, connect to the Official BTC network, and the list the balance of said wallet? I can't seem to figure out how to do that after spending a lot of time looking at their docs. the quick_start in scripts seems very helpful but it connects to a test-net and not the actual bitcoin network.  
> **username_1**: @frogeyedpeas you should probably ask for help with that in #electrum irc channel on freenode.  

---

