private async Task <ActionResult> GetTransactionsByBlockHash(string blockHash, UInt64 pageNum, bool returnLegacyAddresses)
        {
            Utils.CheckIfChainIsFresh(chain_, config_.AcceptStaleRequests);
            using (var getBlockResult = await chain_.FetchBlockByHashAsync(Binary.HexStringToByteArray(blockHash)))
            {
                Utils.CheckBitprimApiErrorCode(getBlockResult.ErrorCode, "FetchBlockByHashAsync(" + blockHash + ") failed, check error log");

                IBlock fullBlock   = getBlockResult.Result.BlockData;
                UInt64 blockHeight = getBlockResult.Result.BlockHeight;
                UInt64 pageSize    = (UInt64)config_.TransactionsByAddressPageSize;
                UInt64 pageCount   = (UInt64)Math.Ceiling((double)fullBlock.TransactionCount / (double)pageSize);
                if (pageNum >= pageCount)
                {
                    return(BadRequest("pageNum cannot exceed " + (pageCount - 1) + " (zero-indexed)"));
                }

                var txs = new List <TransactionSummary>();
                for (UInt64 i = 0; i < pageSize && pageNum * pageSize + i < fullBlock.TransactionCount; i++)
                {
                    var tx = fullBlock.GetNthTransaction(pageNum * pageSize + i);
                    txs.Add(await TxToJSON
                            (
                                tx, blockHeight, confirmed: true,
                                returnLegacyAddresses: returnLegacyAddresses, noAsm: false, noScriptSig: false,
                                noSpend: false
                            ));
                }

                return(Json(new GetTransactionsResponse
                {
                    pagesTotal = pageCount,
                    txs = txs.ToArray()
                }));
            }
        }
        public async Task <ActionResult> GetRawBlockByHash(string hash)
        {
            if (!Validations.IsValidHash(hash))
            {
                return(BadRequest(hash + " is not a valid block hash"));
            }
            Utils.CheckIfChainIsFresh(chain_, config_.AcceptStaleRequests);
            var binaryHash = Binary.HexStringToByteArray(hash);

            using (var getBlockResult = await chain_.FetchBlockByHashAsync(binaryHash))
            {
                Utils.CheckBitprimApiErrorCode(getBlockResult.ErrorCode, "FetchBlockByHashAsync(" + hash + ") failed, check error log");
                var block = getBlockResult.Result.BlockData;
                return(Json
                       (
                           new GetRawBlockResponse
                {
                    rawblock = Binary.ByteArrayToHexString(block.ToData(false).Reverse().ToArray())
                }
                       ));
            }
        }