From a9572047b9794ab2e01c366d00007f9437cff98c Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 28 Sep 2026 03:45:43 +0000 Subject: [PATCH] fix(cashu): drop the JVM-only HashMap.putIfAbsent from commonMain CashuMintOperations.checkProofStates used java.util.HashMap.putIfAbsent, which the commonMain metadata compile rejects. The map is local and single-threaded, so an explicit contains-then-set keeps the same first-secret-wins behaviour. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01S7FuNBSKiyVecARSoE4B9P --- .../quartz/nip60Cashu/mintApi/CashuMintOperations.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip60Cashu/mintApi/CashuMintOperations.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip60Cashu/mintApi/CashuMintOperations.kt index 024413a720..ca15286ab7 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip60Cashu/mintApi/CashuMintOperations.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip60Cashu/mintApi/CashuMintOperations.kt @@ -687,10 +687,13 @@ class CashuMintOperations( val ys = ArrayList(proofs.size) proofs.forEach { proof -> val y = Bdhke.hashToCurveCompressed(proof.secret.encodeToByteArray()).toHexKey() - // putIfAbsent: two proofs can legitimately carry the same secret + // First one wins: two proofs can legitimately carry the same secret // (a duplicated kind:7375 the dedup pass hasn't retired yet), and // they map to the same state anyway. - if (secretByY.putIfAbsent(y, proof.secret) == null) ys.add(y) + if (y !in secretByY) { + secretByY[y] = proof.secret + ys.add(y) + } } val out = HashMap(secretByY.size)