Skip to content

Commit

Permalink
fix: account can be nil when switching networks for example
Browse files Browse the repository at this point in the history
  • Loading branch information
pankcuf committed Jul 13, 2024
1 parent 0a12f21 commit dc8ba2c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion DashSyncCurrentCommit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6a056858c65b46d4bc0a9c52c9d892688153799d
751595434308e0761cceb15b428a41ca5eefdb8b
14 changes: 6 additions & 8 deletions DashWallet/Sources/Categories/DSTransaction+DashWallet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ extension DSTransaction {
let direction = direction

switch direction {
case .moved:
case .notAccountFunds, .moved:
amount = 0
case .sent:
let amountSent = chain.amountSent(by: self)
Expand All @@ -54,9 +54,7 @@ extension DSTransaction {
let fee = feeUsed == UInt64.max ? 0 : feeUsed
amount = amountSent - amountReceived - fee
case .received:
amount = account!.amountReceived(from: self)
case .notAccountFunds:
amount = 0
amount = account?.amountReceived(from: self) ?? 0
@unknown default:
fatalError()
}
Expand Down Expand Up @@ -96,7 +94,7 @@ extension DSTransaction {

switch direction {
case .moved, .sent, .received:
outputReceiveAddresses = account!.externalAddresses(of: self)
outputReceiveAddresses = account?.externalAddresses(of: self) ?? []
default:
break
}
Expand Down Expand Up @@ -229,10 +227,10 @@ extension DSTransactionDirection {
return .dw_quaternaryText()
case .sent:
return .dw_darkTitle()
case .received:
return .dw_dashBlue()
case .notAccountFunds:
case .received, .notAccountFunds:
return .dw_dashBlue()
@unknown default:
fatalError()
}
}
}

0 comments on commit dc8ba2c

Please sign in to comment.