Sadly I will say bitcoin core wallet isn’t user friend like some of the SPV wallets interms of easily exporting or importing private keys from it. It is stated that since the wallet versions (from 24.0) which creates descriptor wallets by default, the wallet is Blocking you from exporting its generated private keys.
Here is a guide on how to go round it by nc50lc
Unfortunately,
dumprivkey or
dumpwallet commands aren't supported by descriptor wallets.
Your option is to export the parent descriptor of that address and then use a tool that can derive the private key of that address from its master private key.
Here's the procedure (
requires https://github.com/iancoleman/bip39):
- Start Bitcoin Core, preferably on an offline machine and enter the command getaddressinfo "bc1address" and take note of the address' "parent_desc" and "ischange" values.
- Next, enter the command listdescriptors true and find the (private) descriptor with the matching script type
of your address' parent descriptor. (your address' should be "wpkh")
But there'll be at least two desc with that script type, so based from your address' "ischange" value of 'true' or 'false', pick the descriptor with "internal" of the same value. - From the correct descriptor, copy it's master private key which is the long "xprv" key. Do not include the script type and '(' before and '/' after it.
- Now open your iancoleman's BIP39 tool in an offline machine and paste your xprv key in "BIP32 Root Key".
- Scroll down a bit and select the correct script type: BIP44 for legacy, BIP49 for Nested-SegWit and BIP84 for Native Segwit.
- The default should be already correct for receiving addresses (internal: false), else, change the internal/external path from '0' to '1'.
- Scroll-down to the derived addresses and it should be there along with its private key.
- If your address' "address_index" is more than 20, you should derive more addresses in BIP39 tool by using the button: "Show ___ more rows" below the address list for it to show.
Also you can use the below guide again by nc50lc to also import the private key
You still can import but with a different command: use
importdescriptors instead.
For a single WIF private key of a Native SegWit address, the command should look like this:
importdescriptors "[{\"desc\": \"wpkh(WIF_PRIV_KEY)#z0cazjry\", \"timestamp\": 0}]"
Use:
help importdescriptors to know how to use the command.
Here's how to construct descriptors:
https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.mdAnd to get the checksum (
#z0cazjry in the example), use:
getdescriptorinfo "descriptor"