Skip to content

refactor: Unify balances between wallet and SPV #336

@xdustinface

Description

@xdustinface

We currently have AddressBalance in dash-spv and WalletBalance in key-wallet. They differ slightly with the SPV one considering instant locks. We should probably have a single balance structure in the wallet which covers everything and gets used from the SPV client.

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct AddressBalance {
/// Confirmed balance (6+ confirmations or InstantLocked).
pub confirmed: dashcore::Amount,
/// Unconfirmed balance (less than 6 confirmations).
pub unconfirmed: dashcore::Amount,
/// Pending balance from mempool transactions (not InstantLocked).
pub pending: dashcore::Amount,
/// Pending balance from InstantLocked mempool transactions.
pub pending_instant: dashcore::Amount,
}

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct WalletBalance {
/// Confirmed and mature balance (UTXOs with enough confirmations to be spendable)
spendable: u64,
/// Unconfirmed balance (UTXOs without confirmations)
unconfirmed: u64,
/// Locked balance (UTXOs reserved for specific purposes like CoinJoin)
locked: u64,
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions