Exemple #1
0
        public async Task <BlockchainEstimatefeeResponse> GetBlockchainEstimatefee(uint number)
        {
            var request = new BlockchainEstimatefeeRequest();

            request.Parameters = new uint[] { number };
            var requestData = request.GetRequestData <BlockchainEstimatefeeRequest>();

            await this.Connect();

            string response = await SendMessage(requestData);

            this.Disconnect();
            return(BlockchainEstimatefeeResponse.FromJson(response));
        }
        public async Task <BlockchainEstimatefeeResult> EstimateFeeSatPerByte(string blockCount)
        {
            if (Coin == Coin.BitcoinCash || string.IsNullOrEmpty(blockCount))
            {
                var result = new BlockchainEstimatefeeResponse()
                {
                    Result = 0.00000001m
                };
                return(result.GetResultModel());
            }
            var requestData = new BlockchainEstimateFeeRequest(blockCount).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 <BlockchainEstimatefeeResponse>(buff) : null;

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