-
Notifications
You must be signed in to change notification settings - Fork 321
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
feat: update keychain::Balance
to use bitcoin::Amount
#1411
feat: update keychain::Balance
to use bitcoin::Amount
#1411
Conversation
0e6d7e5
to
ae54551
Compare
wallet::Balance
to use bitcoin::Amount
keychain::Balance
to use bitcoin::Amount
736495f
to
fe5e313
Compare
5aa1990
to
82b2ae5
Compare
keychain::Balance
to use bitcoin::Amount
keychain::Balance
to use bitcoin::Amount
I think it's ready for a new round of reviews I'll move the previous conversations to resolved after it, and if it's everything looks good on this new review round) |
Can you move it from Draft PR to a full PR? |
82b2ae5
to
06d3d96
Compare
Yes, forgot to do it |
|
423aed4
to
df4cdfe
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.
Some suggestions.
Most important, why we are using SignedAmount
in some places?
df4cdfe
to
362a67a
Compare
It's because net_value used i64 previously, and to keep the standard (and makes sense in my opinion given the fn name) I used the SignedAmount, same for the other comments, they are all net_value references. (replying on the overall comment too) |
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 362a67a
Great work!
362a67a
to
c0b0e14
Compare
c0b0e14
to
bd41a0c
Compare
bd41a0c
to
df92624
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.
Sorry my reviews have been intermittent. I think this is good.
The commit history could be cleaned up slightly:
-
In df92624 we want to refer to
TxBuilder::add_recipient
(not CoinSelectionAlgorithm) -
Some changes in later commits (like fixing imports and wallet examples) could be squashed into earlier ones, but this not a blocker in my opinion.
Some other thoughts: I agree there is potentially more to do like updating calculate_fee
and Psbt::fee_amount
to use Amount
. I'm still unsure how we should handle amounts internally. Honestly I don't mind leaving it as u64
. If we decide that all amounts should be strongly typed, then Amount
seems like a logical choice, my only concern is we should avoid the possibility of mixing up denominations.
86bbd79
to
234ab88
Compare
- update all fields `immature`, ` trusted_pending`, `unstrusted_pending` and `confirmed` to use the `bitcoin::Amount` instead of `u64` - update all `impl Balance` methods to use `bitcoin::Amount` - update all tests that relies on `keychain::Balance`
234ab88
to
2e6aeb7
Compare
@ValuedMammal No worries, thanks for the comments and suggestions! I tried to address them, please let me know if something remains or if new needed changes appear. |
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 2e6aeb7
Actually, changing |
- update `wallet.rs` fns: `sent_and_received` fn - update `keychain` `txout_index` fn: `sent_and_received and `net_value`
2e6aeb7
to
22aa534
Compare
I updated I would rather move this commit ac762f4 to another PR, and keep only the previous ones here, wdyt ? |
ac762f4
to
22aa534
Compare
I moved it to the other PR #1426, we can start discussing the changes on that one after this one is merged. |
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 22aa534
a03949a feat: use `Amount` on `calculate_fee`, `fee_absolute`, `fee_amount` and others (Leonardo Lima) Pull request description: builds on top of #1411, further improves #823 <!-- You can erase any parts of this template not applicable to your Pull Request. --> ### Description It further updates and adds the usage of `bitcoin::Amount` instead of `u64`. <!-- Describe the purpose of this PR, what's being adding and/or fixed --> ### Notes to the reviewers Open for comments and discussions. <!-- In this section you can include notes directed to the reviewers, like explaining why some parts of the PR were done in a specific way --> ### Changelog notice - Updated `CreateTxError::FeeTooLow` to use `bitcoin::Amount`. - Updated `Wallet::calculate_fee()`. to use `bitcoin::Amount` - Updated `TxBuilder::fee_absolute()`. to use `bitcoin::Amount`. - Updated `CalculateFeeError::NegativeFee` to use `bitcoin::SignedAmount`. - Updated `TxGraph::calculate_fee()`. to use `bitcoin::Amount`. - Updated `PsbUtils::fee_amount()` to use `bitcoin::Amount`. <!-- Notice the release manager should include in the release tag message changelog --> <!-- See https://keepachangelog.com/en/1.0.0/ for examples --> ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing #### New Features: * [x] I've added tests for the new feature * [x] I've added docs for the new feature ACKs for top commit: storopoli: ACK a03949a Tree-SHA512: abfbf7d48ec004eb448ed0a928e7e64b5f82a2ab51ec278fede4ddbff4eaba16469a7403f78dfeba1aba693b0132a528bc7c4ef072983cbbcc2592993230e40f
fixes #823
Description
It's being used on
Balance
, and throughout the code, anu64
represents the amount, which relies on the user to infer its sats, not millisats, or any other representation.It updates the usage of
u64
onBalance
, and other APIs:TxParams::add_recipient
KeyChainTxOutIndex::sent_and_received
,KeyChainTxOutIndex::net_value
SpkTxOutIndex::sent_and_received
,SpkTxOutIndex::net_value
Notes to the reviewers
It updates some of the APIs to expect the
bitcoin::Amount
, but it does not update internal usage of u64, such asTxParams
still expects and usesu64
, please see the PR comments for related discussion.Changelog notice
keychain::Balance
struct fields to useAmount
instead ofu64
.add_recipient
method onTxBuilder
implementation to expectbitcoin::Amount
.sent_and_received
, andnet_value
methods onKeyChainTxOutIndex
to expectbitcoin::Amount
.sent_and_received
, andnet_value
methods onSpkTxOutIndex
to expectbitcoin::Amount
.Checklists
All Submissions:
cargo fmt
andcargo clippy
before committingNew Features:
Bugfixes: