15
5
How do I generate a SegWit address using Bitcoin Core CLI? Also will I be able to redeem those outputs and send them to a "legacy" address? If so, will this second transaction be accepted by older, non-SegWit clients?
15
5
How do I generate a SegWit address using Bitcoin Core CLI? Also will I be able to redeem those outputs and send them to a "legacy" address? If so, will this second transaction be accepted by older, non-SegWit clients?
15
How do I generate a SegWit address using Bitcoin Core CLI?
You can use addwitnessaddress addr, where addr is an existing P2PKH or P2SH address of yours. It will construct a P2SH-P2WPKH or P2SH-P2WSH address with the same key/script, if known to be valid.
Note that this command is not available until SegWit is active on the network, as before that time, such outputs would be spendable by everyone.
Since Bitcoin Core v0.16.0, P2SH-P2WPKH addresses are the default, and the addwitnessaddress RPC is deprecated.
Also will I be able to redeem those outputs and send them to a "legacy" address?
Yes.
If so, will this second transaction be accepted by older, non-SegWit clients?
Yes, it is a softfork. Every new transaction is valid according to the old rule. If not, a chain split would occur. Older clients may not see the transaction until it is confirmed, however.
2That means I need to generate a "legacy" address and then pass it to addwitnessaddress and it will return a "segwit" address? And I will be able to send the bitcoins received in that "segwit" address to any other address and older clients will not complain (they will "receive" those bitcoins)? – Paul – 2017-08-09T18:46:53.960
2Yes to all of those. – Pieter Wuille – 2017-08-09T18:55:20.593
2in case anyone is interested: the legacy address used to create the SegWit address and the resulting witness address share the same private key. – venzen – 2017-10-25T07:06:50.967
1Is there perhaps any benefit in using a P2SH address instead of a P2PKH address? – venzen – 2017-10-25T07:11:01.447
Why do you need to do this stupid addwitness to a different address? It does not make any sense. – Giovanni Di Stasi – 2017-12-11T15:59:21.213
It mimicks addmultisigaddress, and teaches the wallet to look for a particular address and how to spend. The initial SegWit implementation only had a rudimentary wallet support sufficient for testing, but we didn't want to do all implementation work if SegWit wouldn't have activated. It has now, so the next Bitcoin Core release will make SegWit addresses default (removing the need for an RPC call, and have better backup recovery). – Pieter Wuille – 2017-12-11T17:52:37.850
@venzen You'd give a P2SH address if you wanted a SegWit address for a multisig spending condition, as those can't be expressed using P2PKH. – Pieter Wuille – 2017-12-11T17:55:43.317
i tried these instructions.
i have not downloaded the full blockchain.
I get this error - Segregated witness not enabled on network (code -4) – Karan Ahuja – 2017-12-26T09:53:25.560
i think - https://github.com/bitcoin/bitcoin/pull/11400
solves above mention error i got.
How does one generate the legacy address back from its corresponding segwit address ? is there a command as below : getlegacyaddress <segwit addr> – Karan Ahuja – 2017-12-27T08:36:03.783
@Karan That sounds like it could be a separate question. – Pieter Wuille – 2017-12-27T08:37:31.007
sure @PieterWuille.
I added a comment here - https://bitcoin.stackexchange.com/questions/63472/how-to-get-legacy-address-and-private-key-from-segwit-p2sh-address
"addwitnessaddress is deprecated and will be fully removed in v0.17. To use addwitnessaddress in v0.16, restart bitcoind with -deprecatedrpc=addwitnessaddress. Projects should transition to using the address_type argument of getnewaddress, or option -addresstype=[bech32|p2sh-segwit] instead. (code -32)" from bitcoin core 0.16 – Haddar Macdasi – 2018-04-03T18:12:49.937
Can I still generate "legacy" address with core 0.16 ? – Haddar Macdasi – 2018-04-03T18:19:09.140
Yes, run with -addresstype=legacy. – Pieter Wuille – 2018-04-03T18:22:10.183
I've opened a new Q concerning V0.16 legacy support
https://bitcoin.stackexchange.com/questions/73411/how-to-add-support-for-segwit-address-and-legacy-with-bitcoin-core-0-16
It's intended not to be easy for users to create P2WPKH addresses until it's live on the network. – m1xolyd1an – 2017-08-09T14:34:04.990
It doesn't seem to be complicated as per the response below. – Paul – 2017-08-09T18:48:10.033