Skip to content
Closed
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
1 change: 0 additions & 1 deletion src/qt/bitcoinunits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ QString BitcoinUnits::formatHtmlWithUnit(Unit unit, const CAmount& amount, bool

QString BitcoinUnits::formatWithPrivacy(Unit unit, const CAmount& amount, SeparatorStyle separators, bool privacy)
{
assert(amount >= 0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: Maybe this change motivation should be documented in the commit message. It is not clear why is needed.
Just a simple line saying that m_mine_nonmempool is always negative so this assert is no longer true should be enough.

QString value;
if (privacy) {
value = format(unit, 0, false, separators, true).replace('0', '#');
Expand Down
32 changes: 29 additions & 3 deletions src/qt/forms/overviewpage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,14 @@
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<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="0">
<item row="5" column="0">
<widget class="QLabel" name="labelTotalText">
<property name="text">
<string>Total:</string>
Expand Down Expand Up @@ -183,7 +183,33 @@
</property>
</widget>
</item>
<item row="4" column="1">
<item row="3" column="1">
<widget class="QLabel" name="labelNonMempool">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
</property>
<property name="toolTip">
<string>Balance for wallet transactions not in the mempool</string>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: I think the tooltip text doesn't tell the user what that means in practice, or why it's negative...

Suggested change
<string>Balance for wallet transactions not in the mempool</string>
<string>Balance about to be spent by wallet transactions not currently in the mempool. May never confirm.</string>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think "about to be spent" and "may never confirm" are mutually contradictory.

"Not in the mempool" describes what's going on, I think "violates local node policy" would accurately describe the "why" (conflicting with txs in the mempool should show up differently iirc), but I'm not sure that's much more helpful -- if you want to act on the information you need a lot more context/details: it could just be that other txs need to confirm first (cluster/ancestor limits), it could be that you've deliberately set datacarriersize limits and could change them to let the tx into your mempool, it could be that you've somehow gotten a tx in your wallet that violates unconfigurable policies (perhaps via a different bitcoind version?).

Saying something simple and google-able like "not in the mempool" and letting users get more information from either docs or an AI agent or similar seems like the best approach to me, fwiw.

</property>
<property name="text">
<string notr="true">0.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="3" column="0">
<widget class="QLabel" name="labelNonMempoolText">
<property name="text">
<string>Non-mempool:</string>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

just a silly feel-free-to-ignore nit: in the rpc we use nonmempool no non_mempool. Maybe we don't want to use the - for consistency?

Also maybe mempool can be tooo techincal for some users? What about Pending (unbroadcast) or something similar?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I was thinking the same and have expressed it in my previous comment but I've checked in the code and it seems that unbroadcast has a different meaning I think (transactions that ARE in the mempool but haven't been relayed to peers yet - m_unbroadcast_txids in txmempool.h), and for the pending section, there's a key difference: Pending = mempool → almost certain to confirm soon; Non-mempool = might never confirm, so it would be also misleading.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe non-standard and then add a ? icon next to it, if putting the mouse on top it shows a small explanation? IIRC we used that ? in the past for some rbf comments.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The label has a tooltip already, I left a suggestion there.

</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="labelTotal">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
Expand Down
10 changes: 9 additions & 1 deletion src/qt/overviewpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,20 @@ void OverviewPage::setBalance(const interfaces::WalletBalances& balances)
ui->labelBalance->setText(BitcoinUnits::formatWithPrivacy(unit, balances.balance, BitcoinUnits::SeparatorStyle::ALWAYS, m_privacy));
ui->labelUnconfirmed->setText(BitcoinUnits::formatWithPrivacy(unit, balances.unconfirmed_balance, BitcoinUnits::SeparatorStyle::ALWAYS, m_privacy));
ui->labelImmature->setText(BitcoinUnits::formatWithPrivacy(unit, balances.immature_balance, BitcoinUnits::SeparatorStyle::ALWAYS, m_privacy));
ui->labelTotal->setText(BitcoinUnits::formatWithPrivacy(unit, balances.balance + balances.unconfirmed_balance + balances.immature_balance, BitcoinUnits::SeparatorStyle::ALWAYS, m_privacy));
ui->labelNonMempool->setText(BitcoinUnits::formatWithPrivacy(unit, balances.nonmempool_balance, BitcoinUnits::SeparatorStyle::ALWAYS, m_privacy));
ui->labelTotal->setText(BitcoinUnits::formatWithPrivacy(unit, balances.balance + balances.unconfirmed_balance + balances.immature_balance + balances.nonmempool_balance, BitcoinUnits::SeparatorStyle::ALWAYS, m_privacy));

@pablomartin4btc pablomartin4btc Jun 25, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: the non-mempool balance is currently a plain text with no visual emphasis, perhaps since it's always negative, it should be red (like negative amounts in the transaction list)... (haven't tested it)

Suggested change
ui->labelTotal->setText(BitcoinUnits::formatWithPrivacy(unit, balances.balance + balances.unconfirmed_balance + balances.immature_balance + balances.nonmempool_balance, BitcoinUnits::SeparatorStyle::ALWAYS, m_privacy));
ui->labelNonMempool->setStyleSheet("QLabel { color: " + COLOR_NEGATIVE.name() + "; }");
ui->labelTotal->setText(BitcoinUnits::formatWithPrivacy(unit, balances.balance + balances.unconfirmed_balance + balances.immature_balance + balances.nonmempool_balance, BitcoinUnits::SeparatorStyle::ALWAYS, m_privacy));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Taken in #952 if you want to review

// only show immature (newly mined) balance if it's non-zero, so as not to complicate things
// for the non-mining users
bool showImmature = balances.immature_balance != 0;

ui->labelImmature->setVisible(showImmature);
ui->labelImmatureText->setVisible(showImmature);

// likewise for non-mempool balances
bool showNonMempool = balances.nonmempool_balance != 0;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

maybe < 0 ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think it's better to show the figure if it somehow ends up being positive (due to a bug or some future change) -- hiding surprising values is bad for auditability.


ui->labelNonMempool->setVisible(showNonMempool);
ui->labelNonMempoolText->setVisible(showNonMempool);
}

void OverviewPage::setClientModel(ClientModel *model)
Expand Down Expand Up @@ -296,5 +303,6 @@ void OverviewPage::setMonospacedFont(const QFont& f)
ui->labelBalance->setFont(f);
ui->labelUnconfirmed->setFont(f);
ui->labelImmature->setFont(f);
ui->labelNonMempool->setFont(f);
ui->labelTotal->setFont(f);
}
2 changes: 1 addition & 1 deletion src/qt/test/wallettests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ void TestGUI(interfaces::Node& node, const std::shared_ptr<CWallet>& wallet)
OverviewPage overviewPage(platformStyle.get());
overviewPage.setWalletModel(&walletModel);
walletModel.pollBalanceChanged(); // Manual balance polling update
CompareBalance(walletModel, walletModel.wallet().getBalance(), overviewPage.findChild<QLabel*>("labelBalance"));
CompareBalance(walletModel, walletModel.wallet().getBalances().balance, overviewPage.findChild<QLabel*>("labelBalance"));

// Check Request Payment button
ReceiveCoinsDialog receiveCoinsDialog(platformStyle.get());
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ class WalletImpl : public Wallet
}
WalletBalances getBalances() override
{
const auto bal = GetBalance(*m_wallet);
const auto bal = GetBalance(*m_wallet, /*min_depth=*/0, /*avoid_reuse=*/true, /*include_nonmempool=*/true);
WalletBalances result;
result.balance = bal.m_mine_trusted;
result.unconfirmed_balance = bal.m_mine_untrusted_pending;
Expand Down
Loading