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?JohnDoe– JohnDoe2017-11-27 09:34:10 +00:00Commented Nov 27, 2017 at 9:34
- The private key is the same private key for your segwit address.2017-11-27 15:34:10 +00:00Commented Nov 27, 2017 at 15:34
- can i generate the legacy address back from the segwit address? example : getlegacyaddress <segwit-addr>mrtechmaker– mrtechmaker2017-12-27 08:41:39 +00:00Commented 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.Pieter Wuille– Pieter Wuille2017-12-27 08:45:22 +00:00Commented Dec 27, 2017 at 8:45