diff --git a/litewallet/ViewModels/Transaction.swift b/litewallet/ViewModels/Transaction.swift index 8dc0b840..d27bdb97 100644 --- a/litewallet/ViewModels/Transaction.swift +++ b/litewallet/ViewModels/Transaction.swift @@ -40,7 +40,11 @@ class Transaction { self.fee = fee + opsAmount let amountReceived = wallet.amountReceivedFromTx(tx) - let amountSent = wallet.amountSentByTx(tx) - opsAmount + + // This ensures that amountSent is always non-negative and within the valid range for UInt64. + let amountSent = wallet.amountSentByTx(tx) > opsAmount + ? wallet.amountSentByTx(tx) - opsAmount + : 0 if amountSent > 0, (amountReceived + fee) == amountSent { direction = .moved