Skip to content

Commit

Permalink
gui: add used balance to overview page
Browse files Browse the repository at this point in the history
Add used balance to overview page for wallets with avoid_reuse flag enabled
  • Loading branch information
BrandonOdiwuor committed Nov 3, 2023
1 parent feae4e0 commit d32506b
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 5 deletions.
36 changes: 31 additions & 5 deletions src/qt/forms/overviewpage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,40 @@
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<item row="4" column="0">
<widget class="QLabel" name="labelUsedText">
<property name="text">
<string>Used:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="labelUsed">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
</property>
<property name="toolTip">
<string>Your current used balance</string>
</property>
<property name="text">
<string notr="true">21 000 000.00000000 BTC</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="5" 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="5" column="2">
<widget class="Line" name="lineWatchBalance">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
Expand All @@ -194,7 +220,7 @@
</property>
</widget>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QLabel" name="labelTotalText">
<property name="text">
<string>Total:</string>
Expand Down Expand Up @@ -240,7 +266,7 @@
</property>
</widget>
</item>
<item row="5" column="1">
<item row="6" column="1">
<widget class="QLabel" name="labelTotal">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
Expand All @@ -259,7 +285,7 @@
</property>
</widget>
</item>
<item row="5" column="2">
<item row="6" column="2">
<widget class="QLabel" name="labelWatchTotal">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
Expand Down
10 changes: 10 additions & 0 deletions src/qt/overviewpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,15 @@ void OverviewPage::setBalance(const interfaces::WalletBalances& balances)
ui->labelImmature->setVisible(showImmature || showWatchOnlyImmature);
ui->labelImmatureText->setVisible(showImmature || showWatchOnlyImmature);
ui->labelWatchImmature->setVisible(!walletModel->wallet().privateKeysDisabled() && showWatchOnlyImmature); // show watch-only immature balance

// only show used balance when on wallet with 'avoid_reuse' flag
bool showUsed = walletModel->isAvoidReuseEnabled();

if (showUsed) {
ui->labelUsed->setText(BitcoinUnits::formatWithPrivacy(unit, balances.used, BitcoinUnits::SeparatorStyle::ALWAYS, m_privacy));
}
ui->labelUsedText->setVisible(showUsed);
ui->labelUsed->setVisible(showUsed);
}

// show/hide watch-only labels
Expand Down Expand Up @@ -352,4 +361,5 @@ void OverviewPage::setMonospacedFont(bool use_embedded_font)
ui->labelWatchPending->setFont(f);
ui->labelWatchImmature->setFont(f);
ui->labelWatchTotal->setFont(f);
ui->labelUsed->setFont(f);
}
5 changes: 5 additions & 0 deletions src/qt/walletmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,11 @@ bool WalletModel::isMultiwallet() const
return m_node.walletLoader().getWallets().size() > 1;
}

bool WalletModel::isAvoidReuseEnabled() const
{
return m_wallet->isAvoidReuseEnabled();
}

void WalletModel::refresh(bool pk_hash_only)
{
addressTableModel = new AddressTableModel(this, pk_hash_only);
Expand Down
2 changes: 2 additions & 0 deletions src/qt/walletmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ class WalletModel : public QObject

bool isMultiwallet() const;

bool isAvoidReuseEnabled() const;

void refresh(bool pk_hash_only = false);

uint256 getLastBlockProcessed() const;
Expand Down

0 comments on commit d32506b

Please sign in to comment.