How to get legacy address and private key from Segwit P2SH address?

0

1

I have a Segwit P2SH address (starting with 3...) with the corresponding private key and need to obtain the legacy address (starting with 1...) and the private key. Is this possible?

JohnDoe

Posted 2017-11-26T16:22:25.867

Reputation: 3

Answers

1

You have the private key so you can just derive the address from there. Get the corresponding public key, hash it with SHA256 and then that result with RIPEMD160. Then perform Base58Check Encoding on it.

Andrew Chow

Posted 2017-11-26T16:22:25.867

Reputation: 40 910

Thanks, will try. And the result of this is the 1.. legacy address? How do I get the private key for it?JohnDoe 2017-11-27T09:34:10.043

The private key is the same private key for your segwit address.Andrew Chow 2017-11-27T15:34:10.673

can i generate the legacy address back from the segwit address? example : getlegacyaddress <segwit-addr>Karan Ahuja 2017-12-27T08:41:39.380

1@KaranAhuja If you need a legacy address, you should create a new legacy address rather than converting an existing one. The 'addwitnessaddress' approach was intended for testing only; over time, Bitcoin Core won't allow you to convert one address type into another anymore.Pieter Wuille 2017-12-27T08:45:22.687