-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Wallet: (Refactor) GetBalance to calculate used balance #29062
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
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/29062. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
pablomartin4btc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK
src/wallet/receive.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have it always compute the used balance for us rather than having the caller do this extra computation.
My understanding of this part of @achow101 comment was to move the calculation for the used balance to GetBalance(...)
I have updated the PR and added GetFullBalance() which adds used balance to GetBalance(...)
19437c3 to
6a0272b
Compare
6a0272b to
c69dd7b
Compare
src/wallet/receive.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be in the above if so that the min_depth check is still being done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bitcoin/src/wallet/rpc/coins.cpp
Line 480 in a46065e
| const auto full_bal = GetBalance(wallet, 0, false); |
My understanding from the above line is min_depth should be zero when calculating full_balance hence I didn't include the statement below in the above if since it uses min_depth provided by the caller
I didn't include the check in this if since tx_depth is always >= 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it makes sense to return m_mine_used without respecting min_depth. The original code passes 0 for min_depth because that is the default value but it needs to pass the avoid_reuse flag. It is not because used balance should always calculated with a min depth of 0. Ignoring it is a layer violation here.
c69dd7b to
1cc2a81
Compare
| if (is_trusted && tx_depth >= min_depth) { | ||
| ret.m_mine_trusted += tx_credit_mine; | ||
| ret.m_watchonly_trusted += tx_credit_watchonly; | ||
| ret.m_mine_used -= tx_credit_mine; // remove overlap from used_balance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the avoid_reuse flag is passed, tx_credit_mine and tx_credit_mine_used will be the same so the returned used_balance will be 0. That seems incorrect.
|
Moved to draft, given this doesn't seem to be active. @BrandonOdiwuor are you still working on this? |
|
🐙 This pull request conflicts with the target branch and needs rebase. |
|
Closing this as it has not had any activity in a while. If you are interested in continuing work on this, please leave a comment so that it can be reopened. |
Add
GetFullBalance()to computeusedbalance ingetbalances RPCand on GUI GUI PR #775Check #28776 (comment) by @achow101
Update:
usedbalance fromGetBalance(...)