/// <summary> /// gets the total number of transactions in the block /// </summary> /// <returns></returns> public Tuple <bool, string, GetBlockHeightResBody> GetTxCountByBlockNumber(string blockNumber) { try { NodeApiReqBody <FiscoBlockReqDataBody> req = new NodeApiReqBody <FiscoBlockReqDataBody> { header = GetReqHeader(), body = new FiscoBlockReqDataBody() { BlockNumber = blockNumber } }; req.mac = sign.Sign(FiscoReqMacExtends.GetFiscoBlockInfoReqMac(req)); var res = SendHelper.SendPost <NodeApiResBody <GetBlockHeightResBody> >(config.reqUrl + GetTxCountByBlockNumberUrl, JsonConvert.SerializeObject(req), config.httpsCert); if (res != null) { //Check the status codes in turn if (res.header.code != 0) { return(new Tuple <bool, string, GetBlockHeightResBody>(false, res.header.msg, null)); } //assemble the original string to verify var datares = FiscoResMacExtends.GetBlockHeightResMac(res); //data verified if (sign.Verify(res.mac, datares)) { return(new Tuple <bool, string, GetBlockHeightResBody>(true, res.header.msg, res.body)); } else { return(new Tuple <bool, string, GetBlockHeightResBody>(false, "failed to verify the signature", null)); } } } catch (Exception ex) { throw ex; } return(new Tuple <bool, string, GetBlockHeightResBody>(false, "failed to get the total number of transactions in the block", null)); }
/// <summary> /// get block info /// </summary> /// <param name="reqBody"></param> /// <returns></returns> public Tuple <bool, string, FiscoBlockData> GetBlockInfo(FiscoBlockReqDataBody reqBody) { try { NodeApiReqBody <FiscoBlockReqDataBody> req = new NodeApiReqBody <FiscoBlockReqDataBody> { header = GetReqHeader(), body = reqBody }; req.mac = sign.Sign(FiscoReqMacExtends.GetFiscoBlockInfoReqMac(req)); var res = SendHelper.SendPost <NodeApiResBody <FiscoBlockData> >(config.reqUrl + BlockInfoUrl, JsonConvert.SerializeObject(req), config.httpsCert); if (res != null) { //Check the status codes in turn if (res.header.code != 0) { return(new Tuple <bool, string, FiscoBlockData>(false, res.header.msg, null)); } //assemble the original string to verify var datares = FiscoResMacExtends.GetFiscoBlockInfoResMac(res); //data verified if (sign.Verify(res.mac, datares)) { return(new Tuple <bool, string, FiscoBlockData>(true, res.header.msg, res.body)); } else { return(new Tuple <bool, string, FiscoBlockData>(false, "failed to verify the signature", null)); } } } catch (Exception ex) { throw ex; } return(new Tuple <bool, string, FiscoBlockData>(false, "failed to get block info", null)); }