mirror of
https://github.com/mollyim/monero-wallet-sdk.git
synced 2024-10-01 03:45:36 -04:00
lib: add account filtering for balance calculation
This commit is contained in:
parent
ec27aa42d4
commit
c28b40899d
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user