<p>If you just need a command line, you can try <code>pip3 install btc-address-dump</code>.</p>
<p>Here is an example:</p>
<pre><code>$ btc_address_dump &quot;olympic wine chicken argue unaware bundle tunnel grid spider slot spell need&quot;
mnemonic = olympic wine chicken argue unaware bundle tunnel grid spider slot spell need
private key (hex) = c7ac679b56f50bfd54dd924fe45a8dca7a1c2dced254b03dac22afc03adb9127
private key (WIF) = 5KLDyKtrScLYsKMJzVCt8Mf6Nn9DEV7V3fg8njfSZnqe7ZEMqzK
private key (WIF compressed) = L3urFcPsE2yHf5zeQjVSfUB8j8FEzX5cnmhjNsJfqjKgowPP4tmg
public key (uncompressed) = 044cd0aaeca3b636078583408e75edd77307b5190ca7a48bb9fbc1f2576c17dff1087190d91e26af594e3f8ecd3f4d3596c03c45d3b235da916903c930c6593cc4
public key (compressed) = 024cd0aaeca3b636078583408e75edd77307b5190ca7a48bb9fbc1f2576c17dff1
legacy address (p2pkh uncompressed) = 1Q5RqZctfcNkTPad2tuJSREByd2gB8xs63
legacy address (p2pkh compressed) = 12W36tm2jnreFiYdrzfE6cvRaKRbicEpnA
p2sh-segwit address (p2sh p2wpkh) = 3AzXxVUqdzvzEqVmdtmeVqRwc98uqwyh76
bech32 address (p2wpkh) = bc1qzp6lz6zy9p7k68r0a7lzfpkdxvj3yapynzuatt
</code></pre>

