Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: amaclin on November 20, 2016, 07:44:04 PM



Title: SegWit change addresses?
Post by: amaclin on November 20, 2016, 07:44:04 PM
Should the client use segwit-addresses for change addresses?
If yes - it will be confusing users.
If no - the benefits of segwit are smaller than expected


Title: Re: SegWit change addresses?
Post by: achow101 on November 20, 2016, 08:53:54 PM
Should the client use segwit-addresses for change addresses?
Yes

If yes - it will be confusing users.
How so? It should be giving segwit addresses for all addresses regardless.


Title: Re: SegWit change addresses?
Post by: johoe on November 24, 2016, 04:38:18 PM
I think the idea so far is to add a segwit account to segwit enabled wallets.  The segwit account then has segwit addresses (p2sh at first).  The user is free to choose between his segwit account and non-segwit account and whether he wants to transfer his funds to the segwit account.  When he uses the segwit account, he uses segwit change addresses.  So every user can decide for himself if/when he wants to update to segwit (of course, only after it gets activated).

It would be possible to use a mixed account with both segwit and non-segwit addresses and maybe even native p2wpkh addresses for change.  But this may be confusing to users, cause inconsistent balances between different wallets (e.g. when sharing xpubs), and make it easier to spot the change output.


Title: Re: SegWit change addresses?
Post by: gmaxwell on November 26, 2016, 10:15:39 PM
I think the idea so far is to add a segwit account to segwit enabled wallets.  The segwit account then has segwit addresses (p2sh at first).  The user is free to choose between his segwit account and non-segwit account and whether he wants to transfer his funds to the segwit account.  When he uses the segwit account, he uses segwit change addresses.  So every user can decide for himself if/when he wants to update to segwit (of course, only after it gets activated).

That sounds like foolish wallet construction, IMO.  Don't do that.  A wallet should use segwit (in which case all newly generated addresses should be segwit) or it shouldn't (in which case none of it is).

As far as bare P2WPKH outputs, indeed-- those could be used for change, but they're more identifiable which is pretty ugly.


Title: Re: SegWit change addresses?
Post by: ScripterRon on November 29, 2016, 03:48:38 PM
For my own wallet, I've taken the approach of providing both P2PKH ('1') and P2SH-P2WPKH ('3') addresses for each private key.  The user can select either address when providing a receive address to an external site. 

When sending coins, the transaction type is determined by the outputs being spent.  A witness transaction will be created if any output is a witness output.  Otherwise, a legacy transaction is created.  The change address is then selected based on the transaction type.

This should provide interoperability with both new and old wallets.  Even if segwit is activated, that doesn't mean a particular web site will accept witness transactions.  So wallets will need to support both for some time.


Title: Re: SegWit change addresses?
Post by: trout on December 01, 2016, 01:28:38 PM
Even if segwit is activated, that doesn't mean a particular web site will accept witness transactions.  So wallets will need to support both for some time.

AFAIU,   non-segwit-supporting wallets will still recognize transactions with segwit inputs. So no need keep creating P2PKH addresses in order to be able to pay to non-segwit wallets


Title: Re: SegWit change addresses?
Post by: dbstmddhks on December 01, 2016, 02:53:58 PM
It is soft-forking.

I don't think this makes an address change.


From wan.


Title: Re: SegWit change addresses?
Post by: ScripterRon on December 01, 2016, 03:52:12 PM
Even if segwit is activated, that doesn't mean a particular web site will accept witness transactions.  So wallets will need to support both for some time.

AFAIU,   non-segwit-supporting wallets will still recognize transactions with segwit inputs. So no need keep creating P2PKH addresses in order to be able to pay to non-segwit wallets
I need to generate P2PKH addresses for non-segwit wallets sending coins to me (the generated addresses are for my private keys).  You are correct that non-segwit wallets should handle witness transactions since they will receive them in legacy format.


Title: Re: SegWit change addresses?
Post by: amaclin on December 01, 2016, 03:55:56 PM
You are correct that non-segwit wallets should handle witness transactions since they will receive them in legacy format.
only when confirmed.


Title: Re: SegWit change addresses?
Post by: achow101 on December 01, 2016, 04:19:04 PM
Even if segwit is activated, that doesn't mean a particular web site will accept witness transactions.  So wallets will need to support both for some time.

AFAIU,   non-segwit-supporting wallets will still recognize transactions with segwit inputs. So no need keep creating P2PKH addresses in order to be able to pay to non-segwit wallets
I need to generate P2PKH addresses for non-segwit wallets sending coins to me (the generated addresses are for my private keys).  You are correct that non-segwit wallets should handle witness transactions since they will receive them in legacy format.
You should be using p2sh nested segwit addresses. The segwit scripts are the "redeemscript" of a p2sh address. Since all wallets today can use p2sh, this lets wallets without segwit still be able to send to you and you can take advantage of segwit.