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

Showing Sigma balance at overview page #791

Merged
merged 1 commit into from
Dec 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
185 changes: 131 additions & 54 deletions src/qt/forms/overviewpage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@
<property name="spacing">
<number>12</number>
</property>
<item row="2" column="2">
<widget class="QLabel" name="labelWatchPending">
<item row="3" column="2">
<widget class="QLabel" name="labelWatchImmature">
<property name="font">
<font>
<weight>75</weight>
Expand All @@ -126,7 +126,7 @@
<cursorShape>IBeamCursor</cursorShape>
</property>
<property name="toolTip">
<string>Unconfirmed transactions to watch-only addresses</string>
<string>Mined balance in watch-only addresses that has not yet matured</string>
</property>
<property name="text">
<string notr="true">0.000 000 00 XZC</string>
Expand All @@ -139,8 +139,15 @@
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="labelUnconfirmed">
<item row="1" column="0">
<widget class="QLabel" name="labelBalanceText">
<property name="text">
<string>Available:</string>
</property>
</widget>
</item>
<item row="9" column="2">
<widget class="QLabel" name="labelWatchTotal">
<property name="font">
<font>
<weight>75</weight>
Expand All @@ -151,7 +158,7 @@
<cursorShape>IBeamCursor</cursorShape>
</property>
<property name="toolTip">
<string>Total of transactions that have yet to be confirmed, and do not yet count toward the spendable balance</string>
<string>Current total balance in watch-only addresses</string>
</property>
<property name="text">
<string notr="true">0.000 000 00 XZC</string>
Expand All @@ -164,8 +171,22 @@
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLabel" name="labelWatchImmature">
<item row="9" column="0">
<widget class="QLabel" name="labelTotalText">
<property name="text">
<string>Total:</string>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLabel" name="labelSigmaPending">
<property name="font">
<font>
<weight>75</weight>
Expand All @@ -176,10 +197,10 @@
<cursorShape>IBeamCursor</cursorShape>
</property>
<property name="toolTip">
<string>Mined balance in watch-only addresses that has not yet matured</string>
<string>Total of anonymize transactions that have yet to be confirmed, and do not yet count toward the spendable balance</string>
</property>
<property name="text">
<string notr="true">0.000 000 00 XZC</string>
<string>0.000 000 00 XZC</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
Expand All @@ -189,14 +210,7 @@
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="4" column="2">
<item row="8" column="2">
<widget class="Line" name="lineWatchBalance">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
Expand All @@ -215,15 +229,40 @@
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="labelTotalText">
<item row="6" column="1">
<widget class="QLabel" name="labelSigmaBalance">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
</property>
<property name="toolTip">
<string>Your current spendable anonymized balance</string>
</property>
<property name="text">
<string>Total:</string>
<string>0.000 000 00 XZC</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="labelImmature">
<item row="6" column="0">
<widget class="QLabel" name="labelSigmaBalanceText">
<property name="text">
<string>Available:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="labelBalance">
<property name="font">
<font>
<weight>75</weight>
Expand All @@ -234,7 +273,7 @@
<cursorShape>IBeamCursor</cursorShape>
</property>
<property name="toolTip">
<string>Mined balance that has not yet matured</string>
<string>Your current spendable balance</string>
</property>
<property name="text">
<string notr="true">0.000 000 00 XZC</string>
Expand All @@ -260,15 +299,8 @@
</property>
</spacer>
</item>
<item row="3" column="0">
<widget class="QLabel" name="labelImmatureText">
<property name="text">
<string>Immature:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="labelTotal">
<item row="2" column="2">
<widget class="QLabel" name="labelWatchPending">
<property name="font">
<font>
<weight>75</weight>
Expand All @@ -279,7 +311,7 @@
<cursorShape>IBeamCursor</cursorShape>
</property>
<property name="toolTip">
<string>Your current total balance</string>
<string>Unconfirmed transactions to watch-only addresses</string>
</property>
<property name="text">
<string notr="true">0.000 000 00 XZC</string>
Expand All @@ -292,8 +324,25 @@
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QLabel" name="labelWatchTotal">
<item row="0" column="2">
<widget class="QLabel" name="labelWatchonly">
<property name="text">
<string>Watch-only:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelPendingText">
<property name="text">
<string>Pending:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="labelUnconfirmed">
<property name="font">
<font>
<weight>75</weight>
Expand All @@ -304,7 +353,7 @@
<cursorShape>IBeamCursor</cursorShape>
</property>
<property name="toolTip">
<string>Current total balance in watch-only addresses</string>
<string>Total of transactions that have yet to be confirmed, and do not yet count toward the spendable balance</string>
</property>
<property name="text">
<string notr="true">0.000 000 00 XZC</string>
Expand All @@ -317,25 +366,43 @@
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="labelWatchonly">
<item row="9" column="1">
<widget class="QLabel" name="labelTotal">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
</property>
<property name="toolTip">
<string>Your current total balance</string>
</property>
<property name="text">
<string>Watch-only:</string>
<string notr="true">0.000 000 00 XZC</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelBalanceText">
<item row="0" column="1">
<widget class="QLabel" name="labelSpendable">
<property name="text">
<string>Available:</string>
<string>Spendable:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="labelBalance">
<item row="3" column="1">
<widget class="QLabel" name="labelImmature">
<property name="font">
<font>
<weight>75</weight>
Expand All @@ -346,7 +413,7 @@
<cursorShape>IBeamCursor</cursorShape>
</property>
<property name="toolTip">
<string>Your current spendable balance</string>
<string>Mined balance that has not yet matured</string>
</property>
<property name="text">
<string notr="true">0.000 000 00 XZC</string>
Expand All @@ -359,6 +426,13 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="labelImmatureText">
<property name="text">
<string>Immature:</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="labelWatchAvailable">
<property name="font">
Expand All @@ -384,20 +458,23 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelPendingText">
<item row="7" column="0">
<widget class="QLabel" name="labelSigmaPendingText">
<property name="text">
<string>Pending:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="labelSpendable">
<property name="text">
<string>Spendable:</string>
<item row="4" column="0" colspan="2">
<widget class="QLabel" name="label">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<property name="text">
<string>Anonymized Balances</string>
</property>
</widget>
</item>
Expand Down
38 changes: 36 additions & 2 deletions src/qt/overviewpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "platformstyle.h"
#include "transactionfilterproxy.h"
#include "transactiontablemodel.h"
#include "walletmodel.h"
#include "main.h"