CC BY-SA 4.0
2021-02-01T14:56:20.207Z
This looks great thanks. I got errors though when I run ```import btc_address_dump```. This should work with python3.8.5 right? 
Alfie Stoppani
CC BY-SA 4.0
2023-12-01T10:42:43.857Z
how can I implement the btc_adress_dump in a good way, dou you have a complete python code for this.
Would be very great.
JOjo
CC BY-SA 4.0
2023-12-01T15:31:42.150Z
Hi JOjo, the project appears to be developed on this [github reposity](https://github.com/10gic/btc-address-dump) under an MIT license. This may present a good starting point for any amendments you wish to make.—I’m gonna delete your answer post since it’s not answering the question that started this topic. Please start a new topic if you have another question.
Murch
CC BY-SA 4.0
2021-02-01T02:41:27.140Z
2021-02-01T02:41:27.140Z
lemon
<p>So, I have written a script that generates BIP39 mnemonics. I now want to generate N native SegWit public keys from this mnemonic.</p>
<p>I have found <a href="https://bitcoin.stackexchange.com/questions/76655/how-to-generate-public-and-private-key-pairs-from-the-12-seed-words-in-python">this</a>, but it generates legacy addresses. It uses the module bip32utils.</p>
<pre><code>def bip39(mnemonic_words):
    mobj = mnemonic.Mnemonic(&quot;english&quot;)
    seed = mobj.to_seed(mnemonic_words)

    bip32_root_key_obj = bip32utils.BIP32Key.fromEntropy(seed)
    bip32_child_key_obj = bip32_root_key_obj.ChildKey(
        44 + bip32utils.BIP32_HARDEN
    ).ChildKey(
        0 + bip32utils.BIP32_HARDEN
    ).ChildKey(
        0 + bip32utils.BIP32_HARDEN
    ).ChildKey(0).ChildKey(0)

    return {
        'mnemonic_words': mnemonic_words,
        'addr': bip32_child_key_obj.Address(),
        'publickey': binascii.hexlify(bip32_child_key_obj.PublicKey()).decode(),
        'privatekey': bip32_child_key_obj.WalletImportFormat(),
        'coin': 'BTC'
    }

if __name__ == '__main__':
    seed = 'input display smile visa surround learn solar hero vacuum parrot cigar devote'
    pprint.pprint(bip39(seed))

</code></pre>
<p>I assume I need bip44utils or something, but it doesn't exists. I have tried looking at bip-utils but I can't work out how to convert my mnemonic to an address.</p>
<p>Does anyone know how I can convert a mnemonic to a SegWit address (in a way that I can change the derivation path to get multiple addresses)?</p>
<p>EDIT (SOLVED):</p>
<p>I found bitcoinlib can do this.</p>
<pre><code>from bitcoinlib.wallets import Wallet

passphrase = 'input display smile visa surround learn solar hero vacuum parrot cigar devote'

w = Wallet.create(&quot;Wallet1&quot;, witness_type='segwit', keys=passphrase, network='bitcoin')
WalletKeys = (w.get_keys(number_of_keys=10))

for k in WalletKeys:
    print(k.address)
</code></pre>
<p>And now it works just as I wanted it to.</p>

<segregated-witness><python><mnemonic-seed>
How can I generate SegWit addresses from a mnemonic using python?
Alfie Stoppani
# How can I generate SegWit addresses from a mnemonic using python?

(Asked by: username_0 on 2021-01-31)

So, I have written a script that generates BIP39 mnemonics. I now want to generate N native SegWit public keys from this mnemonic.

I have found [this](https://bitcoin.stackexchange.com/questions/76655/how-to-generate-public-and-private-key-pairs-from-the-12-seed-words-in-python), but it generates legacy addresses. It uses the module bip32utils.

```
def bip39(mnemonic_words):
    mobj = mnemonic.Mnemonic("english")
    seed = mobj.to_seed(mnemonic_words)

    bip32_root_key_obj = bip32utils.BIP32Key.fromEntropy(seed)
    bip32_child_key_obj = bip32_root_key_obj.ChildKey(
        44 + bip32utils.BIP32_HARDEN
    ).ChildKey(
        0 + bip32utils.BIP32_HARDEN
    ).ChildKey(
        0 + bip32utils.BIP32_HARDEN
    ).ChildKey(0).ChildKey(0)

    return {
        'mnemonic_words': mnemonic_words,
        'addr': bip32_child_key_obj.Address(),
        'publickey': binascii.hexlify(bip32_child_key_obj.PublicKey()).decode(),
        'privatekey': bip32_child_key_obj.WalletImportFormat(),
        'coin': 'BTC'
    }

if __name__ == '__main__':
    seed = 'input display smile visa surround learn solar hero vacuum parrot cigar devote'
    pprint.pprint(bip39(seed))

```

I assume I need bip44utils or something, but it doesn't exists. I have tried looking at bip-utils but I can't work out how to convert my mnemonic to an address.

Does anyone know how I can convert a mnemonic to a SegWit address (in a way that I can change the derivation path to get multiple addresses)?

EDIT (SOLVED):

I found bitcoinlib can do this.

```
from bitcoinlib.wallets import Wallet

passphrase = 'input display smile visa surround learn solar hero vacuum parrot cigar devote'

w = Wallet.create("Wallet1", witness_type='segwit', keys=passphrase, network='bitcoin')
WalletKeys = (w.get_keys(number_of_keys=10))

for k in WalletKeys:
    print(k.address)

```

And now it works just as I wanted it to.

**Tags:** segregated-witness, python, mnemonic-seed


---

## 1 answers

### Answer by username_1 on 2021-02-01. Score: 2

If you just need a command line, you can try `pip3 install btc-address-dump`.

Here is an example:

```
$ btc_address_dump "olympic wine chicken argue unaware bundle tunnel grid spider slot spell need"
mnemonic = olympic wine chicken argue unaware bundle tunnel grid spider slot spell need
private key (hex) = c7ac679b56f50bfd54dd924fe45a8dca7a1c2dced254b03dac22afc03adb9127
private key (WIF) = 5KLDyKtrScLYsKMJzVCt8Mf6Nn9DEV7V3fg8njfSZnqe7ZEMqzK
private key (WIF compressed) = L3urFcPsE2yHf5zeQjVSfUB8j8FEzX5cnmhjNsJfqjKgowPP4tmg
public key (uncompressed) = 044cd0aaeca3b636078583408e75edd77307b5190ca7a48bb9fbc1f2576c17dff1087190d91e26af594e3f8ecd3f4d3596c03c45d3b235da916903c930c6593cc4
public key (compressed) = 024cd0aaeca3b636078583408e75edd77307b5190ca7a48bb9fbc1f2576c17dff1
legacy address (p2pkh uncompressed) = 1Q5RqZctfcNkTPad2tuJSREByd2gB8xs63
legacy address (p2pkh compressed) = 12W36tm2jnreFiYdrzfE6cvRaKRbicEpnA
p2sh-segwit address (p2sh p2wpkh) = 3AzXxVUqdzvzEqVmdtmeVqRwc98uqwyh76
bech32 address (p2wpkh) = bc1qzp6lz6zy9p7k68r0a7lzfpkdxvj3yapynzuatt

```

> **Comments:**
> **username_0**: This looks great thanks. I got errors though when I run ```import btc_address_dump```. This should work with python3.8.5 right?   
> **username_2**: how can I implement the btc_adress_dump in a good way, dou you have a complete python code for this. Would be very great.  
> **username_3**: Hi username_2, the project appears to be developed on this [github reposity](https://github.com/10gic/btc-address-dump) under an MIT license. This may present a good starting point for any amendments you wish to make.—I’m gonna delete your answer post since it’s not answering the question that started this topic. Please start a new topic if you have another question.  

---

