bdk icon indicating copy to clipboard operation
bdk copied to clipboard

TxGraph::balance's API is too complicated

Open LLFourn opened this issue 2 years ago • 1 comments

  pub fn try_balance<C: ChainOracle, OI: Clone>(
        &self,
        chain: &C,
        chain_tip: BlockId,
        outpoints: impl IntoIterator<Item = (OI, OutPoint)>,
        mut trust_predicate: impl FnMut(&OI, &Script) -> bool,
    ) -> Result<Balance, C::Error> {

OI is unnecessary. The caller passes it to us and then we query it. It can just be:

    pub fn try_balance<C: ChainOracle>(
        &self,
        chain: &C,
        chain_tip: BlockId,
        outpoints: impl IntoIterator<Item = OutPoint>,
        mut trust_predicate: impl FnMut(&OutPoint, &Script) -> bool,
    ) -> Result<Balance, C::Error> {

If the caller wants to know the value of OI in trust predicate it can just look it up itself via the OutPoint.

LLFourn avatar Jan 15 '24 06:01 LLFourn

Probably a small change but I think we should push to 2.0 milestone.

notmandatory avatar Mar 20 '24 02:03 notmandatory