<p>I believe you're confusing legacy <em>addresses</em> with legacy <em>wallets</em>. They're distinct and unrelated things.</p>
<ul>
<li>Legacy <em>addresses</em> are pre-segwit addresses (P2PKH most commonly), and are contrasted with segwit and taproot addresses.</li>
<li>Legacy wallets are wallet files in the BDB file format, created by old versions of Bitcoin Core (and can still be opened by new versions, for now). They're contrasted with descriptor wallets, which use the SQLite file format, which are created by newer versions of Bitcoin Core.</li>
</ul>
<p>You can create legacy addresses using descriptor wallets, and you can create segwit (but not taproot) addresses using legacy wallets.</p>
<p>What I suspect is going on here is that you're trying to perform the <code>dumpprivkey</code> on a legacy address in a descriptor wallet. And that doesn't work, because <code>dumpprivkey</code> only works on legacy wallets (regardless of address type). Exporting private key is dangerous, and especially so for descriptor wallets (where an attacker can typically compute <em>all</em> your private keys from just one). If you must, you can export the private master key using <code>listdescriptors</code>, though I suspect this will not be what you want.</p>
<p>To help you find an alternative, I encourage you to amend your answer to explain exactly what you're trying to achieve (or point out if my interpretation of events is incorrect). Perhaps a solution exists that doesn't involve exporting private keys, as that is generally a bad idea unless you really know what you are doing.</p>

CC BY-SA 4.0
2023-11-12T19:11:53.303Z
2023-11-12T19:45:23.900Z
2023-11-12T19:45:23.900Z
Pieter Wuille
<p>I've had the same problem.
Solution for that was ... that I've imported again my old wallet from backup. That was before I've converted it to legacy wallet.
After that it was simple to get private key. I've wnet to console and run:</p>
<ul>
<li>walletpassphrase &quot;myPassword&quot; 600</li>
<li>dumpprivkey 18wX2UUqNn3W6MLq2urHNMjvEXaZr3hYoL</li>
</ul>
<p>After that i've gotten private key without any problem.</p>
<p>When I've done it on the wallet that has been already migrated - then I've gotten error:</p>
<ul>
<li>Only legacy wallets are supported by this command (code -4)</li>
</ul>
<p>Regards,
Konki</p>

CC BY-SA 4.0
2024-11-14T10:05:40.167Z
2024-11-14T10:05:40.167Z
Konki
<p>I can't create the private key of a legacy address on bitcoin core. When I do the command it writes me that it can only be done to legacy addresses. And my address is legacy. What should I do. Thank you</p>

CC BY-SA 4.0
2023-11-29T16:38:27.983Z
Hello Carmen, what are you trying to do that you need to export a private key for? Perhaps if you ask about your original problem instead of your solution attempt for that problem, we could help you better.
Murch
CC BY-SA 4.0
2024-03-09T05:53:05.097Z
why is the private key, which allows you to have full control over moving your wallet/addresses between bitcoin clients so elusive to obtain? @Murch
Jon Grah
CC BY-SA 4.0
2024-03-09T13:10:18.923Z
Because Bitcoin Core moved to a more comprehensive export format, _ouput script descriptors_ a few years ago.
Murch
<bitcoin-core><private-key-export>
Private key on Bitcoin Core
Carmen Duda
# Private key on Bitcoin Core

(Asked by: username_0 on 2023-11-12)

I can't create the private key of a legacy address on bitcoin core. When I do the command it writes me that it can only be done to legacy addresses. And my address is legacy. What should I do. Thank you

**Tags:** bitcoin-core, private-key-export

> **Comments:**
> **username_1**: Hello username_0, what are you trying to do that you need to export a private key for? Perhaps if you ask about your original problem instead of your solution attempt for that problem, we could help you better.  
> **username_2**: why is the private key, which allows you to have full control over moving your wallet/addresses between bitcoin clients so elusive to obtain? @username_1  
> **username_1**: Because Bitcoin Core moved to a more comprehensive export format, _ouput script descriptors_ a few years ago.  

---

## 2 answers

### Answer by username_3 on 2023-11-12. Score: 3

I believe you're confusing legacy *addresses* with legacy *wallets*. They're distinct and unrelated things.

* Legacy *addresses* are pre-segwit addresses (P2PKH most commonly), and are contrasted with segwit and taproot addresses.
* Legacy wallets are wallet files in the BDB file format, created by old versions of Bitcoin Core (and can still be opened by new versions, for now). They're contrasted with descriptor wallets, which use the SQLite file format, which are created by newer versions of Bitcoin Core.

You can create legacy addresses using descriptor wallets, and you can create segwit (but not taproot) addresses using legacy wallets.

What I suspect is going on here is that you're trying to perform the `dumpprivkey` on a legacy address in a descriptor wallet. And that doesn't work, because `dumpprivkey` only works on legacy wallets (regardless of address type). Exporting private key is dangerous, and especially so for descriptor wallets (where an attacker can typically compute *all* your private keys from just one). If you must, you can export the private master key using `listdescriptors`, though I suspect this will not be what you want.

To help you find an alternative, I encourage you to amend your answer to explain exactly what you're trying to achieve (or point out if my interpretation of events is incorrect). Perhaps a solution exists that doesn't involve exporting private keys, as that is generally a bad idea unless you really know what you are doing.


---

### Answer by username_4 on 2024-11-14. Score: 0

I've had the same problem.
Solution for that was ... that I've imported again my old wallet from backup. That was before I've converted it to legacy wallet.
After that it was simple to get private key. I've wnet to console and run:

* walletpassphrase "myPassword" 600
* dumpprivkey 18wX2UUqNn3W6MLq2urHNMjvEXaZr3hYoL

After that i've gotten private key without any problem.

When I've done it on the wallet that has been already migrated - then I've gotten error:

* Only legacy wallets are supported by this command (code -4)

Regards,
username_4


---

