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?
1 Answer
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.
-
Thanks, will try. And the result of this is the 1.. legacy address? How do I get the private key for it?– JohnDoeNov 27, 2017 at 9:34
-
The private key is the same private key for your segwit address.– Andrew Chow ♦Nov 27, 2017 at 15:34
-
can i generate the legacy address back from the segwit address? example : getlegacyaddress <segwit-addr> Dec 27, 2017 at 8:41
-
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. Dec 27, 2017 at 8:45