Skip to content

Use bitcoin::Amount everywhere #1432

@ValuedMammal

Description

@ValuedMammal

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)

Metadata

Metadata

Assignees

Labels

discussionThere's still a discussion ongoing

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions