user123768: 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?

user48884: 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).

123768: <p>When I run <code>dumpprivkey</code> from Bitcoin Core 0.21.1. I get the following error message:</p>
<pre><code>error code: -4
error message:
This type of wallet does not support this command
</code></pre>
<p>I came across achow's explanation stating that</p>
<blockquote>
<p>&quot;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 <strong>private keys</strong> to generate
addresses.&quot;</p>
</blockquote>
<p>If <code>dumprivkey</code> does not work, how can I get a private key from a descriptor wallet?</p>
 48884: <p>It is currently not possible to export private keys from a descriptor wallet.</p>
<p>There is currently an open <a href="https://github.com/bitcoin/bitcoin/pull/21500" rel="noreferrer">pull request</a> which allows the <code>listdescriptors</code> command to optionally return descriptors with private keys. This will be the method by which private keys can be exported from a descriptor wallet.</p>
<p>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).</p>
