0

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, 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?

1 Answer 1

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 Python library (disclaimer: I am the author)

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.