Пример #1
0
        public async Task <BlockchainTransactionGetResponse> GetBlockchainTransactionGet(string txhash)
        {
            var request = new BlockchainTransactionGetRequest();

            request.Parameters = new object[] { txhash, true };
            var requestData = request.GetRequestData <BlockchainTransactionGetRequest>();

            await this.Connect();

            string response = await SendMessage(requestData);

            this.Disconnect();
            return(BlockchainTransactionGetResponse.FromJson(response));
        }
Пример #2
0
        public async Task <string> GetRawTx(string txHash)
        {
            if (string.IsNullOrEmpty(txHash))
            {
                return(string.Empty);
            }
            var requestData = new BlockchainTransactionGetRequest(txHash).GetRequestData();
            var buff        = "";

            try
            {
                if (UseSsl)
                {
                    await ConnectWithSsl();

                    buff = await SendMessageWithSsl(requestData);
                }
                else
                {
                    await ConnectNoSsl();

                    buff = await SendMessageNoSsl(requestData);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                // ignored
            }
            var response = !string.IsNullOrEmpty(buff) ? JsonConvert.DeserializeObject <BlockchainTransactionGetResponse>(buff) : null;

            if (response?.Error != null)
            {
                OnError?.Invoke(this, response.Error.Code, response.Error.Message);
            }
            return(response != null?response.GetResultModel().RawTx : string.Empty);
        }
Пример #3
0
        public async Task <int> GetConfirms(string txHash)
        {
            if (string.IsNullOrEmpty(txHash))
            {
                return(-1);
            }
            var requestData = new BlockchainTransactionGetRequest(txHash, true).GetRequestData();
            var buff        = "";

            try
            {
                if (UseSsl)
                {
                    await ConnectWithSsl();

                    buff = await SendMessageWithSsl(requestData);
                }
                else
                {
                    await ConnectNoSsl();

                    buff = await SendMessageNoSsl(requestData);
                }
            }
            catch
            {
                // ignored
            }
            var response = !string.IsNullOrEmpty(buff) ? JsonConvert.DeserializeObject <BlockchainTransactionGetConfirmsResponse>(buff) : null;

            if (response?.Error != null)
            {
                OnError?.Invoke(this, response.Error.Code, response.Error.Message);
            }
            return(response?.GetResultModel() ?? -1);
        }