but it should be LnurlError.RemoteFailure.Detailed(reason = "Withdraw is spent.")
The problem is that we weren't properly following the LUD-01 spec:
HTTP Status Codes and Content-Type:
Neither status codes or any HTTP Header has any meaning. Servers may use whatever they want. Clients should ignore them (and be careful when using libraries that treat responses differently based on headers and status codes) and just parse the response body as JSON, then interpret it accordingly.
So even though the server returns a 404, since it also returns a valid JSON (that matches the spec with status=error & reason=string), we should be returning the given reason as a RemoteFailure.Detailed.
Fixes issue #468
Initially this looked like a bug specific to iOS. But I found another problem in the shared kotlin layer:
The error returned from the referenced lnurl:
LnurlError.RemoteFailure.Code(code = 404)
LnurlError.RemoteFailure.Detailed(reason = "Withdraw is spent.")
The problem is that we weren't properly following the LUD-01 spec:
So even though the server returns a 404, since it also returns a valid JSON (that matches the spec with
status=error
&reason=string
), we should be returning the given reason as aRemoteFailure.Detailed
.