/// <summary> /// Process offchain channel /// </summary> /// <returns></returns> //[HttpPost("processChannel")] --reserved for version 2 //[SwaggerOperation("ProcessChannel")] //[ProducesResponseType(typeof(OffchainTradeRespModel), (int)HttpStatusCode.OK)] //[ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.BadRequest)] //[ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.NotFound)] private async Task <IActionResult> ProcessChannel([FromBody] OffchainChannelProcessModel request) { var clientId = request.ClientId; if (string.IsNullOrEmpty(request.SignedChannelTransaction)) { await LogAndReturnBadRequest(request, ControllerContext, "SignedChannelTransaction must not be empty"); } if (string.IsNullOrEmpty(request.TransferId)) { await LogAndReturnBadRequest(request, ControllerContext, "TransferId must not be empty"); } try { var response = await _offchainService.CreateHubCommitment(clientId, request.TransferId, request.SignedChannelTransaction); return(Ok(new OffchainTradeRespModel { TransferId = response.TransferId, TransactionHex = response.TransactionHex, OperationResult = response.OperationResult })); } catch (OffchainException ex) { return(await LogOffchainExceptionAndReturn(request, ControllerContext, ex)); } catch (Exception ex) { return(await LogAndReturnNotFound(request, ControllerContext, ex.Message)); } }
public async Task <OffchainApiResponse> CreateHubCommitment([FromBody] CreateHubCommitmentModel model) { var asset = await GetAsset(model.Asset); var tr = await _offchain.CreateHubCommitment(model.ClientPubKey, asset, model.SignedByClientChannel); return(new OffchainApiResponse(tr)); }