-
Notifications
You must be signed in to change notification settings - Fork 329
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
Get balance in categories #640
Get balance in categories #640
Conversation
I have not added tests since I feel that existing test should be fine. I can add some if need be. |
f04341b
to
13e9ce5
Compare
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
- Some tests are failing, run them with
cargo test --features test-electrum
andcargo test --features test-rpc
- You should update the
CHANGELOG.md
- You should add tests! Some ideas:
- Receive a transaction, check that the output values get counted in the
untrusted_pending
, get it confirmed, check that now the amount is inavailable
- Make a transaction, check that the change value is counted in
trusted_pending
, get it confirmed, check that now the amount is inavailable
- Receive a transaction, check that the output values get counted in the
7e7d25a
to
ae5271a
Compare
Can you rebase to pick up the CI fixes (#638)? Thanks :) |
d91b8fa
to
4f052fe
Compare
4f052fe
to
ac23fa3
Compare
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
I'm very excited for these changes, and great work!
I just have some thoughts on naming conventions and some changes in logic. Haven't really gone through everything yet though.
In regards to naming conventions, may need various second opinions.
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone, Default)] | ||
pub struct Balance { | ||
/// All coinbase outputs not yet matured | ||
pub immature: u64, |
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.
Would immature_coinbase
be clearer? Or too wordy? 😅
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 feel immature
coins are only ever meant in regards to coinbase coins, so I think it would be a bit too wordy. I thought of these names as if they had a imaginary "balance" or "coins" added at the end of them.
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.
That's an interesting point. If a coin is un-spendable due to a script-level timelock (such as OP_CLTV or OP_CSV) would we also use the term immature?
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.
That's an interesting point. If a coin is un-spendable due to a script-level timelock (such as OP_CLTV or OP_CSV) would we also use the term immature?
Not at the moment! But I should open an issue to remember this. Also see #640 (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.
......which means that maybe immature coinbase is clearer...
FYI: #614 got merged, so you can rebase on master to pickup the latest changes. It also looks like there are some conflicts, so during the rebase you'll get a chance to fix them as well. EDIT: I think the conflicts mostly come from the two commits you have in your branch from the old version of #614, so just dropping those and rebasing on master should fix everything. |
4ec63e4
to
74def0a
Compare
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.
tACK 74def0a
74def0a
to
779a5d3
Compare
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 hate to make you go through another round of fixing and rebasing but I swear, this is gonna be the last one!
The code looked great to me now, no complains there.
bde59df
to
62e6b04
Compare
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.
ACK 62e6b04
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.
ACK 62e6b04
However, just a thought...
For tests that require checking balance, would it make sense to compare with the whole Balance
struct?
For example:
assert_eq!(wallet.get_balance().unwrap(), Balance{ .. })
But I hate to be the one that delays merging, maybe we can have this as another task for another PR?
Otherwise, I've gone through everything and it all looks dandy to me :)
62e6b04
to
9c1d769
Compare
This needs rebasing to fix the conflicts. One small note: please, when you've updated the code, can you click "resolve conversation" under the comments? This way the whole PR is way more readable. I've done it for you this time, I hope I didn't accidentally solve something that wasn't solved... |
8c626d4
to
2c20ecd
Compare
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.
Just a tiny nit. Me and Alekos have been recently talking about lacking test coverage (mainly after we discovered #666 😈 ), and we realize that we should definitely be more nit-picker on tests. Sorry to delay merging even more, but I promise we're close!
2c20ecd
to
b9a5e5b
Compare
f3bb345
to
b86b3aa
Compare
34fce23
to
fb7845c
Compare
Add type balance with add, display traits. Change affected tests. Update `CHANGELOG.md`
fb7845c
to
0f03831
Compare
Rebased |
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.
ACK 0f03831
3c6075a Add Balance struct and conversion from BdkBalance (thunderbiscuit) 4e15bad Update BDK to version 0.22 (thunderbiscuit) Pull request description: The bindings do not build when attempting this upgrade because `get_balance()` now returns a `Balance` struct (this was merged in bitcoindevkit/bdk#640) ```sh error[E0308]: mismatched types --> src/lib.rs:433:9 | 432 | fn get_balance(&self) -> Result<u64, Error> { | ------------------ expected `Result<u64, bdk::Error>` because of return type 433 | self.get_wallet().get_balance() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u64`, found struct `Balance` | = note: expected enum `Result<u64, _>` found enum `Result<Balance, _>` For more information about this error, try `rustc --explain E0308`. error: could not compile `bdk-ffi` due to previous error ``` When we upgrade to `0.22.0` we could decide to add the `Balance` struct to the bindings, or simply return the total by calling `get_total()`, which returns a `u64` (same as we have now). ACKs for top commit: notmandatory: ACK 3c6075a Tree-SHA512: 13d2f83f992735f4f9619ae339d7834df08385129edf06bac830c298b433571af3f211e92a6da1f4f9646dec27dbd2c6133a035f26eac8757b7a1c94b54b463d
Description
This changes
get_balance()
function so that it returns balance separated in 4 categories:Fixes #238
Notes to the reviewers
Based on #614
Checklists
All Submissions:
cargo fmt
andcargo clippy
before committingNew Features:
CHANGELOG.md