#ifdef WIN32
Expand Down Expand Up @@ -201,7 +200,7 @@ void OverviewPage::setBalance(const CAmount& balance, const CAmount& unconfirmed
ui->labelBalance->setText(BitcoinUnits::formatWithUnit(unit, balance, false, BitcoinUnits::separatorAlways));
ui->labelUnconfirmed->setText(BitcoinUnits::formatWithUnit(unit, unconfirmedBalance, false, BitcoinUnits::separatorAlways));
ui->labelImmature->setText(BitcoinUnits::formatWithUnit(unit, immatureBalance, false, BitcoinUnits::separatorAlways));
ui->labelTotal->setText(BitcoinUnits::formatWithUnit(unit, balance + unconfirmedBalance + immatureBalance, false, BitcoinUnits::separatorAlways));
ui->labelTotal->setText(BitcoinUnits::formatWithUnit(unit, balance + unconfirmedBalance + immatureBalance + currentSigmaBalance + currentSigmaUnconfirmedBalance, false, BitcoinUnits::separatorAlways));
ui->labelWatchAvailable->setText(BitcoinUnits::formatWithUnit(unit, watchOnlyBalance, false, BitcoinUnits::separatorAlways));
ui->labelWatchPending->setText(BitcoinUnits::formatWithUnit(unit, watchUnconfBalance, false, BitcoinUnits::separatorAlways));
ui->labelWatchImmature->setText(BitcoinUnits::formatWithUnit(unit, watchImmatureBalance, false, BitcoinUnits::separatorAlways));
Expand All @@ -218,6 +217,38 @@ void OverviewPage::setBalance(const CAmount& balance, const CAmount& unconfirmed
ui->labelWatchImmature->setVisible(showWatchOnlyImmature); // show watch-only immature balance
}

void OverviewPage::updateCoins(const std::vector<CMintMeta>& spendable, const std::vector<CMintMeta>& pending)
{
CAmount sum(0);
int64_t denom;
for (const auto& c : spendable) {
DenominationToInteger(c.denom, denom);
sum += denom;
}

CAmount pendingSum(0);
for (const auto& c : pending) {
DenominationToInteger(c.denom, denom);
pendingSum += denom;
}



currentSigmaBalance = sum;
currentSigmaUnconfirmedBalance = pendingSum;
setSigmaBalance();
}

void OverviewPage::setSigmaBalance()
{
int unit = walletModel->getOptionsModel()->getDisplayUnit();

setBalance(walletModel->getBalance(), walletModel->getUnconfirmedBalance(), walletModel->getImmatureBalance(),
walletModel->getWatchBalance(), walletModel->getWatchUnconfirmedBalance(), walletModel->getWatchImmatureBalance());
ui->labelSigmaBalance->setText(BitcoinUnits::formatWithUnit(unit, currentSigmaBalance, false, BitcoinUnits::separatorAlways));
ui->labelSigmaPending->setText(BitcoinUnits::formatWithUnit(unit, currentSigmaUnconfirmedBalance, false, BitcoinUnits::separatorAlways));
}

// show/hide watch-only labels
void OverviewPage::updateWatchOnlyLabels(bool showWatchOnly)
{
Expand Down Expand Up @@ -264,6 +295,8 @@ void OverviewPage::setWalletModel(WalletModel *model)
setBalance(model->getBalance(), model->getUnconfirmedBalance(), model->getImmatureBalance(),
model->getWatchBalance(), model->getWatchUnconfirmedBalance(), model->getWatchImmatureBalance());
connect(model, SIGNAL(balanceChanged(CAmount,CAmount,CAmount,CAmount,CAmount,CAmount)), this, SLOT(setBalance(CAmount,CAmount,CAmount,CAmount,CAmount,CAmount)));
connect(model, SIGNAL(notifySigmaChanged(const std::vector<CMintMeta>, const std::vector<CMintMeta>)),
this, SLOT(updateCoins(const std::vector<CMintMeta>, const std::vector<CMintMeta>)));

connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));

Expand All @@ -282,6 +315,7 @@ void OverviewPage::updateDisplayUnit()
if(currentBalance != -1)
setBalance(currentBalance, currentUnconfirmedBalance, currentImmatureBalance,
currentWatchOnlyBalance, currentWatchUnconfBalance, currentWatchImmatureBalance);
setSigmaBalance();

// Update txdelegate->unit with the current unit
txdelegate->unit = walletModel->getOptionsModel()->getDisplayUnit();
Expand Down
Loading