Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qt: Setting for deciding address type (legacy, p2sh or bech32) #11937

Closed
wants to merge 1 commit into from

Conversation

hsjoberg
Copy link
Contributor

@hsjoberg hsjoberg commented Dec 18, 2017

Related PR #11403, needs to be merged first. I'll rebase this PR to be up to date with #11403, and rebase it to master once it has been merged.

Exposes the addresstype parameter through the GUI.
Currently directly changes the g_address_type global variable instead of requiring an application restart, I'm not sure if this is good practice, but could easily be changed if needed.

Radio buttons seem to be acting a bit different compared to other GUI elements, so that's why the code is somewhat different than for other settings.

@hsjoberg hsjoberg changed the title GUI: Setting for deciding address type (legacy, p2sh or bech32) Qt: Setting for deciding address type (legacy, p2sh or bech32) Dec 18, 2017
@Sjors
Copy link
Member

Sjors commented Dec 18, 2017

If you edit the pull request description, you can change the base branch from bitcoin:master to sipa:201709_segwitwallet2. That should make review here much easier. Although it might cause Github to move the whole pull request to @sipa's account, which would hurt visibility.

@hsjoberg
Copy link
Contributor Author

hsjoberg commented Dec 18, 2017

@Sjors Yes, I tried to do that but it doesn't seem to be possible.

But opening a new PR to Wuille's repository should be possible yes.

@Sjors
Copy link
Member

Sjors commented Dec 18, 2017

No problem, it's easy to work around:
schermafbeelding 2017-12-18 om 18 23 23

Copy link
Member

@Sjors Sjors left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK. It's great to offer users the ability to use bech32 addresses.

Receive tab works as expected.

Send tab has a bug: without a restart, the change address will not use newly selected address type (maybe explicitly set -changetype?).

The nested boxes and alignment is not very pretty:

nesting

I suggest moving this the same level as Expert. Alternatively, use a dropdown.

Arguably this isn't really an expert feature anyway, especially if you remove the Legacy option. Users can't really shoot themselves in the foot: either they get paid, or the creditor tells them they don't understand the address, in which case the user creates a P2SH address.

I'd like to have a way to toggle this in the address generation screen too, but that can be done independently of this PR.

</sizepolicy>
</property>
<property name="text">
<string>BIP173 (bech32)</string>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe call this "Native SegWit (bech32, BIP173)"?

Can you also add a description (could be a popover) to explain the difference, explain:

  • not all wallets support this format
  • there are privacy implications for using bech32 while adoption is low, as well as for mixing bech32 and P2SH

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'll look into that.
Any suggestions of exactly what the tooltip(s) should say?

@@ -180,6 +181,10 @@ void OptionsDialog::setMapper()
mapper->addMapping(ui->spendZeroConfChange, OptionsModel::SpendZeroConfChange);
mapper->addMapping(ui->coinControlFeatures, OptionsModel::CoinControlFeatures);

mapper->addMapping(ui->addressTypeLegacy, OptionsModel::AddressTypeLegacy);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really want to maintain UI support for legacy addresses? Maybe only show this option if the app was launched with -addresstype=legacy?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I think it makes more sense to have the GUI options mapped 1:1 to the addresstype parameter. Perhaps this could be something to look into later?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nvm, it's fine for a setting, especially combined with the per address checkbox in #11991.

@@ -110,6 +110,11 @@ void OptionsModel::Init(bool resetSettings)
settings.setValue("bSpendZeroConfChange", true);
if (!gArgs.SoftSetBoolArg("-spendzeroconfchange", settings.value("bSpendZeroConfChange").toBool()))
addOverriddenOption("-spendzeroconfchange");

