private async Task <string> Send(MhcRequest mhcRequest, string url)
        {
            using (var request = new HttpRequestMessage(HttpMethod.Post, url))
            {
                var json = JsonConvert.SerializeObject(mhcRequest);
                using (var stringContent = new StringContent(json, Encoding.UTF8, "application/json"))
                {
                    request.Content = stringContent;

                    var response = await _httpClient.SendAsync(request);

                    response.EnsureSuccessStatusCode();
                    return(await response.Content.ReadAsStringAsync());
                }
            }
        }
        public async Task <FetchBalanceResponse> FetchBalance(string walletAddress)
        {
            var queryTorrentRequest = new QueryBalanceRequest
            {
                Address = walletAddress
            };

            var torrentRequest = new MhcRequest {
                Params = queryTorrentRequest, Method = "fetch-balance"
            };
            var responseJson = await QueryTorrent(torrentRequest);

            var fetchBalanceResponse = JsonConvert.DeserializeObject <FetchBalanceResponse>(responseJson);

            return(fetchBalanceResponse);
        }
        public async Task <GetTxResponse> GetTx(string txId)
        {
            var getTxRequest = new GetTxRequest
            {
                TxId = txId
            };

            var torrentRequest = new MhcRequest {
                Params = getTxRequest, Method = "get-tx"
            };
            var responseJson = await QueryTorrent(torrentRequest);

            var getTxResponse = JsonConvert.DeserializeObject <GetTxResponse>(responseJson);

            return(getTxResponse);
        }
        public async Task <FetchHistoryFilterResponse> FetchHistory(string walletAddress)
        {
            var queryTorrentRequest = new QueryHistoryFilterRequest
            {
                Address = walletAddress,
                CountTx = 999,
                BeginTx = 0
            };

            var torrentRequest = new MhcRequest {
                Params = queryTorrentRequest, Method = "fetch-history"
            };
            var responseJson = await QueryTorrent(torrentRequest);

            var fetchHistoryResponse = JsonConvert.DeserializeObject <FetchHistoryFilterResponse>(responseJson);

            return(fetchHistoryResponse);
        }
 private async Task <string> QueryTorrent(MhcRequest mhcRequest)
 {
     return(await Send(mhcRequest, TorUrl));
 }