From 2dd3da33349ef430fe4de03af17d1f860b417304 Mon Sep 17 00:00:00 2001 From: Vlad Kozarez Date: Fri, 17 Nov 2023 16:39:51 +0300 Subject: [PATCH] AND-5295 utxo history amount calculation --- .../bitcoin/BitcoinTransactionHistoryProvider.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/blockchain/src/main/java/com/tangem/blockchain/blockchains/bitcoin/BitcoinTransactionHistoryProvider.kt b/blockchain/src/main/java/com/tangem/blockchain/blockchains/bitcoin/BitcoinTransactionHistoryProvider.kt index d6eef89d5..1c14ed03f 100644 --- a/blockchain/src/main/java/com/tangem/blockchain/blockchains/bitcoin/BitcoinTransactionHistoryProvider.kt +++ b/blockchain/src/main/java/com/tangem/blockchain/blockchains/bitcoin/BitcoinTransactionHistoryProvider.kt @@ -150,11 +150,13 @@ internal class BitcoinTransactionHistoryProvider( outputs + fee } else { val outputs = tx.vout - .find { it.addresses?.contains(walletAddress) == true} - ?.value.toBigDecimalOrDefault() + .filter { it.addresses?.contains(walletAddress) == true } + .map { it.value.toBigDecimalOrDefault() } + .sumOf { it } val inputs = tx.vin - .find { it.addresses?.contains(walletAddress) == true } - ?.value.toBigDecimalOrDefault() + .filter { it.addresses?.contains(walletAddress) == true } + .map { it.value.toBigDecimalOrDefault() } + .sumOf { it } outputs - inputs }