When trying to import a WIF private key into Bitcoin-QT i get this error:
Only legacy wallets are supported by this command (code -4)
How can one import a private key on a non-legacy wallet?
I don't know how to perform this on the GUI, but in order to import a WIF private key on a modern Bitcoin Core you have to use a descriptor. In order to recover from a backup, you most likely want to use the combo()
descriptor.
Here is an example with an example WIF private key: cSWVo8YMehg6STxqw6xGgmMJE6Ac6RCJ7owcrBZRAT7QANtyAAEj
(it's a testnet-encoded WIF private key on purpose, yours will be different). There is most likely a similar flow on the graphical interface, but failing that you can always use the command line (or the command input on the GUI).
First craft a combo descriptor from this private key and get its checksum:
getdescriptorinfo 'combo(cSWVo8YMehg6STxqw6xGgmMJE6Ac6RCJ7owcrBZRAT7QANtyAAEj)'
We get:
{
"descriptor": "combo(023ad6336ae257527ff59ec4356fa5d2ac33fff5e04be9e5958dfed9b0100b7948)#mv9rgx7y",
"checksum": "9zedq5ns",
"isrange": false,
"issolvable": true,
"hasprivatekeys": true
}
You can now import this descriptor using the importdescriptors
command:
importdescriptors '[{"desc":"combo(cSWVo8YMehg6STxqw6xGgmMJE6Ac6RCJ7owcrBZRAT7QANtyAAEj)#9zedq5ns","timestamp":"now"}]'
Finally rescan the blockchain from a point before which you are certain to not have received coins. To rescan the whole chain from the genesis block do not provide any parameter:
rescanblockchain
importprivkey only works on legacy wallets, so you need create a legacy wallet and then import the private key succ.