Skip to content

Commit

Permalink
Enable masking of cpid in privacy mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescowens committed Jan 1, 2022
1 parent bd96a4e commit 0aeb54c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/qt/overviewpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,12 @@ void OverviewPage::setPrivacy(bool privacy)

ui->recentTransactionsNoResult->setVisible(m_privacy || !transaction_count);
ui->listTransactions->setVisible(!m_privacy && transaction_count);
if (researcherModel) researcherModel->setMaskAccrualAndMagnitude(m_privacy);
if (researcherModel) researcherModel->setMaskCpidMagnitudeAccrual(m_privacy);

LogPrint(BCLog::LogFlags::QT, "INFO: %s: m_privacy = %u", __func__, m_privacy);

updateTransactions();
updateResearcherStatus();
updatePendingAccrual();
}

Expand Down
12 changes: 9 additions & 3 deletions src/qt/researcher/researchermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ void ResearcherModel::setTheme(const QString& theme_name)
emit beaconChanged();
}

void ResearcherModel::setMaskAccrualAndMagnitude(bool privacy)
void ResearcherModel::setMaskCpidMagnitudeAccrual(bool privacy)
{
m_privacy_enabled = privacy;

Expand Down Expand Up @@ -306,7 +306,13 @@ QString ResearcherModel::email() const

QString ResearcherModel::formatCpid() const
{
return QString::fromStdString(m_researcher->Id().ToString());
QString text = QString::fromStdString(m_researcher->Id().ToString());

if (m_privacy_enabled) {
text = text.replace(QRegExp("."), "#");
}

return text;
}

QString ResearcherModel::formatMagnitude() const
Expand All @@ -315,7 +321,7 @@ QString ResearcherModel::formatMagnitude() const

if (outOfSync()) {
text = "...";
} else if (m_privacy_enabled){
} else if (m_privacy_enabled) {
text = "#";
} else {
text = QString::fromStdString(m_researcher->Magnitude().ToString());
Expand Down
2 changes: 1 addition & 1 deletion src/qt/researcher/researchermodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class ResearcherModel : public QObject

void showWizard(WalletModel* wallet_model);
void setTheme(const QString& theme_name);
void setMaskAccrualAndMagnitude(bool privacy);
void setMaskCpidMagnitudeAccrual(bool privacy);

bool configuredForInvestorMode() const;
bool outOfSync() const;
Expand Down

0 comments on commit 0aeb54c

Please sign in to comment.