<p>Assuming that:</p>
<ul>
<li>you have the <strong>root</strong> Xprv and not the one at m/44'/0'/0' for example</li>
<li>the derivation path is the same as you said</li>
</ul>
<p>You can use <a href="https://github.com/mcdallas/cryptotools" rel="nofollow noreferrer">this</a> Python library (disclaimer: I am the author)</p>
<pre class="lang-python prettyprint-override"><code>from cryptotools import Xprv
from cryptotools.BTC.opcodes import ADDRESS

prv = Xprv.decode('xprv9s21ZrQH143K38bNJiHY54kkjio8o6aw3bRjCbzi8KgRxNy98avUribz1wk85ToSUV2VwVuc73NJWc2YGwpMtqz7bBFUh9Q77RtJeuh2zvy')
prv.type = ADDRESS('P2WPKH')
prv.encode()
'zprvAWgYBBk7JR8GjiybyRrnVEwm5f62gLZvspUAmPnUtLSC4abbduFc6qvG4MfJ5H7HHmG7ST6j2N5QHBFfiLePVKMKKreKry35et1bS1HZYDu'

</code></pre>

CC BY-SA 4.0
2023-03-30T14:56:39.043Z
2023-03-30T14:56:39.043Z
Mike D
<p><strong>Goal:</strong> after creating a descriptor wallet in Bitcoin Core for automated e-commerce order processing, setup a backup Electrum wallet for the market owner with the ability to sign.</p>
<p><strong>Steps:</strong></p>
<ol>
<li><p>Create a new descriptor wallet in Bitcoin Core.</p>
</li>
<li><p><code>listdescriptors true</code> to extract <code>xprv</code></p>
</li>
<li><p>?? Convert <code>xprv</code> to <code>zprv</code> &lt;== stuck here.</p>
</li>
<li><p>Import <code>zprv</code> into Electrum.</p>
</li>
</ol>
<p><strong>Problem:</strong> Stuck at creating <code>zprv</code> from <code>xprv</code>.</p>
<p>If I import <code>xprv</code> into Electrum as is, it will generate old addresses <code>1...</code>. Instead, my goal is to import a <code>zprv</code> so that it knows to generate bech32 addresses: <code>bc1...</code>.</p>
<p>From what I've read <a href="https://bitcoin.stackexchange.com/a/106297/107366">here</a>, it is impossible without having the HD seed.</p>
<p>However, in my case, the derivation path is the same in both Bitcoin Core and Electrum. hence <strong>the question</strong>: can I transform <code>xprv</code> into <code>zprv</code> without losing any information along, and for the sole goal being to let Electrum understand that bech32 addresses are to be generated?</p>
<p>Is this possible theoretically, and if so, any code snippets you can point to?</p>
<p>Alternatively, is there any other way to restore the wallet in Electrum in such a way that it generates the same bech32 addresses?</p>

<private-key-import><private-key-format>
convert Bitcoin Core' xprv to Electrum zprv
Meglio
# convert Bitcoin Core' xprv to Electrum zprv

(Asked by: username_0 on 2023-03-30)

**Goal:** after creating a descriptor wallet in Bitcoin Core for automated e-commerce order processing, setup a backup Electrum wallet for the market owner with the ability to sign.

**Steps:**

1. Create a new descriptor wallet in Bitcoin Core.
2. `listdescriptors true` to extract `xprv`
3. ?? Convert `xprv` to `zprv` <== stuck here.
4. Import `zprv` into Electrum.

**Problem:** Stuck at creating `zprv` from `xprv`.

If I import `xprv` into Electrum as is, it will generate old addresses `1...`. Instead, my goal is to import a `zprv` so that it knows to generate bech32 addresses: `bc1...`.

From what I've read [here](https://bitcoin.stackexchange.com/a/106297/107366), it is impossible without having the HD seed.

However, in my case, the derivation path is the same in both Bitcoin Core and Electrum. hence **the question**: can I transform `xprv` into `zprv` without losing any information along, and for the sole goal being to let Electrum understand that bech32 addresses are to be generated?

Is this possible theoretically, and if so, any code snippets you can point to?

Alternatively, is there any other way to restore the wallet in Electrum in such a way that it generates the same bech32 addresses?

**Tags:** private-key-import, private-key-format


---

## 1 answers

### Answer by username_1 on 2023-03-30. Score: 1

Assuming that:

* you have the **root** Xprv and not the one at m/44'/0'/0' for example
* the derivation path is the same as you said

You can use [this](https://github.com/mcdallas/cryptotools) Python library (disclaimer: I am the author)

```python
from cryptotools import Xprv
from cryptotools.BTC.opcodes import ADDRESS

prv = Xprv.decode('xprv9s21ZrQH143K38bNJiHY54kkjio8o6aw3bRjCbzi8KgRxNy98avUribz1wk85ToSUV2VwVuc73NJWc2YGwpMtqz7bBFUh9Q77RtJeuh2zvy')
prv.type = ADDRESS('P2WPKH')
prv.encode()
'zprvAWgYBBk7JR8GjiybyRrnVEwm5f62gLZvspUAmPnUtLSC4abbduFc6qvG4MfJ5H7HHmG7ST6j2N5QHBFfiLePVKMKKreKry35et1bS1HZYDu'

```


---

