public async Task <ActionResult> GetRawBlockByHeight([FromRoute] UInt64 height) { if (!ModelState.IsValid) { return(BadRequest("Block height must be a non negative integer")); } Utils.CheckIfChainIsFresh(chain_, config_.AcceptStaleRequests); using (var getBlockResult = await chain_.FetchBlockByHeightAsync(height)) { Utils.CheckBitprimApiErrorCode(getBlockResult.ErrorCode, "FetchBlockByHeightAsync(" + height + ") failed, check error log"); var block = getBlockResult.Result.BlockData; return(Json ( new { rawblock = Binary.ByteArrayToHexString(block.ToData(false).Reverse().ToArray()) } )); } }
public IBlock GetBlockByHeight(UInt64 height) { return(chain_.FetchBlockByHeightAsync(height).Result.Result.BlockData); }