Skip to content

Reimplement Wallet::balance #15

@ValuedMammal

Description

@ValuedMammal

The Wallet::balance method is currently limited in that you can only assign trust to an indexed script pubkey, however one might reasonably assume that a txout can be trusted if it resides on a transaction where all of the inputs are controlled by the same wallet, and hence not likely to be double-spent unintentionally. One way to approach this is to redefine trust_predicate to operate on a particular outpoint of interest.

Proposed API

/// Compute the wallet balance with the default parameters.
pub fn balance(&self) -> Balance { ... }

/// Compute the wallet balance with canonical params, confirmation threshold, and trust predicate.
pub fn balance_with_params_conf_threshold(
    &self,
    params: CanonicalizationParams,
    conf_threshold: u32,
    trust_predicate: impl Fn(&OutPoint) -> bool,
) -> Balance
{ ... }

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions