How to sweep a segwit bech32 private key?

1

I'm testing segwit bech32 addresses and generated the following using bitcoinjs:

address: bc1qc7u5njf4nf2rj3zys642mfc7nct6kdven8j4e9

private key: 5Kkzs8XrJNAmf9VQDFeGBfaRvSByAvPK6DbDXw5BVqswWaXSG2Y

When I import this private key into electrum 3.0.5, it imports it as the following address: 1KD3SE71kGAcxw57BvcmUzsHwx3QxdPBW7

How do I go about sweeping funds from the bc1... address if electrum 3.0.5 sees the legacy format address instead?

Patoshi パトシ

Posted 2018-03-23T21:12:57.730

Reputation: 8 911

Answers

4

Use Electrum 3.1.1 and prepend "p2wpkh:" to the private key before importing or sweeping it. For example:

p2wpkh:5Kkzs8XrJNAmf9VQDFeGBfaRvSByAvPK6DbDXw5BVqswWaXSG2Y

enter image description here

Abdussamad

Posted 2018-03-23T21:12:57.730

Reputation: 1 850

how do you output the segwit address just to make sure it matches that private key?Patoshi パトシ 2018-03-24T04:23:28.013

1bitcoin.address_from_private_key("p2wpkh:5Kkzs8XrJNAmf9VQDFeGBfaRvSByAvPK6DbDXw5BVqswWaXSG2Y") in the console tab of electrum (view menu> show console if you can't see that tab)Abdussamad 2018-03-24T04:28:58.410

thanks! I'm curious to how did you even figure this out to put "p2wpkh:" in front of the address?Patoshi パトシ 2018-03-26T16:19:59.400

@Patoshiパトシ It's in the release notes for 3.1: https://github.com/spesmilo/electrum/blob/master/RELEASE-NOTES#L72

Abdussamad 2018-03-27T14:38:56.370

thanks. I'm trying to output the 3xxx address and tried p2sh:5Kkzs8XrJNAmf9VQDFe.... that doesnt work. what is the prefix for that?Patoshi パトシ 2018-03-27T18:32:22.047

use "p2wpkh-p2sh:"Abdussamad 2018-03-28T08:22:45.743