taler-ios

iOS apps for GNU Taler (wallet)
Log | Files | Refs | README | LICENSE

commit 96cd8a7fab1aae86dd846a7b89d4ae5dda8cf2a6
parent 345e17aa34550060e3653b1c7bf27be12b2b1fc9
Author: Marc Stibane <marc@taler.net>
Date:   Thu, 20 Aug 2026 19:24:48 +0200

AI: invalid amount handling

Diffstat:
Mtaler-swift/Sources/taler-swift/Amount.swift | 7++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/taler-swift/Sources/taler-swift/Amount.swift b/taler-swift/Sources/taler-swift/Amount.swift @@ -538,7 +538,12 @@ public final class Amount: Codable, Hashable, @unchecked Sendable, CustomStringC return (leftNormalized.integer == rightNormalized.integer && leftNormalized.fraction == rightNormalized.fraction) } catch { - return false + // Normalization failed (invalid amount). `hash(into:)` falls back to the + // raw fields in that case, so compare them here too - otherwise an + // invalid amount is not even equal to itself, which breaks Set/Dictionary. + return left.currency == right.currency + && left.integer == right.integer + && left.fraction == right.fraction } }