Post
Topic
Board Bitcoin Technical Support
Re: Bitcoin Core generates wrong private key?
by
LoyceV
on 16/02/2021, 17:02:00 UTC
Alternatively it's possible that in Electrum you pasted the private key without putting p2wpkh: in front of it. If you don't do that then you might generate an address starting with a "1" or "3" instead of native segwit's bc1.
Correct. Full version:
For P2SH-P2WPKH addresses (Addresses starting with "3")
Just add p2wpkh-p2sh: directly in front of your  private key.
For example
Code:
p2wpkh-p2sh:5BitcoinPrivateKey
This should generate the corresponding p2wpkh-p2sh bitcoin address.

For P2WPKH addresses (Bech32, starting with 'bc1')
This time we'll add p2wpkh: in front of the private key.
For example
Code:
p2wpkh:5PrivateKey
This should generate the corresponding Bech32 address

It's about time Electrum checks all possible address formats on it's own. I can never remember what to type.