Avoids crashing due to illegal zap address
This commit is contained in:
+22
-18
@@ -55,28 +55,32 @@ class LightningAddressResolver() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
withContext(Dispatchers.IO) {
|
try {
|
||||||
val request: Request = Request.Builder()
|
withContext(Dispatchers.IO) {
|
||||||
.header("User-Agent", "Amethyst/${BuildConfig.VERSION_NAME}")
|
val request: Request = Request.Builder()
|
||||||
.url(url)
|
.header("User-Agent", "Amethyst/${BuildConfig.VERSION_NAME}")
|
||||||
.build()
|
.url(url)
|
||||||
|
.build()
|
||||||
|
|
||||||
client.newCall(request).enqueue(object : Callback {
|
client.newCall(request).enqueue(object : Callback {
|
||||||
override fun onResponse(call: Call, response: Response) {
|
override fun onResponse(call: Call, response: Response) {
|
||||||
response.use {
|
response.use {
|
||||||
if (it.isSuccessful) {
|
if (it.isSuccessful) {
|
||||||
onSuccess(it.body.string())
|
onSuccess(it.body.string())
|
||||||
} else {
|
} else {
|
||||||
onError("Could not resolve $lnaddress. Error: ${it.code}. Check if the server up and if the lightning address $lnaddress is correct")
|
onError("Could not resolve $lnaddress. Error: ${it.code}. Check if the server up and if the lightning address $lnaddress is correct")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
override fun onFailure(call: Call, e: java.io.IOException) {
|
override fun onFailure(call: Call, e: java.io.IOException) {
|
||||||
onError("Could not resolve $url. Check if the server up and if the lightning address $lnaddress is correct")
|
onError("Could not resolve $url. Check if the server up and if the lightning address $lnaddress is correct")
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
onError("Could not resolve $url. Check if the server up and if the lightning address $lnaddress is correct")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user