Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: SamuelDL on July 26, 2021, 10:59:42 AM



Title: I can't get my private key
Post by: SamuelDL on July 26, 2021, 10:59:42 AM
Hello, on Bitcoin core 0.21.1, when I write the commands on the console to see my private key, I am told that the type of my wallet does not support this command. It is an encrypted wallet with passphrase. Can someone tell me how to get my private key ? Thank you.


Title: Re: I can't get my private key
Post by: OmegaStarScream on July 26, 2021, 11:07:34 AM
Do you mind posting the commands you've used? Is it a standard wallet? If so, all you should be using is the walletpassphrase command to unlock the wallet, then dumpprivkey afterward.


Title: Re: I can't get my private key
Post by: SamuelDL on July 26, 2021, 11:27:17 AM
Do you mind posting the commands you've used? Is it a standard wallet? If so, all you should be using is the walletpassphrase command to unlock the wallet, then dumpprivkey afterward.
I have already written these commands and I am told that my wallet does not support this kind of commands. When I created it, I just encrypted it, wrote a passphrase and that's it. Nothing more


Title: Re: I can't get my private key
Post by: SamuelDL on July 26, 2021, 11:52:25 AM
I am told that the type of my wallet does not support this command.

Can you try it again and show us the exact error/warning message?

then dumpprivkey afterward.

Or use dumpwallet if you plan to get private key from many address.
I just did a test and when I deselect DescriptorWallet it shows me my private key but not when I select DescriptorWallet and even when I write '' dumpwallet '' it gives me the same error message: ''This type of wallet does not support this command (code -4)''




Title: Re: I can't get my private key
Post by: ABCbits on July 26, 2021, 12:10:07 PM
I tried creating to reproduce the problem (by enable "descriptor wallet" and "encrypt wallet" when creating new wallet) and managed to reproduce the problem. It happens because Bitcoin Core doesn't support such command for descriptor wallet according to https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md (https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md).


Title: Re: I can't get my private key
Post by: SamuelDL on July 26, 2021, 12:28:58 PM
I tried creating to reproduce the problem (by enable "descriptor wallet" and "encrypt wallet" when creating new wallet) and managed to reproduce the problem. It happens because Bitcoin Core doesn't support such command for descriptor wallet according to https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md (https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md).
Is it better that I change the type of wallet to know my private key or I stay with this one ?


Title: Re: I can't get my private key
Post by: SamuelDL on July 27, 2021, 08:48:42 AM
Thank you very much.


Title: Re: I can't get my private key
Post by: Easteregg69 on July 27, 2021, 01:02:44 PM
Thank you very much.

How about putting the wallet.dat in core wallet and try? Latest version.


Title: Re: I can't get my private key
Post by: HCP on August 04, 2021, 01:21:47 AM
If you read the release notes for 0.21.0, you'll see the descriptor wallets are regarded as "experimental" and should not be the "default" wallet type created: https://bitcoincore.org/en/releases/0.21.0/

Additionally, the import and export functionality for these types of wallets is different:
As Legacy Wallets and Descriptor Wallets use different mechanisms for storing and importing scripts and keys the existing import RPCs have been disabled for descriptor wallets. New export RPCs for Descriptor Wallets have not yet been added.

The following RPCs are disabled for Descriptor Wallets:

- importprivkey
- importpubkey
- importaddress
- importwallet
- dumpprivkey
- dumpwallet
- importmulti
- addmultisigaddress
- sethdseed
So, as you can see... there are no "Export" functions for descriptor wallets as yet. So you will not be able to export anything at this time.

Note that v0.21.1 is just the update to support Taproot... so the 0.21.0 info regarding descriptor wallets should still hold true.


Essentially, unless you explicitly need descriptor support (and you can only use it for importing at this time), I would suggest that you continue to use the "legacy" wallet option by making sure that the "descriptor wallet" option is not used during wallet creation.


Title: Re: I can't get my private key
Post by: SamuelDL on August 05, 2021, 08:30:08 PM
Ok, Thank you.


Title: Re: I can't get my private key
Post by: nc50lc on April 30, 2022, 04:31:38 AM
Bumping this quite old thread to include a solution involving today's latest Bitcoin Core version (v23.0).

It's now possible to export the parent descriptor with xprv key by using the command: listdescriptors true.
You can get your address' prvKey with the help of Iancoleman's BIP39 tool (https://github.com/iancoleman/bip39) (or any alternative).

Steps:
  • First use the command: getaddressinfo <address> and take note of the result.
  • Export the parent descriptor (private) with the command: listdescriptors true.
  • Select the correct parent descriptor based from the address' script type (pkh, wpkh, sh),
    also check if it's a descriptor for receiving or change addresses ("internal": false = receiving | true = change); then take note of its xprv key.
  • Launch BIP39 tool (offline) and paste the xprv key as "BIP32 Root Key".
  • Select the correct derivation path as described in the descriptor, the derived addresses and private keys will be listed below the page.

If the address is not in the list:
In getaddressinfo's result, look for "hdkeypath":" to see the index (last digit), since the tool will only show 20 by default; generate more rows if it's 20+.
Also check if the path is correct.

For Taproot descriptors, the suggested tool doesn't support it yet.