Title: [GUIDE] Importing Electrum Segwit Private Key Into Bitcoin Core (And Vice Versa) Post by: Xynerise on April 24, 2018, 08:00:01 AM Usually, when you import a segwit private key from Bitcoin Core to Electrum, Electrum generates a legacy address (starting with '1') instead of a Segwit address (starting with '3' or 'bc1') because Bitcoin Core uses the WIF for all address types (https://github.com/bitcoin/bitcoin/pull/11403#issuecomment-353301840) while Electrum has a custom WIF (https://github.com/spesmilo/electrum/issues/3694#issuecomment-356785965) for different types of addresses so each WIF corresponds to 1 bitcoin address.
Also, because of this, you're also unable to import a segwit WIF from Electrum into Bitcoin Core because Core doesn't understand the custom WIF. However, Electrum internally maintains backwards compatibility (https://github.com/spesmilo/electrum/pull/3925) so you can convert an Electrum custom WIF to one Core understands. How To Convert An Electrum segwit WIF to standard WIF For P2SH-P2WPKH addresses: Open the console in Electrum and type the following code . (Press enter after each line) Code: key = 'L4wAtJ8RYaxtRYZxUwZRH8qGYVv1LUP3RAh9ER9KK2HeTXW6v4Ru' It should print a WIF that you can import into Bitcoin Core. For P2WPKH addresses (Bech32) Type the following code, replacing the private key there with yours. Code: key = 'LAst2SKVNx36PUY2q49cyLCcpze1YMvdJ66z3uKuiyaLKTVVsH3J' How To Import Segwit WIF from Bitcoin Core to Electrum This one is simple to do. NB: For this to work you need to be on Electrum version 3.1.1 and above 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 For P2WPKH addresses (Bech32, starting with 'bc1') This time we'll add p2wpkh: in front of the private key. For example Code: p2wpkh:5PrivateKey Title: Re: [GUIDE] Importing Electrum Segwit Private Key Into Bitcoin Core (And Vice Versa) Post by: Abdussamad on April 24, 2018, 12:46:50 PM If you use Electrum 3.1 or newer to view your private keys it'll display them in "script_type:priv_key_in_standard_wif" so there is nothing to convert. Just remove the colon and whatever comes before it.
|