2

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 Sood Mar 29 '18 at 14:03
  • Good plan! And, done. – Willtech Mar 29 '18 at 14:03
  • This Q/A is linked on Puzzling.SE. – Willtech Mar 29 '18 at 14:07
2

The entire process is as follows: (these instructions are correct for Electrum v3.0.6)

  1. Install Electrum. The installation methods vary but, the official download is here. On some varieties of Linux it is in the default distro repository.
  2. Run Electrum.
    1. Choose Automatically Connect and click on Next.
    2. Name your wallet if you like or accept the default and click on Next.
    3. Select Standard Wallet and click on Next.
    4. Select Create a new seed and click on Next.
    5. Select Segwit and click on Next.
    6. 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.
    7. Type your seed in the box and click on Next to verify you have it correctly.
    8. Set a good password that you will never forget. This must be secure to ensure your wallet cannot be stolen. Click on Next.
    9. Your wallet is setup.
  3. With Electrum setup and running, go to View -> Show console.
  4. Click on the Console tab.
  5. Using the instructions from here:
    1. Type (or copy and paste) at the >> prompt key = 'your_key' and press Enter (leave the single quotes in).
    2. Type (or copy and paste) at the >> prompt txin_type, secret, compressed = bitcoin.deserialize_privkey(key) and press Enter.
    3. Type (or copy and paste) at the >> prompt wif2 = bitcoin.serialize_privkey(secret, compressed, 'p2wpkh-p2sh') and press Enter.
    4. Type (or copy and paste) at the >> prompt print(wif2) and press Enter.
  6. 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.
  7. Click on Wallet -> Private Keys -> Sweep
  8. 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.
  9. 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).
  10. This will create a Bitcoin transaction transferring the balance to your own address.
  11. 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. – Abdussamad Mar 31 '18 at 19:32
  • @Abdussamad When Electrum gets the new version in the Fedora repository then I will get the new version. – Willtech Apr 1 '18 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. – Abdussamad Apr 2 '18 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.