diff --git a/app/src/main/java/com/bitchat/android/nostr/RelayDirectory.kt b/app/src/main/java/com/bitchat/android/nostr/RelayDirectory.kt index 980b95ef..13bafce2 100644 --- a/app/src/main/java/com/bitchat/android/nostr/RelayDirectory.kt +++ b/app/src/main/java/com/bitchat/android/nostr/RelayDirectory.kt @@ -88,10 +88,10 @@ object RelayDirectory { fun closestRelaysForGeohash(geohash: String, nRelays: Int): List { val snapshot = synchronized(relaysLock) { relays.toList() } if (snapshot.isEmpty()) return emptyList() - val center = try { - val c = com.bitchat.android.geohash.Geohash.decodeToCenter(geohash) - c - } catch (e: Exception) { + // An empty or malformed geohash decodes to (0, 0), which would pick the + // relays closest to the Gulf of Guinea rather than declining to choose. + val center = com.bitchat.android.geohash.Geohash.decodeToCenterOrNull(geohash) + if (center == null) { Log.e(TAG, "Failed to decode geohash") return emptyList() }