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: Add privacy to the Overview page #16432

Merged
merged 2 commits into from May 29, 2020

Conversation

hebasto
Copy link
Member

@hebasto hebasto commented Jul 22, 2019

This PR allows to hide/reveal values on the Overviewpage by checking/unchecking Menu->Settings-> Mask Values

Closes #16407

Privacy mode is OFF (the default behavior):
Screenshot from 2020-01-02 15-08-28

Privacy mode is ON:
Screenshot from 2020-01-02 15-10-23 cropped

@fanquake fanquake added the GUI label Jul 22, 2019
@DrahtBot
Copy link
Contributor

DrahtBot commented Jul 22, 2019

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@practicalswift
Copy link
Contributor

practicalswift commented Jul 22, 2019

@hebasto Would you mind posting before/after screenshots?

@hebasto
Copy link
Member Author

hebasto commented Jul 22, 2019

@practicalswift

Would you mind posting before/after screenshots?

Done.

{
if (privacy && cache.isEmpty()) {
cache = text();
QLabel::setText("h-i-d-d-e-n");
Copy link
Member

@MarcoFalke MarcoFalke Jul 22, 2019

Choose a reason for hiding this comment

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

I think a fence of # translates better.

Couldn't this use BitcoinUnits::format(unit, 0).replace("0", "#") + unit.shortName() (or whatever is used right now), so that the UI doesn't reflow the columns on every toggle?

Copy link
Member

@MarcoFalke MarcoFalke Jul 22, 2019

Choose a reason for hiding this comment

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

Screenshot from 2019-07-22 08-04-35

Copy link
Member Author

@hebasto hebasto Jul 22, 2019

Choose a reason for hiding this comment

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

I think a fence of # translates better.

Done.

... so that the UI doesn't reflow the columns on every toggle?

This requires a monospaced font.

Copy link
Member Author

@hebasto hebasto Jul 22, 2019

Choose a reason for hiding this comment

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

This requires a monospaced font.

Done.

@laanwj
Copy link
Member

laanwj commented Jul 22, 2019

Concept ACK, definitely prefer the # to h-i-d-d-e-n

@hebasto
Copy link
Member Author

hebasto commented Jul 22, 2019

@MarcoFalke

I think a fence of # translates better.

@laanwj

definitely prefer the # to h-i-d-d-e-n

The screenshot on OP has been updated.

@achow101
Copy link
Member

achow101 commented Jul 22, 2019

Can it use a fixed number/string of #s instead of replacing each character with #? That way we don't leak any information about the number of coins. For example, right now, in your screenshot, we can see that you have at least 1000 coins and at least 100 available to spend.

@jonasschnelli
Copy link
Contributor

jonasschnelli commented Jul 22, 2019

Thanks for working on this!
Tested a bit. Works.

Not sure if clicking on the actual amount label is the right way to activate this (may confuse user who lacks understanding the "hidden"-concept).

Plus, should it not also cover the "Recent transactions"-list amounts?

I would say ideally, once enabled, the values in the transaction list should also be "hidden".

@promag
Copy link
Member

promag commented Jul 22, 2019

Concept ACK. Not so sure about the approach as it requires too much wiring. I'm testing a different approach and I'll give feedback if it's worth it.

@promag
Copy link
Member

promag commented Jul 22, 2019

Not sure if clicking on the actual amount label is the right way to activate this

Agree with @jonasschnelli, I initially thought of having a toggle somewhere (in the status bar for instance) as well a menu option. Something for a follow up.

@hebasto
Copy link
Member Author

hebasto commented Jul 22, 2019

@achow101

Can it use a fixed number/string of #s instead of replacing each character with #? That way we don't leak any information about the number of coins. For example, right now, in your screenshot, we can see that you have at least 1000 coins and at least 100 available to spend.

Done. The screenshot on OP has been updated.

@hebasto
Copy link
Member Author

hebasto commented Jul 22, 2019

@jonasschnelli Thank you for your review.

Not sure if clicking on the actual amount label is the right way to activate this (may confuse user who lacks understanding the "hidden"-concept).

It seems very intuitive ;) (also there is an example of usage in Wasabi)
To further improvements (on the following PR), a toggle could be added (as @promag suggested).

Plus, should it not also cover the "Recent transactions"-list amounts?
I would say ideally, once enabled, the values in the transaction list should also be "hidden".

Agree. I'd leave this improvement for the following PRs.

@kristapsk
Copy link
Contributor

kristapsk commented Jul 22, 2019

Not sure if clicking on the actual amount label is the right way to activate this (may confuse user who lacks understanding the "hidden"-concept).

That's the way "lurking wife mode" of Wasabi Wallet, which is basically the same, is activated. I think Bitcoin is already hard enough for newcomers, so unnecessary reinventing the wheel should be avoided, if possible, so that users get similar experience using different wallets. Unless there are clear benefits in doing so, of course. But probably some message about privacy / stealth mode being activated and how to turn it back off would not hurt.

integer_part = QString(integer_part.size() - 1, ' ') + mask;
QString fractional_part = parts.last();
fractional_part = fractional_part.replace(QRegularExpression("\\d"), mask);
QLabel::setText(integer_part + '.' + fractional_part);
Copy link
Contributor

@kristapsk kristapsk Jul 22, 2019

Choose a reason for hiding this comment

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

Just looked at how Wasabi did this and they just replace any amounts, addresses, labels everywhere with a fixed number of #'s. IMO "#########" even looks better than "#.########" and it's less lines of code, all this block could be just replaced with

cache = text();
QLabel::setText("#########");`

Copy link
Member Author

@hebasto hebasto Jul 23, 2019

Choose a reason for hiding this comment

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

Unfortunately, this will cause the UI to reflow the columns on every toggle (see @MarcoFalke's comment).

@fanquake
Copy link
Member

fanquake commented Jul 23, 2019

Concept ACK

@hebasto
Copy link
Member Author

hebasto commented Jul 23, 2019

Fixed two bugs:

  • sat units (no fractional part) handling
  • unit switching handling

@fanquake
Copy link
Member

fanquake commented Jul 24, 2019

Had a quick test. Functionality works as described. I might just be seeing things, but the monospace font looks a bit weird no macOS, don't think that has to be any sort of blocker though.

@promag Are you still working on a different approach, or happy with this PR now?

master:
master

This PR:
16432-values
16432-hidden

@darosior
Copy link
Member

darosior commented Jul 24, 2019

ACK 22c16fd
I readed the code and I tested it. I think it's a great addition.

@promag
Copy link
Member

promag commented Jul 25, 2019

I've tried alternatives - basically tried filtering paint events if the widget had amounts or even extend QStyle - but didn't like at the end.

Currently I think this PR can be improved, I'll review shortly.

@jonasschnelli
Copy link
Contributor

jonasschnelli commented Aug 12, 2019

Looks like the build is failing:

qt/bitcoinamountlabel.cpp:26:47: error: 'QRegularExpression' is an incomplete type
    fractional_part = fractional_part.replace(QRegularExpression("\\d"), mask);
                                              ^
/home/ubuntu/src/depends/x86_64-apple-darwin14/include/QtCore/qstring.h:80:7: note: forward declaration of 'QRegularExpression'
class QRegularExpression;

https://bitcoinbuilds.org/index.php?build=669

@hebasto
Copy link
Member Author

hebasto commented Aug 12, 2019

@jonasschnelli

Looks like the build is failing: ...

Rebased and fixed by partially reverting the 248e22b commit (#16386).

@jonasschnelli
Copy link
Contributor

jonasschnelli commented Aug 13, 2019

Works as intended. I like the concept but think it should be implemented more radical (maybe in follow up PRs?).

  • The privacy mode won't hide recent transaction values
  • For users not aware of the privacy mode, it's unclear why the numbers are now # and how to bring it back,... a quick disappearing info-element (statusbar?) would make things much more understandable for users new to this concept (or a toggle element in the icon section of the status bar?).
  • I think all amount values should be masqueraded, especially the ones in the transaction list.

Copy link
Member

@luke-jr luke-jr left a comment

Rather than cloaking the text we want to hide (which seems problematic so long as we base it on the real hidden value), how about simply setting the background colour to the text colour?

depends/packages/qt.mk Outdated Show resolved Hide resolved
@konez2k
Copy link

konez2k commented Aug 20, 2019

This should work without regexp

static QString cloak(QString& text)
{
    QStringList parts = text.split(' ');
    QStringList amounts = parts[0].split('.');
    for (int i = 0; i < amounts.size(); i++)
        amounts[i].fill('#');
    return amounts.join('.') + ' ' + parts[1];
}

@laanwj laanwj added the Feature label Sep 30, 2019
@hebasto
Copy link
Member Author

hebasto commented May 27, 2020

Updated 908b014 -> 8d75115 (pr16432.21 -> pr16432.22, diff):

Apologetic nit: I belatedly noticed that this change makes the message long enough to be potentially cut off at the end (on my display on Debian). Do we need to write Menu->? If you retouch, maybe consider something like the following. I tested that it fits in the smallest display size (on my display).

-    const QString status_tip = m_privacy ? tr("Privacy mode is activated for the Overview tab. To unmask the values, uncheck Menu->Settings->Mask values.") : "";
+    const QString status_tip = m_privacy ? tr("Privacy mode activated for the Overview tab. To unmask the values, uncheck Settings->Mask values.") : "";

@jonatack
Copy link
Member

jonatack commented May 27, 2020

Tested ACK 8d75115

Changes since last review:

git diff 908b014 8d75115

((HEAD detached at origin/pr/16432))$ git diff 31be796 908b014
$ git diff 908b014 8d75115
diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp
index 51682fe2fc..1ab30fefc7 100644
--- a/src/qt/overviewpage.cpp
+++ b/src/qt/overviewpage.cpp
@@ -163,7 +163,7 @@ void OverviewPage::setPrivacy(bool privacy)
 
     ui->listTransactions->setVisible(!m_privacy);
 
-    const QString status_tip = m_privacy ? tr("Privacy mode is activated for the Overview tab. To unmask the values, uncheck Menu->Settings->Mask values.") : "";
+    const QString status_tip = m_privacy ? tr("Privacy mode activated for the Overview tab. To unmask the values, uncheck Settings->Mask values.") : "";

Thanks @hebasto 🏆

@luke-jr
Copy link
Member

luke-jr commented May 28, 2020

Apologetic nit: I belatedly noticed that this change makes the message long enough to be potentially cut off at the end (on my display on Debian).

We shouldn't be assuming or breaking with any window or font size... Is this a bug?

@jonatack
Copy link
Member

jonatack commented May 28, 2020

@luke-jr Good question. My description was imprecise. When the GUI window was at its smallest size, the message wasn't truncated per se but required navigating horizontally using the window scroll bar to see the last word.

@jonasschnelli
Copy link
Contributor

jonasschnelli commented May 29, 2020

Tested ACK 8d75115

@jonasschnelli jonasschnelli merged commit 5f75c5e into bitcoin:master May 29, 2020
2 checks passed
@hebasto hebasto deleted the 20190721-privacy branch May 29, 2020
MarkLTZ added a commit to litecoinz-core/litecoinz that referenced this issue May 29, 2020
sidhujag pushed a commit to syscoin/syscoin that referenced this issue May 31, 2020
8d75115 qt: Add privacy feature to Overview page (Hennadii Stepanov)
73d8ef7 qt: Add BitcoinUnits::formatWithPrivacy() function (Hennadii Stepanov)

Pull request description:

  This PR allows to hide/reveal values on the Overviewpage by checking/unchecking Menu->Settings-> Mask Values

  Closes bitcoin#16407

  Privacy mode is OFF (the default behavior):
  ![Screenshot from 2020-01-02 15-08-28](https://user-images.githubusercontent.com/32963518/71669074-28ab6980-2d74-11ea-8e54-4973aa307192.png)

  Privacy mode is ON:
  ![Screenshot from 2020-01-02 15-10-23 cropped](https://user-images.githubusercontent.com/32963518/71669082-2d701d80-2d74-11ea-9df5-d4acc4982dbe.png)

ACKs for top commit:
  jonatack:
    Tested ACK 8d75115
  jonasschnelli:
    Tested ACK 8d75115

Tree-SHA512: 42f396d5bf0d343b306fb7e925f86f66b3fc3a257af370a812f4be181b5269298f9b23bd8a3ce25ab61de92908c4018d8c2dc8591d11bc58d79c4eb7206fc6ec
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this issue Jun 9, 2020
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this issue Jun 9, 2020
MarcoFalke added a commit to bitcoin-core/gui that referenced this issue Dec 17, 2020
…ormat

198fff8 GUI: Define MAX_DIGITS_BTC for magic number in BitcoinUnits::format (Luke Dashjr)

Pull request description:

  A magic number snuck in with bitcoin/bitcoin#16432

ACKs for top commit:
  hebasto:
    ACK 198fff8, I have reviewed the code and it looks OK, I agree it can be merged.
  kristapsk:
    utACK 198fff8

Tree-SHA512: 78dc23c2ae61bac41e5e34eebf57274599cb2ebb0b18d46e8a3228d42b256a1bc9bb17091c748f0f692ef1c4c241cfbd3e30a12bcd12222a234c1a9547ebe786
laanwj added a commit to bitcoin-core/gui that referenced this issue Feb 22, 2021
67f2631 gui: Add monospaced font settings (Hennadii Stepanov)
22e0114 qt: Choose monospaced font in C++ code rather in `*.ui` file (Hennadii Stepanov)
623de12 qt: Make GUIUtil::fixedPitchFont aware of embedded font (Hennadii Stepanov)
89e4219 gui: Add Roboto Mono font (Hennadii Stepanov)

Pull request description:

  Qt does not guarantee that the actual applied font matches to the requested one.
  It was noted (bitcoin/bitcoin#16432 (comment)):
  > the monospace font looks a bit weird no macOS

  ... because it is _not_ monospaced.
  Also some discrepancies I've noted on Windows while testing Qt 5.15 ([#19716](bitcoin/bitcoin#19716)).

  Of course, we could check the actual font with `QFontInfo`, and try to choose another font.
  But this PR suggests to just embed a monospaced font, and get the GUI look (partially) independent from a platform.

  [Roboto Mono](https://fonts.google.com/specimen/Roboto+Mono) was chosen after discussion with Bitcoin Design community, and due to its [Apache License, Version 2.0](https://fonts.google.com/specimen/Roboto+Mono#license).

  Changes are scoped to the Overview page only.

  ---

  Screenshots on macOS 10.15.6 (images are simulated by code patching):

  - master (ca30d34)
  ![Screenshot from 2020-09-03 14-10-03](https://user-images.githubusercontent.com/32963518/92107902-30357d80-edef-11ea-8a4f-b4c758eebf66.png)

  - this PR (3fdd5b6)
  ![Screenshot from 2020-09-03 15-41-36](https://user-images.githubusercontent.com/32963518/92116277-4b5aba00-edfc-11ea-8cb9-22fc44460bfb.png)

  ---

  More screenshots added after #79 (comment):

  - Linux Mint 20.1 + Cinnamon DE

  ![DeepinScreenshot_select-area_20210221205410](https://user-images.githubusercontent.com/32963518/108635739-b327be80-7489-11eb-8851-ac89f61199ee.png)

  - Windows 10 (with depends)

  ![DeepinScreenshot_select-area_20210221205056](https://user-images.githubusercontent.com/32963518/108635741-b6bb4580-7489-11eb-8b6b-66be5551eb8c.png)

  - macOS Big Sur (with depends)

  ![DeepinScreenshot_select-area_20210221202917](https://user-images.githubusercontent.com/32963518/108635746-bd49bd00-7489-11eb-8cd2-cf4bb2273a6d.png)

ACKs for top commit:
  laanwj:
    Tested ACK 67f2631

Tree-SHA512: a59775570b8ce314669ede50a0b69f53e8a47a41e7eea428835013240f0ce9afcff6e4c258895455b56806417ed877e5b7a9522f1904e95a5f435db8ccf6078c
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this issue Aug 24, 2021
Summary:
> This PR allows to hide/reveal values on the Overviewpage by checking/unchecking Menu->Settings-> Mask Values

This is a backport of [[bitcoin/bitcoin#16432 | core#16432]] [1/2]
bitcoin/bitcoin@73d8ef7

Test Plan: `ninja all check-all`

Reviewers: #bitcoin_abc, majcosta

Reviewed By: #bitcoin_abc, majcosta

Differential Revision: https://reviews.bitcoinabc.org/D9919
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this issue Aug 24, 2021
Summary:
This is a backport of [[bitcoin/bitcoin#16432 | core#16432]] [2/2]

bitcoin/bitcoin@8d75115

Depends on D9919

Test Plan:
`ninja && src/qt/bitcoin-qt`

Toggle the privacy option with Shift + Ctrl + M or through the menu.

Reviewers: #bitcoin_abc, majcosta

Reviewed By: #bitcoin_abc, majcosta

Subscribers: majcosta

Differential Revision: https://reviews.bitcoinabc.org/D9920
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this issue Aug 24, 2021
Summary: I noticed while backporting [[bitcoin/bitcoin#16432 | core#16432]]  that there are some leftover instances of BCH in default values for widgets.

Test Plan:
I don't know how to test this, those values are probably reinitialized in the code before the widgets are even visible, else we would have noticed the wrong  "BCH"  unit in the past.

I just compiled and ran  `bitcoin-qt` to make sure everything works and looks normal.

Check that there aren't any occurences of BCH left:
` grep BCH src/qt/forms/*.ui`

Reviewers: #bitcoin_abc, majcosta

Reviewed By: #bitcoin_abc, majcosta

Subscribers: majcosta

Differential Revision: https://reviews.bitcoinabc.org/D9921
@BenWestgate
Copy link

BenWestgate commented Aug 12, 2022

Current Behavior: "Mask values" mode is off each launch and must be manually re-enabled.
If a wallet loads on startup from settings.json this leaves user vulnerable to shoulder surfing.

Solution: This mode should persist across restarts of bitcoin-qt by being saved in Bitcoin-Qt.conf.
Exactly how nDisplayUnit=0 will persist the unit to show amounts in.

Expected Behavior: If I shutdown Bitcoin core with it on, I'd expect it to be on when I restart and vice versa.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.