6

When I run dumpprivkey from Bitcoin Core 0.21.1. I get the following error message:

error code: -4
error message:
This type of wallet does not support this command

I came across achow's explanation stating that

"Descriptor Wallets store Output Script Descriptors in the wallet and use these to generate the addresses that users can use. Legacy Wallets (the non-descriptor wallet type, and the only type of wallet previous versions would create) instead used private keys to generate addresses."

If dumprivkey does not work, how can I get a private key from a descriptor wallet?

Murch
  • 71,155
  • 33
  • 180
  • 600

1 Answers1

7

It is currently not possible to export private keys from a descriptor wallet.

There is currently an open pull request which allows the listdescriptors command to optionally return descriptors with private keys. This will be the method by which private keys can be exported from a descriptor wallet.

Note that only the master private key used in a descriptor will be allowed to be exported from descriptor wallets. This is because descriptor wallets will be using unhardened derivation for the child keys and there is a known issue where having the parent xpub and a child key derived with unhardened derivation will allow the parent xprv to be computed. So to be clear to users that what they are doing is potentially unsafe, we will only allow exporting the master private key (it is more obviously unsafe when you have the master private key as users are unlikely to know about this weakness and may think that giving out child keys and the parent xpub is safe).

Andrew Chow
  • 67,209
  • 5
  • 76
  • 149
  • Is my understanding correct that the output of `listdescriptors` with the parent master private key is enough to recover the entire wallet using `importdescriptor`? – Martin Braun Dec 19 '22 at 22:35
  • 1
    @MartinBraun Yes. The output of `listdescriptors true` is sufficient to recover your wallet. – Andrew Chow Dec 20 '22 at 05:15
  • This is too paternalistic. A user advanced enough to be able to extract the private key should know better what to do with it. This stuff just makes it harder to work with Bitcoin Core's wallet and forces us developers to go and look for third-party resources instead. – Bilthon Jun 23 '23 at 22:49