|
@ -41,6 +41,8 @@ trait XSNService { |
|
|
def getMasternodes(): FutureApplicationResult[List[rpc.Masternode]] |
|
|
def getMasternodes(): FutureApplicationResult[List[rpc.Masternode]] |
|
|
|
|
|
|
|
|
def getMasternode(ipAddress: IPAddress): FutureApplicationResult[rpc.Masternode] |
|
|
def getMasternode(ipAddress: IPAddress): FutureApplicationResult[rpc.Masternode] |
|
|
|
|
|
|
|
|
|
|
|
def getUnspentOutputs(address: Address): FutureApplicationResult[JsValue] |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
class XSNServiceRPCImpl @Inject() ( |
|
|
class XSNServiceRPCImpl @Inject() ( |
|
@ -322,6 +324,29 @@ class XSNServiceRPCImpl @Inject() ( |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override def getUnspentOutputs(address: Address): FutureApplicationResult[JsValue] = { |
|
|
|
|
|
val body = s""" |
|
|
|
|
|
|{ |
|
|
|
|
|
| "jsonrpc": "1.0", |
|
|
|
|
|
| "method": "getaddressutxos", |
|
|
|
|
|
| "params": [ |
|
|
|
|
|
| { "addresses": ["${address.string}"] } |
|
|
|
|
|
| ] |
|
|
|
|
|
|} |
|
|
|
|
|
|""".stripMargin |
|
|
|
|
|
|
|
|
|
|
|
server |
|
|
|
|
|
.post(body) |
|
|
|
|
|
.map { response => |
|
|
|
|
|
val maybe = getResult[JsValue](response) |
|
|
|
|
|
maybe.getOrElse { |
|
|
|
|
|
logger.warn(s"Unexpected response from XSN Server, status = ${response.status}, response = ${response.body}") |
|
|
|
|
|
|
|
|
|
|
|
Bad(XSNUnexpectedResponseError).accumulating |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private def mapError(json: JsValue, errorCodeMapper: Map[Int, ApplicationError]): Option[ApplicationError] = { |
|
|
private def mapError(json: JsValue, errorCodeMapper: Map[Int, ApplicationError]): Option[ApplicationError] = { |
|
|
val jsonErrorMaybe = (json \ "error") |
|
|
val jsonErrorMaybe = (json \ "error") |
|
|
.asOpt[JsValue] |
|
|
.asOpt[JsValue] |
|
|