-
Notifications
You must be signed in to change notification settings - Fork 36.2k
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
Conversation
If you edit the pull request description, you can change the base branch from |
@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. |
There was a problem hiding this 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:
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.
src/qt/forms/optionsdialog.ui
Outdated
</sizepolicy> | ||
</property> | ||
<property name="text"> | ||
<string>BIP173 (bech32)</string> |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
src/qt/optionsmodel.cpp
Outdated
@@ -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")) |
There was a problem hiding this comment.
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 {}
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixing missing space. :)
src/qt/optionsmodel.cpp
Outdated
|
||
if(!settings.contains("strAddressType")) | ||
settings.setValue("strAddressType", QString::fromStdString(FormatOutputType(OUTPUT_TYPE_DEFAULT))); | ||
if (!gArgs.SoftSetArg("-addresstype", settings.value("strAddressType").toString().toStdString())) |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hsjoberg ping.
src/qt/forms/optionsdialog.ui
Outdated
@@ -163,6 +163,57 @@ | |||
</property> | |||
</widget> | |||
</item> | |||
<item> | |||
<widget class="QGroupBox" name="groupBoxAddressType"> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixing.
@Sjors Very true, I'll fix this. |
13adc63
to
62fe665
Compare
Rebased to fix some of the nits. |
GUI settings probably shouldn't influence RPC like this, and IMO it should really be exposed per-receive. |
@luke-jr wrote:
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 One counter argument to that is that we expect There's something to be said for being able to persist wallet settings, so that they apply to both 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. |
62fe665
to
3962c69
Compare
@Sjors Rebased and fixed 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.
Yes, I guess that makes sense too. |
3962c69
to
054d5fd
Compare
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. |
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. |
@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. |
Perhaps it makes sense to have both options available. Per receive level and as a global setting. |
case AddressTypeLegacy: | ||
if (value.toBool()) { | ||
settings.setValue("strAddressType", QString::fromStdString(FormatOutputType(OUTPUT_TYPE_LEGACY))); | ||
g_address_type = OUTPUT_TYPE_LEGACY; |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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 :/
There was a problem hiding this comment.
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.
Nice! |
Needs rebase |
@jonasschnelli I'll rebase to master as soon as I have time. |
054d5fd
to
450206b
Compare
450206b
to
ff6abca
Compare
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. |
src/qt/optionsmodel.cpp
Outdated
@@ -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))); |
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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).
Tested a bit and seems to work. 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. |
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. |
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). |
… 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
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! |
… 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
Needs rebase if still relevant. Otherwise I suggest to close. |
@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. |
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.
ff6abca
to
872f281
Compare
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. |
@@ -6,6 +6,7 @@ | |||
#define BITCOIN_QT_OPTIONSMODEL_H | |||
|
|||
#include <amount.h> | |||
#include <wallet/wallet.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this include?
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. |
This PR doesn't compile when rebased on |
Closing for now |
…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
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.