<p>Load up electrum 3.1.1+ and enable the "console" and in the console do the following to output the addresses you need by providing your private key:</p>

<p><strong>bech32 format bc1...:</strong></p>

<blockquote>
  <p>bitcoin.address_from_private_key("p2wpkh:5Kkzs8XrJNAmf9......")</p>
</blockquote>

<p><strong>p2sh format 3...:</strong></p>

<blockquote>
  <p>bitcoin.address_from_private_key("p2wpkh-p2sh:5Kkzs8XrJNAmf9VQDFeG......")</p>
</blockquote>

<p>you just need to prefix your private key with p2wpkh or p2wpkh-p2sh to get one of them. </p>

CC BY-SA 3.0
2018-03-28T15:58:43.563Z
Keep in mind that this function requires the WIF encoding of the private key as an input.
Mike D
CC BY-SA 3.0
2018-03-28T16:27:38.787Z
how do you get the WIF encoding?
Patoshi パトシ
CC BY-SA 3.0
2018-03-28T16:39:59.123Z
I dont know about electrum but I have made a [python library](https://github.com/mcdallas/cryptotools) that can do what you want. PrivateKey.from_hex('yourkeyhere').to_public().to_address('P2WPKH')
Mike D
CC BY-SA 3.0
2018-03-29T16:15:55.110Z
see also here: https://bitcoin.stackexchange.com/questions/69315/how-are-compressed-pubkeys-generated/69366?noredirect=1#comment80625_69366
pebwindkraft
CC BY-SA 3.0
2018-03-28T14:25:12.547Z
2018-03-28T14:25:12.547Z
Patoshi パトシ
<p>I have a bitcoin private key and know that it can output a segwit addresses of bech32 bc1... and p2sh 3... formats. How can this be done easily?</p>

<address><segregated-witness><address-generation><bech32-address>
How do you output segwit bech32 (bc1...) / P2SH (3...) addresses from a bitcoin private key?
Patoshi パトシ
# How do you output segwit bech32 (bc1...) / P2SH (3...) addresses from a bitcoin private key?

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

I have a bitcoin private key and know that it can output a segwit addresses of bech32 bc1... and p2sh 3... formats. How can this be done easily?

**Tags:** address, segregated-witness, address-generation, bech32-address


---

## 1 answers

### Answer by username_0 on 2018-03-28. Score: 0 | Accepted answer

Load up electrum 3.1.1+ and enable the "console" and in the console do the following to output the addresses you need by providing your private key:

**bech32 format bc1...:**

> bitcoin.address\_from\_private\_key("p2wpkh:5Kkzs8XrJNAmf9......")

**p2sh format 3...:**

> bitcoin.address\_from\_private\_key("p2wpkh-p2sh:5Kkzs8XrJNAmf9VQDFeG......")

you just need to prefix your private key with p2wpkh or p2wpkh-p2sh to get one of them.

> **Comments:**
> **username_1**: Keep in mind that this function requires the WIF encoding of the private key as an input.  
> **username_0**: how do you get the WIF encoding?  
> **username_1**: I dont know about electrum but I have made a [python library](https://github.com/mcdallas/cryptotools) that can do what you want. PrivateKey.from_hex('yourkeyhere').to_public().to_address('P2WPKH')  
> **username_2**: see also here: https://bitcoin.stackexchange.com/questions/69315/how-are-compressed-pubkeys-generated/69366?noredirect=1#comment80625_69366  

---

