I need to import a private key like in this question for a p2wpkh-p2sh address. What is the entire process?
-
Maybe add electrum to the question title - Google might show this for generic import queries otherwise, and the import process will likely differ for different clients– Raghav SoodCommented Mar 29, 2018 at 14:03
-
Good plan! And, done.– WilltechCommented Mar 29, 2018 at 14:03
-
This Q/A is linked on Puzzling.SE.– WilltechCommented Mar 29, 2018 at 14:07
Add a comment
|
1 Answer
The entire process is as follows: (these instructions are correct for Electrum v3.0.6)
- Install Electrum. The installation methods vary but, the official download is here. On some varieties of Linux it is in the default distro repository.
- Run Electrum.
- Choose Automatically Connect and click on Next.
- Name your wallet if you like or accept the default and click on Next.
- Select Standard Wallet and click on Next.
- Select Create a new seed and click on Next.
- Select Segwit and click on Next.
- Securely, privately and accurately store your seed. This is your wallet backup. If it is lost all your BTC is gone permanently. Click on Next.
- Type your seed in the box and click on Next to verify you have it correctly.
- Set a good password that you will never forget. This must be secure to ensure your wallet cannot be stolen. Click on Next.
- Your wallet is setup.
- With Electrum setup and running, go to View -> Show console.
- Click on the Console tab.
- Using the instructions from here:
- Type (or copy and paste) at the >> prompt
key = 'your_key'
and press Enter (leave the single quotes in). - Type (or copy and paste) at the >> prompt
txin_type, secret, compressed = bitcoin.deserialize_privkey(key)
and press Enter. - Type (or copy and paste) at the >> prompt
wif2 = bitcoin.serialize_privkey(secret, compressed, 'p2wpkh-p2sh')
and press Enter. - Type (or copy and paste) at the >> prompt
print(wif2)
and press Enter.
- Type (or copy and paste) at the >> prompt
- Highlight and copy the one-line string that is output (make sure you do not get any extra spaces) in your clipboard or, write it down.
- Click on Wallet -> Private Keys -> Sweep
- Paste the string you copied into the big box. The address that is pre-filled in starting (as of writing) with bc1 is one of your many receiving addresses. The balance will be transferred to that address.
- Click on Sweep and follow the prompts (I didn't proceed to actually do this step - when I originally tested I used completely different steps to 'Import, not Sweep' just to prove it worked and not take the balance).
- This will create a Bitcoin transaction transferring the balance to your own address.
- Wait for at least 1 confirmations.
Done!
If you just want to import the address to make sure it is correct without trying to sweep you need different steps.
-
That's sweeping rather than importing and as far as the private key format goes just prepend "p2wpkh-p2sh:" to the WIF and you're good to go in 3.1 or newer. You shouldn't be using old versions like 3.0.6. Commented Mar 31, 2018 at 19:32
-
@Abdussamad When Electrum gets the new version in the Fedora repository then I will get the new version.– WilltechCommented Apr 1, 2018 at 0:31
-
in the case of Electrum you should be installing from source. That's because it updates far too frequently for distro repos to keep up. Commented Apr 2, 2018 at 13:24