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?
How do you output segwit bech32 (bc1...) / P2SH (3...) addresses from a bitcoin private key?
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...:
p2sh format 3...:
you just need to prefix your private key with p2wpkh or p2wpkh-p2sh to get one of them.
Keep in mind that this function requires the WIF encoding of the private key as an input.– Mike DMar 28, 2018 at 15:58
how do you get the WIF encoding? Mar 28, 2018 at 16:27
I dont know about electrum but I have made a python library that can do what you want. PrivateKey.from_hex('yourkeyhere').to_public().to_address('P2WPKH')– Mike DMar 28, 2018 at 16:39
see also here: bitcoin.stackexchange.com/questions/69315/… Mar 29, 2018 at 16:15