Skip to content

Commit

Permalink
Fixed crash Swift runtime failure: arithmetic overflow ()
Browse files Browse the repository at this point in the history
  • Loading branch information
azisramdhan committed Dec 22, 2024
1 parent c3c60fa commit 7703f37
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion litewallet/ViewModels/Transaction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7703f37

Please sign in to comment.