-
Notifications
You must be signed in to change notification settings - Fork 338
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Use bitcoin::Amount
everywhere
#1432
Comments
I still like the idea of using |
I might be biased, but I think that using It internally adopts
I understand that on both scenarios we are reinventing the wheel, and even at a loss of all the conversions between denominations and error treatment already implemented on |
Using edit: I think we can use |
292ec3c refactor(wallet): use `Amount` everywhere (valued mammal) Pull request description: This is a followup to #1426 that refactors wallet internals to use `bitcoin::Amount` (nearly) everywhere. I chose not to change any public types in `coin_selection.rs` that still use `u64` as that might require more discussion. partially addresses #1432 fixes #1434 ### 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 ACKs for top commit: oleonardolima: ACK 292ec3c notmandatory: ACK 292ec3c Tree-SHA512: e84c543e796e151803321ad238023bd5f446448b4430dd6c62929180d159ee1ef867e98f69a4ef3b152c3146b8e30bbf01ce7952ac00b726847a224dca7e3be4
Fixed by #1595. If we want to do the same in other places (like coin selection) please open new PR. |
It was decided initially to only include
bitcoin::Amount
at the API boundary. No doubt this makes for a better UX. Would it be worth replacing all satoshi amounts represented internally asu64
with theAmount
type?One concern would be: why introduce an abstraction over the denomination when sats are already the standard used throughout the library, but it's possible this fear is overblown.
Alternatives:
pub type Satoshis = u64;
However this serves no real purpose at the type level other than to enhance readability.Amount
. The problem with this is re-inventing the wheel when theAmount
type already exists.So with respect to the internals we should either use
Amount
everywhere or (almost) nowhere, which seems to be similarly expressed here #823 (comment)The text was updated successfully, but these errors were encountered: