lib: add account filtering for balance calculation

This commit is contained in:
Oscar Mira 2024-02-28 01:25:54 +01:00
parent ec27aa42d4
commit c28b40899d

View File

@ -23,12 +23,14 @@ data class Balance(
}
}
fun Iterable<TimeLocked<Enote>>.calculateBalance(): Balance {
fun Iterable<TimeLocked<Enote>>.calculateBalance(
accountFilter: (owner: AccountAddress) -> Boolean = { true },
): Balance {
val lockedAmounts = mutableListOf<TimeLocked<MoneroAmount>>()
var pendingAmount = MoneroAmount.ZERO
for (timeLocked in filter { !it.value.spent }) {
for (timeLocked in filter { !it.value.spent && accountFilter(it.value.owner) }) {
if (timeLocked.value.age == 0) {
pendingAmount += timeLocked.value.amount
} else {