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

Wallet: Functions to enable adding used balance to GUI overview page #28776

Conversation

BrandonOdiwuor
Copy link
Contributor

@BrandonOdiwuor BrandonOdiwuor commented Nov 2, 2023

First Part: Fixes bitcoin-core/gui#769

Functions to enable adding used balance to the overview page for wallets with the avoid_reuse flag

Dependency

Screenshot from 2023-11-02 18-10-06

@DrahtBot
Copy link
Contributor

DrahtBot commented Nov 2, 2023

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

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.

Type Reviewers
Concept ACK katesalazar, pablomartin4btc

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

No conflicts as of last run.

@katesalazar
Copy link
Contributor

Concept ACK

@bitcoin bitcoin deleted a comment from leotese Nov 7, 2023
Copy link
Member

@pablomartin4btc pablomartin4btc left a comment

Choose a reason for hiding this comment

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

Concept ACK

Light CR, left a suggestion if I understand it correctly.

Also, since this is a very small change on the wallet interface, perhaps makes more sense to add this commit first on the GUI PR #775 and would be easier to test the gui as well.

@@ -410,6 +410,11 @@ class WalletImpl : public Wallet
result.unconfirmed_watch_only_balance = bal.m_watchonly_untrusted_pending;
result.immature_watch_only_balance = bal.m_watchonly_immature;
}
if (m_wallet->IsWalletFlagSet(WALLET_FLAG_AVOID_REUSE)) {
const auto full_bal = GetBalance(*m_wallet, 0, false);
Copy link
Member

Choose a reason for hiding this comment

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

GetBalance receives bool avoid_reuse in the last argument, should not be true or just remove the if condition directly and pass the result of IsWalletFlagSet(WALLET_FLAG_AVOID_REUSE) entirely.

Suggested change
const auto full_bal = GetBalance(*m_wallet, 0, false);
const auto full_bal = GetBalance(*m_wallet, 0, true);

Copy link
Member

Choose a reason for hiding this comment

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

That parameter is slightly misleading. When set to true, it will ignore the used balance, so it needs to be false here in order to get the full balance to calculate the used balance. This is what getbalances does.

However, I think it would be better to move all of this into GetBalance itself and just have it always compute the used balance for us rather than having the caller do this extra computation.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, it's clear, I was incorrect in my statement, but what I meant is we could use the flag instead of false (e.g.: GetBalance(*m_wallet, 0, !(m_wallet->IsWalletFlagSet(WALLET_FLAG_AVOID_REUSE)));) and remove the if.

I agree with moving this piece into GetBalance, the other only place where this is called with this argument is in coins.cpp.

@@ -280,6 +280,9 @@ class Wallet
//! Return whether is a legacy wallet
virtual bool isLegacy() = 0;

//Return whether wallet has 'avoid_reuse' flag set
virtual bool isAvoidReuseEnabled() = 0;
Copy link
Member

Choose a reason for hiding this comment

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

Interface functions that are newly introduced or are only called by the GUI can be handled in the GUI repo. Closing for now, this can be moved into the GUI pull.

@maflcko maflcko closed this Apr 9, 2024
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.

used balance should be shown on overview page
6 participants