computeBalanceFromVisualList function

BigInt computeBalanceFromVisualList({
  1. required Iterable<UTXOTransaction> txList,
})

Implementation

BigInt computeBalanceFromVisualList({
  required Iterable<UTXOTransaction> txList,
}) {
  BigInt balance = BigInt.zero;
  for (final tx in txList) {
    if (tx.transferMethod == TransactionTransferMethod.receive) {
      balance += tx.value;
    }

    if (tx.transferMethod == TransactionTransferMethod.send) {
      balance -= tx.value;
    }
  }
  return balance;
}