if(!settings.contains("strAddressType"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, missing space after if, missing {}.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixing missing space. :)


if(!settings.contains("strAddressType"))
settings.setValue("strAddressType", QString::fromStdString(FormatOutputType(OUTPUT_TYPE_DEFAULT)));
if (!gArgs.SoftSetArg("-addresstype", settings.value("strAddressType").toString().toStdString()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, missing {}.

break;
case OUTPUT_TYPE_NONE:
default:
break;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is not hit then assert?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I'm not sure if we really need to kill the application, if we cannot resolve an address type, it doesn't necessarily need to be fatal.

I'm not sure what the best practice is here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think an assert would be appropriate here (stop the app if address type is unknown to the GUI).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hsjoberg ping.

@@ -163,6 +163,57 @@
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBoxAddressType">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is inside Export group box, should be on the outside instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixing.

@hsjoberg
Copy link
Contributor Author

I suggest moving this the same level as Expert. Alternatively, use a dropdown.

@Sjors @promag The Address type was actually intentionally in the Expert group, but I guess you are right, it makes more sense to have it separately. I will move it.
We need good tooltips and description though.

@hsjoberg
Copy link
Contributor Author

Send tab has a bug: without a restart, the change address will not use newly selected address type (maybe explicitly set -changetype?).

@Sjors Very true, I'll fix this.

@hsjoberg
Copy link
Contributor Author

hsjoberg commented Dec 19, 2017

Rebased to fix some of the nits.

@luke-jr
Copy link
Member

luke-jr commented Dec 19, 2017

GUI settings probably shouldn't influence RPC like this, and IMO it should really be exposed per-receive.

@Sjors
Copy link
Member

Sjors commented Dec 19, 2017

@luke-jr wrote:

IMO it should really be exposed per-receive

Do you mean that it should only be exposed per receive (i.e. don't add this setting)?

That would not be ideal, because the wallet wouldn't use bech32 for change in that case.

It reveals another problem with this setting: if the user changes the setting and then runs bitcoind instead of bitcoin-qt, they might expect the RPC to use bech32 as well, just like it would in the debug console inside of QT.

One counter argument to that is that we expect bitcoind users to know what they're doing and to aware of the fact that GUI settings, like "spend unconfirmed change", don't apply to bitcoind. This would be worth pointing out in the release notes and such.

There's something to be said for being able to persist wallet settings, so that they apply to both bitcoin-qt and bitcoind if no flag overrides it.

Writing the setting into bitcoin.conf is one way, but at least one potential problem with that, is that we can't change the default later, because all users have it set in stone in their bitcoin.conf file. That's probably an issue with the PR as well; once there is a setting, it's weird to just change it.

So I might agree with @luke-jr here in that this should be a per-receive thing, and not a setting. But then I would suggest that we make the change address behavior more intelligent (not in this PR): its address type should match the destination. Also making it a per receive checkbox still makes it difficult to change, as the user might grow accustomed to the check-box being checked or unchecked.

So I'm not really sure. We should think about how to encourage users to try out bech32 without making it more difficult to make this the default in the future.

@hsjoberg
Copy link
Contributor Author

Send tab has a bug: without a restart, the change address will not use newly selected address type (maybe explicitly set -changetype?).

@Sjors Rebased and fixed this.
Right now, changetype isn't changed if you explicitly set a type it in the configuration file, otherwise it defaults to whatever addresstype option is chosen.

@hsjoberg
Copy link
Contributor Author

hsjoberg commented Dec 19, 2017

GUI settings probably shouldn't influence RPC like this

@luke-jr Isn't this what GUI settings basically are used for? It seems like most of the settings in the GUI expose different configuration parameters.

IMO it should really be exposed per-receive.

Yes, I guess that makes sense too.

@Sjors
Copy link
Member

Sjors commented Dec 22, 2017

For a per receive address toggle, see #11991. These PR's are compatible (aside from the usual potential for merge conflicts), so we can use both, either or none.

@jb55
Copy link
Contributor

jb55 commented Dec 30, 2017

Hmm after testing this patch over #11991, I think I prefer this one. The toggle seems a bit weird. I don't see why I would ever want to selectively toggle a bech32 address, vs just eventually having it my default when I feel comfortable doing that.

@sipa
Copy link
Member

sipa commented Dec 31, 2017

@jb55 The only reason for bech32 or not is whether the sender supports bech32 - which I think is something you may want to decide per address.

@hsjoberg
Copy link
Contributor Author

hsjoberg commented Dec 31, 2017

Perhaps it makes sense to have both options available. Per receive level and as a global setting.
If not, I think @Sjors PR works very well.

@molxyz
Copy link

molxyz commented Jan 2, 2018

ACK! I just compiled this PR for Windows. It is beautiful. Really love it. Will test.

walletgui-by-coco

case AddressTypeLegacy:
if (value.toBool()) {
settings.setValue("strAddressType", QString::fromStdString(FormatOutputType(OUTPUT_TYPE_LEGACY)));
g_address_type = OUTPUT_TYPE_LEGACY;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, but I guess changing g_address_type and g_change_type needs locking (concurrency), otherwise a race would be possible (unlikely, though possible).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, probably, in current code I think its safe just because they're only set at init, setting at runtime is probably a lock bug, but none of the option are good fixes :/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guard with cs_main? Most accesses already held the lock. Fix the remaining.

@jonasschnelli
Copy link
Contributor

Nice!
Concept ACK

@jonasschnelli
Copy link
Contributor

Needs rebase

@hsjoberg
Copy link
Contributor Author

@jonasschnelli I'll rebase to master as soon as I have time.

@laanwj laanwj added this to the 0.16.0 milestone Jan 11, 2018
@hsjoberg
Copy link
Contributor Author

Addressed some of the issues that have been pointed out as well as the compiling error, sorry for that.

There are still some outstanding things that need to be addressed, I'll look into them.

@@ -110,6 +110,11 @@ void OptionsModel::Init(bool resetSettings)
settings.setValue("bSpendZeroConfChange", true);
if (!gArgs.SoftSetBoolArg("-spendzeroconfchange", settings.value("bSpendZeroConfChange").toBool()))
addOverriddenOption("-spendzeroconfchange");

if (!settings.contains("strAddressType"))
settings.setValue("strAddressType", QString::fromStdString(FormatOutputType(OUTPUT_TYPE_DEFAULT)));
Copy link
Contributor

@jonasschnelli jonasschnelli Jan 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do that also at different places... but this makes changing defaults in the future really hard. If we the default for -addresstype, QT remains at the old state even if the user hasn't changed the value there...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can fix this in a follow up PR (that also fixes the other issues with defaults).

@jonasschnelli
Copy link
Contributor

Tested a bit and seems to work.
What worries me is that the code has not the right concurrency protections to have those globals change during run-time. There would be some potential races (rare and often only possible when mixing QT with RPC).

We can leave this for an follow up PR but I'd prefer the have the right instruments in place before adding runtime "sets" on those globals.

@gmaxwell
Copy link
Contributor

I don't see any use case for the three way selection-- it just confronts users with more technical details (complete with gobbltygopy technical terms like P2SH and BIP173 ) which many won't know how to select among.

The purpose of having the legacy setting is maintaining wallet backwards compatibility. .. but that's blown out the moment you select either P2SH or BC1 addresses. What is the envisioned use-case for someone to set legacy but then sometimes pick P2SH? Without understanding that I am a Concept NAK.

Being able to switch between BC1 and 3xxx addresses at receive time would very useful, but that should be a per-receive selection set when the address is requested.

@jonasschnelli
Copy link
Contributor

Removing 0.16 milestone since there are some concerns with this PR. Also, seems not to be a blocker for 0.16 (especially since #11991).

@jonasschnelli jonasschnelli removed this from the 0.16.0 milestone Jan 18, 2018
laanwj added a commit that referenced this pull request Jan 24, 2018
… P2WPKH or P2WSH

596c446 [wallet] use P2WPKH change output if any destination is P2WPKH or P2WSH (Sjors Provoost)

Pull request description:

  If `-changetype` is not explicitly set, then regardless of `-addresstype`, the wallet will use a ~`bech32` change address~ `P2WPKH` change output if any destination is `P2WPKH` or `P2WSH`.

  This seems more intuitive to me and more in line with the spirit of [BIP-69](https://github.com/bitcoin/bips/blob/master/bip-0069.mediawiki).

  When combined with #11991 a QT user could opt to use `bech32` exclusively without having to figure out how to launch with `-changetype=bech32`, although so would #11937.

Tree-SHA512: 9238d3ccd1f3be8dfdd43444ccf45d6bdc6584ced3172a3045f3ecfec4a7cc8999db0cdb76ae49236492a84e6dbf3a1fdf18544d3eaf6d518e1f8bd241db33e7
@molxyz
Copy link

molxyz commented Apr 25, 2018

I'm not sure why this PR isn't merged? It makes much more sense to use this so I have been using it as my wallet. Please consider to merge this PR. Thank you!

maflcko pushed a commit that referenced this pull request May 17, 2018
… legacy address default

82dda6b GUI: Allow generating Bech32 addresses with a legacy-address default (Luke Dashjr)
7ab1c6f GUI: Rephrase Bech32 checkbox text/tooltip (Luke Dashjr)

Pull request description:

  - "Bech32" isn't very user-friendly; used "native segwit" as in #11937.
  - You don't spend from addresses.
  - No reason to block off Bech32 access with legacy address default.

  Rebased from #12208

Tree-SHA512: c82dd20d967a7f47bcc75b25be0d3a8cf00cfccc1cd14916b87d70b9c56fd53e366b456348b173f36c89b145b76624413780abaed4cea82117a9ecd47dd8fb99
@maflcko
Copy link
Member

maflcko commented May 23, 2018

Needs rebase if still relevant. Otherwise I suggest to close.

@hsjoberg
Copy link
Contributor Author

@molxyz @MarcoFalke Sorry for the delay.

Yes, If there is interest I could continue work on this PR.

There are some minor outstanding issues (albeit minor) regarding thread safety and other things that I'll look into before merge.

There doesn't seem to be a clear consensus regarding if we should merge this.
Personally I think it makes sense considering we already provide these options through the configuration file and as a command-line argument. I do understand the argument that it could be perceived as too technical though (not sure on how to improve on this?)

@maflcko
Copy link
Member

maflcko commented May 23, 2018

@hsjoberg have you seen #13251? I haven't looked closely at you pull request, but they seem strongly related. And yours might not be relevant after that one has been merged.

@maflcko
Copy link
Member

maflcko commented May 23, 2018

If it is still relevant, please rebase so that it compiles at a minimum. (green travis)

The Options-dialog now contains radio buttons for deciding which address
type to use (legacy, p2sh or BIP173 (bech32)).

This setting is connected to the `addresstype` parameter.
@DrahtBot
Copy link
Contributor

The last travis run for this pull request was 55 days ago and is thus outdated. To trigger a fresh travis build, this pull request should be closed and re-opened.

@DrahtBot DrahtBot reopened this Jul 29, 2018
@@ -6,6 +6,7 @@
#define BITCOIN_QT_OPTIONSMODEL_H

#include <amount.h>
#include <wallet/wallet.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this include?

@maflcko
Copy link
Member

maflcko commented Jul 29, 2018

Hmm, I don't think we should expose a "legacy" checkbox through the gui. I am missing the use case for that, given that "bech32" can already be unchecked.

@practicalswift
Copy link
Contributor

This PR doesn't compile when rebased on master :-)

@maflcko
Copy link
Member

maflcko commented Sep 15, 2018

Closing for now

@maflcko maflcko closed this Sep 15, 2018
TheArbitrator pushed a commit to TheArbitrator/dash that referenced this pull request Jun 21, 2021
…it with legacy address default

82dda6b GUI: Allow generating Bech32 addresses with a legacy-address default (Luke Dashjr)
7ab1c6f GUI: Rephrase Bech32 checkbox text/tooltip (Luke Dashjr)

Pull request description:

  - "Bech32" isn't very user-friendly; used "native segwit" as in bitcoin#11937.
  - You don't spend from addresses.
  - No reason to block off Bech32 access with legacy address default.

  Rebased from bitcoin#12208

Tree-SHA512: c82dd20d967a7f47bcc75b25be0d3a8cf00cfccc1cd14916b87d70b9c56fd53e366b456348b173f36c89b145b76624413780abaed4cea82117a9ecd47dd8fb99
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.