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?
1 Answer
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)?– PaulCommented Aug 9, 2017 at 18:46
-
2
-
2in case anyone is interested: the legacy address used to create the SegWit address and the resulting witness address share the same private key.– venzenCommented Oct 25, 2017 at 7:06
-
1Is there perhaps any benefit in using a P2SH address instead of a P2PKH address?– venzenCommented Oct 25, 2017 at 7:11
-
Why do you need to do this stupid addwitness to a different address? It does not make any sense. Commented Dec 11, 2017 at 15:59