Skip to content

@armada/sdk / index / computeBalances

Function: computeBalances()

computeBalances(txos, spentNullifiers, nullifyingKey, options): TokenBalance[]

Defined in: src/sync/balances.ts:86

Aggregate a wallet's TXOs into per-token spendable/pending balances.

  • A TXO is spent (contributes to neither) iff its tree-scoped nullifier (txo.tree, getNullifier(nullifyingKey, txo.position)) appears in spentNullifiers.
  • An unspent TXO is spendable once it has at least finalityThreshold confirmations (blockNumber <= currentBlock - finalityThreshold), otherwise pending.

Pure and deterministic: output is sorted by tokenHash.

Parameters

txos

readonly TXO[]

spentNullifiers

readonly SpentNullifier[]

nullifyingKey

bigint

options

BalanceOptions

Returns

TokenBalance[]