15

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?

2
  • It's intended not to be easy for users to create P2WPKH addresses until it's live on the network.
    – m1xolyd1an
    Commented Aug 9, 2017 at 14:34
  • It doesn't seem to be complicated as per the response below.
    – Paul
    Commented Aug 9, 2017 at 18:48

1 Answer 1

14

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.

16
  • 2
    That 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
    Commented Aug 9, 2017 at 18:46
  • 2
    Yes to all of those. Commented Aug 9, 2017 at 18:55
  • 2
    in case anyone is interested: the legacy address used to create the SegWit address and the resulting witness address share the same private key.
    – venzen
    Commented Oct 25, 2017 at 7:06
  • 1
    Is there perhaps any benefit in using a P2SH address instead of a P2PKH address?
    – venzen
    Commented 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.