Skip to content

Balance should use bitcoin::Amount #823

@tnull

Description

@tnull

Describe the bug
Currently, the Balance type returned by get_balance() only uses non-descript u64s, while not even stating a denomination anywhere in the documentation (I assume it's sats?). To avoid any confusion and make this much less error prone BDK should reuse the Amount type provided by rust-bitcoin.

Also, the documentation could generally be improved, e.g., clarifying what exactly it means that some funds are immature/trusted_pending/untrusted_pending/confirmed.

To Reproduce
Call Wallet::get_balance().

Expected behavior
Receive a meaningful return value.

Additional context
This is in particular confusing since similar u64 values are used in the Lightning space very often to denominate millisatoshis. It's best practice to append _msat to the names of such variables, which however still doesn't make use of the type system to avoid any conversion errors (we can't, as Amount doesn't allow to express millisatoshis). As BDK doesn't have to deal with millisatoshis, it really should make use of Amount here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions