<p>Prepend "p2wpkh-p2sh:" to the private key before importing it into Electrum. For example:</p>

<p><code>p2wpkh-p2sh:5Kkzs8XrJNAmf9VQDFeGBfaRvSByAvPK6DbDXw5BVqswWaXSG2Y</code></p>

CC BY-SA 3.0
2018-03-25T07:24:51.983Z
I cannot confirm this - I tried it on my priv key and I get an error but, then again I have already imported it.
Willtech
CC BY-SA 3.0
2018-03-25T07:36:08.047Z
@Willtech it only works [with 3.1 and above](https://github.com/spesmilo/electrum/blob/master/RELEASE-NOTES#L72).
Abdussamad
CC BY-SA 3.0
2018-03-25T07:39:59.040Z
Just checked my version, it is indeed not 3.1 and above.
Willtech
CC BY-SA 4.0
2018-05-08T02:40:46.393Z
you made me cry, after 6 hours of searching and trying. I wish I could give you +100 upvotes. Thank you.
Ashkan
CC BY-SA 4.0
2022-11-24T06:06:12.167Z
This should be marked as the correct answer since it's simpler than the current accepted solution of using the console.
Kartik Shah
CC BY-SA 3.0
2018-03-25T06:16:36.180Z
2018-03-25T06:16:36.180Z
Abdussamad
<blockquote>
  <p>"I have previously imported the private key for a 1Archive... address into Bitcoin Core and noted then it added an address like 1AXbRq... and I didn't follow it up further."</p>
</blockquote>

<p>First of all, I won't be answering the first question. It just sounds weird, and 99% it's caused by a mistake.</p>

<blockquote>
  <p>How does this work? I understand that there is an underlying 1... address behind a SegWit address but how would I spend any BTC if it is not showing in my wallet balance? What else should I do?</p>
</blockquote>

<p>Here's how importing a P2PKH address works:</p>

<p>WIF result is affected by three parameters: Privkey type (a byte for BTC private keys), the private key (that also contains which <code>y</code> coordinate the pubkey has, if we want the compressed pubkey), and an extra <code>0x01</code> byte if we want the compressed pubkey. There's only one public key that can be generated using that WIF.</p>

<p>Here's how importing a P2SH address works:</p>

<p>1) Dump the WIF of the P2SH address</p>

<p>2) Import the WIF</p>

<p>3) Make a transaction, and watch how your wallet or Bitcoin Core doesn't recognize the transaction.</p>

<p>It won't recognize the transaction, because there's infinite number of P2SH addresses one can create using the WIF (Note: script has a size limit, so it's not infinite)!</p>

<p>To inform your wallet about your P2SH address, you should also import the script. And, this is not supported by 99.9% of the wallets. (However, the wallets can import Witness addresses, as they're standardized and widely used) That's why Electrum doesn't see your P2WPKH address, if you don't tell it to use the Witness address.</p>

CC BY-SA 3.0
2018-03-25T08:31:58.733Z
p2wpkh-p2sh scripts are standardized in the bip. As long as you prepend "p2wpkh-p2sh:" to the WIF Electrum will recognize it as such in Electrum 3.1 or newer. In the case of 3.0.x you have to convert the WIF which you can do using the script @RaghavSood posted or this menu based one [here](https://github.com/AbdussamadA/electrum-convert-key).
Abdussamad
CC BY-SA 3.0
2018-03-24T10:52:05.607Z
2018-03-25T08:35:58.370Z
2018-03-25T08:35:58.370Z
MCCCS
<p>I suspect you can import it directly from the console within Electrum (based on <a href="https://github.com/spesmilo/electrum/issues/3620" rel="nofollow noreferrer">this</a> PR). Currently, Electrum does now allow importing individual p2wpk inside p2sh addresses (the 3 segwit addresses). You can, however, still import an entire seed by using a BIP49 derivation path.</p>

<p>Try running the following in the electrum console:</p>

<pre><code>key = 'your_key'
txin_type, secret, compressed = bitcoin.deserialize_privkey(key)
wif2 = bitcoin.serialize_privkey(secret, compressed, 'p2wpkh-p2sh')
print(wif2)
</code></pre>

<p>Then import the wif2 which it prints out</p>

CC BY-SA 3.0
2018-03-24T11:21:07.643Z
That works. It imports the correct address.
Willtech
CC BY-SA 3.0
2018-03-24T11:23:04.143Z
Good to know! I wasn't super sure, and currently away from a machine with electrum on it. Thank you for confirming.
Raghav Sood
CC BY-SA 3.0
2018-03-25T06:17:12.690Z
Note since 3.1 you can just prepend "p2wpkh-p2sh:" to the private key before importing it.
Abdussamad
CC BY-SA 3.0
2018-03-24T10:36:24.690Z
2018-03-24T21:14:47.170Z
2018-03-24T21:14:47.170Z
Raghav Sood
<p>How does importing private keys work?</p>

<p>I have previously imported the private key for a 1Archive... address into Bitcoin Core and noted then it added an address like 1AXbRq...  and I didn't follow it up further.</p>

<p>Today I have exported the private key for a 3... address from Bitcoin Core and imported it in Electrum. Electrum adds a 1... address and doesn't see any of the transactions.</p>

<p>How does this work? I understand that there is an underlying 1... address behind a SegWit address but how would I spend any BTC if it is not showing in my wallet balance? What else should I do?</p>

<p>If there is an answered question for this already on Bitcoin.SE I could not find it.</p>

<p>My private key begins with L.</p>

CC BY-SA 3.0
2018-03-24T10:07:06.147Z
Was the address that started with `3` a P2WPKH address? If so, that might help: https://bitcoin.stackexchange.com/q/72899/38618
MCCCS
CC BY-SA 3.0
2018-03-24T10:25:41.760Z
@MCCCS Okay, that's actually close. I have a 3... address not a bc1... address. I have hope it is going to be easily solvable.
Willtech
CC BY-SA 3.0
2018-03-24T10:29:45.250Z
@MCCCS Actually, tried that method, Electrum says that the key cannot be imported. My priv key starts with L.
Willtech
CC BY-SA 3.0
2018-03-24T14:44:30.020Z
It's completly irrelevant that your private key start with "L". Don't share it!
hardfork
CC BY-SA 3.0
2018-03-29T13:02:39.493Z
ICIN, the official download for Electrum is from https://bitcoin.org/en/wallets/desktop/windows/electrum/
Willtech
<wallet><private-key><electrum><private-key-import><importaddress>
Importing private keys creates different address
Willtech
# Importing private keys creates different address

(Asked by: username_0 on 2018-03-24)

How does importing private keys work?

I have previously imported the private key for a 1Archive... address into Bitcoin Core and noted then it added an address like 1AXbRq... and I didn't follow it up further.

Today I have exported the private key for a 3... address from Bitcoin Core and imported it in Electrum. Electrum adds a 1... address and doesn't see any of the transactions.

How does this work? I understand that there is an underlying 1... address behind a SegWit address but how would I spend any BTC if it is not showing in my wallet balance? What else should I do?

If there is an answered question for this already on Bitcoin.SE I could not find it.

My private key begins with L.

**Tags:** wallet, private-key, electrum, private-key-import, importaddress

> **Comments:**
> **username_1**: Was the address that started with `3` a P2WPKH address? If so, that might help: https://bitcoin.stackexchange.com/q/72899/38618  
> **username_0**: @username_1 Okay, that's actually close. I have a 3... address not a bc1... address. I have hope it is going to be easily solvable.  
> **username_0**: @username_1 Actually, tried that method, Electrum says that the key cannot be imported. My priv key starts with L.  
> **username_2**: It's completly irrelevant that your private key start with "L". Don't share it!  
> **username_0**: ICIN, the official download for Electrum is from https://bitcoin.org/en/wallets/desktop/windows/electrum/  

---

## 3 answers

### Answer by username_6 on 2018-03-24. Score: 4 | Accepted answer

I suspect you can import it directly from the console within Electrum (based on [this](https://github.com/spesmilo/electrum/issues/3620) PR). Currently, Electrum does now allow importing individual p2wpk inside p2sh addresses (the 3 segwit addresses). You can, however, still import an entire seed by using a BIP49 derivation path.

Try running the following in the electrum console:

```
key = 'your_key'
txin_type, secret, compressed = bitcoin.deserialize_privkey(key)
wif2 = bitcoin.serialize_privkey(secret, compressed, 'p2wpkh-p2sh')
print(wif2)

```

Then import the wif2 which it prints out

> **Comments:**
> **username_0**: That works. It imports the correct address.  
> **username_6**: Good to know! I wasn't super sure, and currently away from a machine with electrum on it. Thank you for confirming.  
> **username_3**: Note since 3.1 you can just prepend "p2wpkh-p2sh:" to the private key before importing it.  

---

### Answer by username_3 on 2018-03-25. Score: 9

Prepend "p2wpkh-p2sh:" to the private key before importing it into Electrum. For example:

`p2wpkh-p2sh:5Kkzs8XrJNAmf9VQDFeGBfaRvSByAvPK6DbDXw5BVqswWaXSG2Y`

> **Comments:**
> **username_0**: I cannot confirm this - I tried it on my priv key and I get an error but, then again I have already imported it.  
> **username_3**: @username_0 it only works [with 3.1 and above](https://github.com/spesmilo/electrum/blob/master/RELEASE-NOTES#L72).  
> **username_0**: Just checked my version, it is indeed not 3.1 and above.  
> **username_4**: you made me cry, after 6 hours of searching and trying. I wish I could give you +100 upvotes. Thank you.  
> **username_5**: This should be marked as the correct answer since it's simpler than the current accepted solution of using the console.  

---

### Answer by username_1 on 2018-03-24. Score: -1

> "I have previously imported the private key for a 1Archive... address into Bitcoin Core and noted then it added an address like 1AXbRq... and I didn't follow it up further."

First of all, I won't be answering the first question. It just sounds weird, and 99% it's caused by a mistake.

> How does this work? I understand that there is an underlying 1... address behind a SegWit address but how would I spend any BTC if it is not showing in my wallet balance? What else should I do?

Here's how importing a P2PKH address works:

WIF result is affected by three parameters: Privkey type (a byte for BTC private keys), the private key (that also contains which `y` coordinate the pubkey has, if we want the compressed pubkey), and an extra `0x01` byte if we want the compressed pubkey. There's only one public key that can be generated using that WIF.

Here's how importing a P2SH address works:

1) Dump the WIF of the P2SH address

2) Import the WIF

3) Make a transaction, and watch how your wallet or Bitcoin Core doesn't recognize the transaction.

It won't recognize the transaction, because there's infinite number of P2SH addresses one can create using the WIF (Note: script has a size limit, so it's not infinite)!

To inform your wallet about your P2SH address, you should also import the script. And, this is not supported by 99.9% of the wallets. (However, the wallets can import Witness addresses, as they're standardized and widely used) That's why Electrum doesn't see your P2WPKH address, if you don't tell it to use the Witness address.

> **Comments:**
> **username_3**: p2wpkh-p2sh scripts are standardized in the bip. As long as you prepend "p2wpkh-p2sh:" to the WIF Electrum will recognize it as such in Electrum 3.1 or newer. In the case of 3.0.x you have to convert the WIF which you can do using the script @username_6 posted or this menu based one [here](https://github.com/AbdussamadA/electrum-convert-key).  

---

