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 as u64 with the Amount 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:
- Use a type alias such as
pub type Satoshis = u64; However this serves no real purpose at the type level other than to enhance readability.
- Use a custom new type and provide conversions to/from
Amount. The problem with this is re-inventing the wheel when the Amount 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)
It was decided initially to only include
bitcoin::Amountat the API boundary. No doubt this makes for a better UX. Would it be worth replacing all satoshi amounts represented internally asu64with theAmounttype?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 theAmounttype already exists.So with respect to the internals we should either use
Amounteverywhere or (almost) nowhere, which seems to be similarly expressed here #823 (comment)