mirror of
https://github.com/ACINQ/eclair.git
synced 2025-02-22 06:21:42 +01:00
better handle bad bitcoind rpc credentials (see #21)
This commit is contained in:
parent
3fc25da461
commit
810fe1fc99
1 changed files with 3 additions and 1 deletions
|
@ -6,7 +6,7 @@ import akka.actor.ActorSystem
|
|||
import akka.http.scaladsl.Http
|
||||
import akka.http.scaladsl.marshalling.Marshal
|
||||
import akka.http.scaladsl.model.headers.{Authorization, BasicHttpCredentials}
|
||||
import akka.http.scaladsl.model.{HttpMethods, HttpRequest, RequestEntity, Uri}
|
||||
import akka.http.scaladsl.model._
|
||||
import akka.http.scaladsl.unmarshalling.Unmarshal
|
||||
import akka.stream.ActorMaterializer
|
||||
import de.heikoseeberger.akkahttpjson4s.Json4sSupport._
|
||||
|
@ -39,6 +39,8 @@ class BitcoinJsonRPCClient(user: String, password: String, host: String = "127.0
|
|||
jsonRpcRes <- Unmarshal(httpRes).to[JsonRPCResponse].map {
|
||||
case JsonRPCResponse(_, Some(error), _) => throw JsonRPCError(error)
|
||||
case o => o
|
||||
} recover {
|
||||
case t: Throwable if httpRes.status == StatusCodes.Unauthorized => throw new RuntimeException("bitcoind replied with 401/Unauthorized (bad user/password?)", t)
|
||||
}
|
||||
} yield jsonRpcRes.result
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue