Use
restore instead of
create.
Example:
electrum --testnet -w test_wallet1 restore "p2wpkh:cToWRvSSzMJn87KJc7y66c9YfLuPWQf8uBrYvj5pdsa8h1v5NL6Q p2wpkh-p2sh:cMiHrQ32jiRmTzMKXi6NT9RR2m6SUgNzC36ghTf1Z2JAbhBJncji"
Enter the wallet name after the "
-w" argument, and the private key(s) (
with script type) after "
restore".
(the whitespace in between is important, apparently, and can't just be any separator)
I noticed that when I used the
restore command, the wallet doesn't automatically get synced, yet the call returns instantly.
Among other things, this causes the balance to be reported as zero for an indefinite amount of time, because the network part of the wallet is never started (there's a reason why the return JSON says: "This wallet has been restored
offline").
I made a new command
restore_sync that fixes this (apparently it was a TODO in the code as well) and some other commands I found convenient to make. I will make a PR for those shortly.
EDIT: The request has been made:
https://github.com/spesmilo/electrum/pull/7584 and I want to merge a few other commands I added (among others, I also have a
delete command that deletes wallet files but I don't think that this will make it - it does not tell the difference between wallet files and other random files).