Esempio n. 1
0
        public static string CheckTxidBalance(string _address, decimal _balance, out decimal _outBalance)
        {
            _outBalance = 0M;
            string _error = "";

            try
            {
                //get info
                _error = "get info";
                string        _url       = $"https://api.trxplorer.io/v2/account/{_address}";
                WebClientPlus _webClient = new WebClientPlus(10000);
                string        _result    = _webClient.DownloadString(_url);
                _webClient.Dispose();
                JObject _json = JObject.Parse(_result);

                //balance
                _error = "balance";
                string _value = _json["balance"] + "";
                _outBalance = Common.Change2Decimal(_value);
                if (!_outBalance.ToString().Contains("."))
                {
                    _outBalance = _outBalance / 1000000M;
                }
                if (_outBalance < _balance)
                {
                    return(_error);
                }

                return("");
            }
            catch (Exception)
            {
                return(_error);
            }
        }
Esempio n. 2
0
        public void ResponseURI_InputHttpBinGoOrg_ResultGoogleCom()
        {
            _wc.DownloadString("https://httpbingo.org/redirect-to?url=https://google.com/");

            Assert.IsTrue(new Regex(@"^https?:\/\/(?:www\.)?google\.com\/?$")
                          .IsMatch(_wc.ResponseURI.ToString()));
        }
Esempio n. 3
0
        private void BooksRunner(object _object)
        {
            string _pair  = _object.ToString();
            string _pairA = _pair.Contains("_") ? _pair.Split('_')[0] : _pair;
            string _url   = $"/public/orderbook/{_pairA}";

            if (this.BooksLimit != "")
            {
                _url += $"?count={this.BooksLimit}";
            }

            this.Books[_pair, MarketSide.Ask] = new BookItems(MarketSide.Ask);
            this.Books[_pair, MarketSide.Bid] = new BookItems(MarketSide.Bid);

            string _result = "";

            while (this.Running)
            {
                Thread.Sleep(1000);

                try
                {
                    WebClientPlus _client = new WebClientPlus(5000);
                    _result = _client.DownloadString($"{base.HttpUrl}{_url}");
                    _client.Dispose();

                    JObject _json = JObject.Parse(_result);

                    BookItems _asks = new BookItems(MarketSide.Ask);
                    BookItems _bids = new BookItems(MarketSide.Bid);

                    this.Books.Timestamp = _json["data"]["timestamp"].Value <long>();

                    foreach (var _item in _json["data"]["asks"])
                    {
                        decimal _price  = _item["price"].Value <decimal>();
                        decimal _amount = _item["quantity"].Value <decimal>();
                        _asks.Insert(_price.ToString(), Math.Abs(_price), _amount);
                    }
                    foreach (var _item in _json["data"]["bids"])
                    {
                        decimal _price  = _item["price"].Value <decimal>();
                        decimal _amount = _item["quantity"].Value <decimal>();
                        _bids.Insert(_price.ToString(), Math.Abs(_price), _amount);
                    }

                    this.Books[_pair, MarketSide.Ask] = _asks;
                    this.Books[_pair, MarketSide.Bid] = _bids;
                }
                catch (Exception _ex)
                {
                    this.OnLog($"GetBooks Error:{_result}");
                    this.OnLog($"GetBooks Error:{_ex.ToString()}");
                }
            }
        }
Esempio n. 4
0
        public static string CheckTxidBalance(string _address, decimal _balance, out decimal _outBalance)
        {
            _outBalance = 0M;
            string _error = "";

            try
            {
                //get info
                _error = "get info";
                string        _url       = $"https://data.ripple.com/v2/accounts/{_address}/balances";
                WebClientPlus _webClient = new WebClientPlus(10000);
                string        _result    = _webClient.DownloadString(_url);
                _webClient.Dispose();
                JObject _json   = JObject.Parse(_result);
                JArray  _jArray = JArray.Parse(_json["balances"].ToString());
                JToken  _jToken = null;
                foreach (var _item in _jArray)
                {
                    string _currency = _item["currency"].Value <string>();
                    if (_currency.ToLower() != "xrp")
                    {
                        continue;
                    }
                    _jToken = _item;
                    break;
                }
                if (_jToken == null)
                {
                    return(_error);
                }

                //balance
                _error = "balance";
                string _value = _jToken["value"].Value <string>();
                //_outBalance = Common.Change2Decimal(_value);
                _outBalance = decimal.Parse(_value);
                //if (!_outBalance.ToString().Contains("."))
                //{
                //    //_outBalance = _outBalance / 1000000000000000000M;
                //    _outBalance = _outBalance / 1000000M;
                //}
                if (_outBalance < _balance)
                {
                    return(_error);
                }

                return("");
            }
            catch (Exception _ex)
            {
                Console.WriteLine(_ex.Message);
                return(_error);
            }
        }
Esempio n. 5
0
        public static string CheckTxidBalance(string _txid, int _index, string _address, decimal _balance, out decimal _outBalance)
        {
            _outBalance = 0M;
            string _error = "";

            try
            {
                //get info
                _error = "get info";
                string        _url       = $"https://bch-chain.api.btc.com/v3/tx/{_txid}?verbose=3";
                WebClientPlus _webClient = new WebClientPlus(10000);
                string        _result    = _webClient.DownloadString(_url);
                _webClient.Dispose();
                JObject _json   = JObject.Parse(_result);
                JToken  _jToken = _json["data"]["outputs"][_index];

                //address
                _error = "address";
                string _cashAddr = _jToken["addresses"][0].Value <string>().Trim();
                _cashAddr = Change2NewAddress(_cashAddr);
                if (_cashAddr != _address.Trim())
                {
                    return(_error);
                }

                //balance
                _error = "balance";
                string _value = _jToken["value"].Value <string>();
                _outBalance = decimal.Parse(_value);
                if (!_value.Contains("."))
                {
                    _outBalance = _outBalance / 100000000M;
                }
                if (_outBalance != _balance)
                {
                    return(_error);
                }

                //spent
                _error = "spent";
                if (_jToken["spent_by_tx"].HasValues || _jToken["spent_by_tx_position"].Value <string>().Trim() != "-1")
                {
                    return(_error);
                }

                return("");
            }
            catch (Exception)
            {
                return(_error);
            }
        }
Esempio n. 6
0
        private void BooksRunner(object _object)
        {
            string _pair = _object.ToString();
            string _url  = $"/api/v1/depth?symbol={_pair}&limit=10";

            this.Books[_pair, MarketSide.Ask] = new BookItems(MarketSide.Ask);
            this.Books[_pair, MarketSide.Bid] = new BookItems(MarketSide.Bid);

            string _result = "";

            while (this.Running)
            {
                Thread.Sleep(1000);

                try
                {
                    WebClientPlus _client = new WebClientPlus(5000);
                    _result = _client.DownloadString($"{base.HttpUrl}{_url}");
                    _client.Dispose();

                    JObject _json = JObject.Parse(_result);

                    BookItems _asks = new BookItems(MarketSide.Ask);
                    BookItems _bids = new BookItems(MarketSide.Bid);

                    this.Books.Timestamp = DateTimePlus.DateTime2JSTime(DateTime.UtcNow);

                    foreach (var _item in _json["asks"])
                    {
                        decimal _price  = _item[0].Value <decimal>();
                        decimal _amount = _item[1].Value <decimal>();
                        _asks.Insert(_price.ToString(), Math.Abs(_price), _amount);
                    }
                    foreach (var _item in _json["bids"])
                    {
                        decimal _price  = _item[0].Value <decimal>();
                        decimal _amount = _item[1].Value <decimal>();
                        _bids.Insert(_price.ToString(), Math.Abs(_price), _amount);
                    }

                    this.Books[_pair, MarketSide.Ask] = _asks;
                    this.Books[_pair, MarketSide.Bid] = _bids;
                }
                catch (Exception _ex)
                {
                    this.OnLog($"GetBooks Error:{_result}");
                    this.OnLog($"GetBooks Error:{_ex.ToString()}");
                }
            }
        }
Esempio n. 7
0
 public static string Change2NewAddress(string _address)
 {
     try
     {
         WebClientPlus _client = new WebClientPlus(10000);
         string        _return = _client.DownloadString($"https://cashaddr.bitcoincash.org/convert?address={_address}");
         _client.Dispose();
         JObject _json = JObject.Parse(_return);
         return(_json["cashaddr"].Value <string>().Trim());
     }
     catch (Exception)
     {
         return("");
     }
 }
Esempio n. 8
0
 public static JObject GetTxidInfo(string _txid)
 {
     try
     {
         string        _url       = $"https://chain.api.btc.com/v3/tx/{_txid}?verbose=3";
         WebClientPlus _webClient = new WebClientPlus(10000);
         string        _result    = _webClient.DownloadString(_url);
         JObject       _json      = JObject.Parse(_result);
         return(_json);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Esempio n. 9
0
 public static string GetCurrentHeight()
 {
     try
     {
         string        _url       = "https://api.blockchair.com/bitcoin-cash/stats";
         WebClientPlus _webClient = new WebClientPlus(10000);
         string        _result    = _webClient.DownloadString(_url);
         _webClient.Dispose();
         JObject _json = JObject.Parse(_result);
         return(_json["data"]["blocks"].Value <string>());
     }
     catch (Exception)
     {
         return("");
     }
 }
Esempio n. 10
0
 public static string GetCurrentHeight()
 {
     try
     {
         string        _url       = "https://api.blockcypher.com/v1/btc/main";
         WebClientPlus _webClient = new WebClientPlus(10000);
         string        _result    = _webClient.DownloadString(_url);
         _webClient.Dispose();
         JObject _json = JObject.Parse(_result);
         return(_json["height"].Value <string>());
     }
     catch (Exception)
     {
         return("");
     }
 }
Esempio n. 11
0
 public static string GetCurrentHeight()
 {
     try
     {
         string        _url       = "https://apilist.tronscan.org/api/system/status";
         WebClientPlus _webClient = new WebClientPlus(10000);
         string        _result    = _webClient.DownloadString(_url);
         _webClient.Dispose();
         JObject _json = JObject.Parse(_result);
         return(_json["database"]["block"].Value <string>());
     }
     catch (Exception)
     {
         return("");
     }
 }
Esempio n. 12
0
 public static string GetCurrentHeight()
 {
     try
     {
         string        _url       = "https://api.etherscan.io/api?module=proxy&action=eth_blockNumber&apikey=YourApiKeyToken";
         WebClientPlus _webClient = new WebClientPlus(10000);
         string        _result    = _webClient.DownloadString(_url);
         _webClient.Dispose();
         JObject _json = JObject.Parse(_result);
         _result = _json["result"].Value <string>();
         int _height = Convert.ToInt32(_result, 16);
         return(_height.ToString());
     }
     catch (Exception)
     {
         return("");
     }
 }
Esempio n. 13
0
 public static string GetCurrentHeight()
 {
     try
     {
         //string _url = "https://data.ripple.com/v2/health/importer?verbose=true";
         string        _url       = "https://data.ripple.com/v2/ledgers/";
         WebClientPlus _webClient = new WebClientPlus(10000);
         string        _result    = _webClient.DownloadString(_url);
         _webClient.Dispose();
         JObject _json = JObject.Parse(_result);
         //return _json["last_validated_ledger"].Value<string>();
         return(_json["ledger"]["ledger_index"].Value <string>());
     }
     catch (Exception)
     {
         return("");
     }
 }
Esempio n. 14
0
 public static string GetCurrentHeight()
 {
     try
     {
         //string _url = "https://xmr.tokenview.com/api/blocks/xmr/1/1";
         string        _url       = "https://monerohash.com/api/stats?_=" + DateTimePlus.DateTime2JSTime(DateTime.UtcNow).ToString() + DateTime.UtcNow.Millisecond.ToString();
         WebClientPlus _webClient = new WebClientPlus(10000);
         string        _result    = _webClient.DownloadString(_url);
         _webClient.Dispose();
         JObject _json = JObject.Parse(_result);
         //return _json["data"][0]["block_no"].Value<string>();
         return(_json["network"]["height"].Value <string>());
     }
     catch (Exception)
     {
         return("");
     }
 }
Esempio n. 15
0
        public static string CheckTxidBalance(string _address, decimal _balance, out decimal _outBalance)
        {
            _outBalance = 0M;
            string _error = "";

            try
            {
                //get info
                _error = "get info";
                //string _url = $"http://api.ethplorer.io/getAddressInfo/0x32Be343B94f860124dC4fEe278FDCBD38C102D88?apiKey=freekey";
                //string _url = $"https://api.blockcypher.com/v1/eth/main/addrs/{_address}/balance";
                string        _url       = $"https://api.etherscan.io/api?module=account&action=balance&address={_address}&tag=latest&apikey=YourApiKeyToken";
                WebClientPlus _webClient = new WebClientPlus(10000);
                string        _result    = _webClient.DownloadString(_url);
                _webClient.Dispose();
                JObject _json = JObject.Parse(_result);

                //balance
                _error = "balance";
                string _value = _json["result"] + "";
                _outBalance = decimal.Parse(_value);
                if (!_value.Contains("."))
                {
                    _outBalance = _outBalance / 1000000000000000000M;
                }
                if (_outBalance < _balance)
                {
                    return(_error);
                }

                return("");
            }
            catch (Exception)
            {
                return(_error);
            }
        }
Esempio n. 16
0
        private void BooksRunner(object _object)
        {
            string _pair = _object.ToString();
            string _url  = $"/{_pair}/depth";

            this.Books[_pair, MarketSide.Ask] = new BookItems(MarketSide.Ask);
            this.Books[_pair, MarketSide.Bid] = new BookItems(MarketSide.Bid);

            string _result = "";

            while (this.Running)
            {
                Thread.Sleep(1000);

                try
                {
                    WebClientPlus _client = new WebClientPlus(5000);
                    _result = _client.DownloadString($"{this.UrlPublic}{_url}");
                    _client.Dispose();

                    JObject _json = JObject.Parse(_result);

                    BookItems _asks = new BookItems(MarketSide.Ask);
                    BookItems _bids = new BookItems(MarketSide.Bid);

                    this.Books.Timestamp = _json["data"]["timestamp"].Value <long>();

                    foreach (var _item in _json["data"]["asks"])
                    {
                        decimal _price  = _item[0].Value <decimal>();
                        decimal _amount = _item[1].Value <decimal>();
                        _asks.Insert(_price.ToString(), Math.Abs(_price), _amount);
                    }
                    foreach (var _item in _json["data"]["bids"])
                    {
                        decimal _price  = _item[0].Value <decimal>();
                        decimal _amount = _item[1].Value <decimal>();
                        _bids.Insert(_price.ToString(), Math.Abs(_price), _amount);
                    }

                    BookItems _asksLimit = new BookItems(MarketSide.Ask);
                    BookItems _bidsLimit = new BookItems(MarketSide.Bid);
                    foreach (var _item in _asks.OrderBy(b => b.Value.Price).Take(10))
                    {
                        decimal _price  = _item.Value.Price;
                        decimal _amount = _item.Value.Amount;
                        _asksLimit.Insert(_price.ToString(), Math.Abs(_price), _amount);
                    }
                    foreach (var _item in _bids.OrderByDescending(b => b.Value.Price).Take(10))
                    {
                        decimal _price  = _item.Value.Price;
                        decimal _amount = _item.Value.Amount;
                        _bidsLimit.Insert(_price.ToString(), Math.Abs(_price), _amount);
                    }

                    this.Books[_pair, MarketSide.Ask] = _asksLimit;
                    this.Books[_pair, MarketSide.Bid] = _bidsLimit;
                }
                catch (Exception _ex)
                {
                    this.OnLog($"GetBooks Error:{_result}");
                    this.OnLog($"GetBooks Error:{_ex.ToString()}");
                }
            }
        }
Esempio n. 17
0
        private void BooksRunner(object _object)
        {
            string _pair = _object.ToString();
            string _url  = $"/api/spot/v3/instruments/{_pair}/book?size=10";

            this.Books[_pair, MarketSide.Ask] = new BookItems(MarketSide.Ask);
            this.Books[_pair, MarketSide.Bid] = new BookItems(MarketSide.Bid);

            string _result = "";

            while (this.Running)
            {
                Thread.Sleep(1000);

                try
                {
                    WebClientPlus _client = new WebClientPlus(10000);
                    _result = _client.DownloadString($"{this.HttpUrl}{_url}");
                    _client.Dispose();

                    JObject _json = JObject.Parse(_result);

                    BookItems _asks = new BookItems(MarketSide.Ask);
                    BookItems _bids = new BookItems(MarketSide.Bid);

                    this.Books.Timestamp = DateTimePlus.DateTime2JSTime(DateTime.UtcNow);

                    foreach (var _item in _json["asks"])
                    {
                        decimal _price  = decimal.Parse(_item[0].Value <string>(), System.Globalization.NumberStyles.Float);
                        decimal _amount = decimal.Parse(_item[1].Value <string>(), System.Globalization.NumberStyles.Float);
                        _asks.Insert(_price.ToString(), Math.Abs(_price), _amount);
                    }
                    foreach (var _item in _json["bids"])
                    {
                        decimal _price  = decimal.Parse(_item[0].Value <string>(), System.Globalization.NumberStyles.Float);
                        decimal _amount = decimal.Parse(_item[1].Value <string>(), System.Globalization.NumberStyles.Float);
                        _bids.Insert(_price.ToString(), Math.Abs(_price), _amount);
                    }

                    BookItems _asksLimit = new BookItems(MarketSide.Ask);
                    BookItems _bidsLimit = new BookItems(MarketSide.Bid);
                    foreach (var _item in _asks.OrderBy(b => b.Value.Price).Take(10))
                    {
                        decimal _price  = _item.Value.Price;
                        decimal _amount = _item.Value.Amount;
                        _asksLimit.Insert(_price.ToString(), Math.Abs(_price), _amount);
                    }
                    foreach (var _item in _bids.OrderByDescending(b => b.Value.Price).Take(10))
                    {
                        decimal _price  = _item.Value.Price;
                        decimal _amount = _item.Value.Amount;
                        _bidsLimit.Insert(_price.ToString(), Math.Abs(_price), _amount);
                    }

                    this.Books[_pair, MarketSide.Ask] = _asksLimit;
                    this.Books[_pair, MarketSide.Bid] = _bidsLimit;
                }
                catch (Exception _ex)
                {
                    this.OnLog($"GetBooks Error:{_result}");
                    this.OnLog($"GetBooks Error:{_ex.ToString()}");
                }
            }
        }
Esempio n. 18
0
        private void BooksRunner(object _object)
        {
            string _pair = _object.ToString();
            string _url  = $"/v1.1/public/getorderbook?market={_pair}&type=both";

            this.Books[_pair, MarketSide.Ask] = new BookItems(MarketSide.Ask);
            this.Books[_pair, MarketSide.Bid] = new BookItems(MarketSide.Bid);

            string _result = "";

            while (this.Running)
            {
                Thread.Sleep(1000);

                try
                {
                    WebClientPlus _client = new WebClientPlus(5000);
                    _result = _client.DownloadString($"{this.HttpUrl}{_url}");
                    _client.Dispose();

                    JObject _json = JObject.Parse(_result);

                    BookItems _asks = new BookItems(MarketSide.Ask);
                    BookItems _bids = new BookItems(MarketSide.Bid);

                    this.Books.Timestamp = DateTimePlus.DateTime2JSTime(DateTime.UtcNow);

                    foreach (var _item in _json["result"]["sell"])
                    {
                        decimal _price  = _item["Rate"].Value <decimal>();
                        decimal _amount = _item["Quantity"].Value <decimal>();
                        _asks.Insert(_price.ToString(), Math.Abs(_price), _amount);
                    }
                    foreach (var _item in _json["result"]["buy"])
                    {
                        decimal _price  = _item["Rate"].Value <decimal>();
                        decimal _amount = _item["Quantity"].Value <decimal>();
                        _bids.Insert(_price.ToString(), Math.Abs(_price), _amount);
                    }

                    BookItems _asksLimit = new BookItems(MarketSide.Ask);
                    BookItems _bidsLimit = new BookItems(MarketSide.Bid);
                    foreach (var _item in _asks.OrderBy(b => b.Value.Price).Take(10))
                    {
                        decimal _price  = _item.Value.Price;
                        decimal _amount = _item.Value.Amount;
                        _asksLimit.Insert(_price.ToString(), Math.Abs(_price), _amount);
                    }
                    foreach (var _item in _bids.OrderByDescending(b => b.Value.Price).Take(10))
                    {
                        decimal _price  = _item.Value.Price;
                        decimal _amount = _item.Value.Amount;
                        _bidsLimit.Insert(_price.ToString(), Math.Abs(_price), _amount);
                    }

                    this.Books[_pair, MarketSide.Ask] = _asksLimit;
                    this.Books[_pair, MarketSide.Bid] = _bidsLimit;
                }
                catch (Exception _ex)
                {
                    this.OnLog($"GetBooks Error:{_result}");
                    this.OnLog($"GetBooks Error:{_ex.ToString()}");
                }
            }
        }
Esempio n. 19
0
        public static string CheckTxidBalance(string _txid, int _index, string _address, decimal _balance, out decimal _outBalance)
        {
            _outBalance = 0M;
            string _error = "";

            try
            {
                //get info
                _error = "get info";
                //string _url = $"https://chain.so/api/v2/get_tx_outputs/ltc/{_txid}";
                string        _url       = $"https://litecoinblockexplorer.net/api/tx/{_txid}";
                WebClientPlus _webClient = new WebClientPlus(10000);
                string        _result    = _webClient.DownloadString(_url);
                _webClient.Dispose();
                JObject _json   = JObject.Parse(_result);
                JArray  _jArray = JArray.Parse(_json["vout"].ToString());
                JToken  _jToken = null;
                foreach (var _item in _jArray)
                {
                    int _n = _item["n"].Value <int>();
                    if (_n != _index)
                    {
                        continue;
                    }
                    _jToken = _item;
                    break;
                }
                if (_jToken == null)
                {
                    return(_error);
                }

                //address
                _error = "address";
                string _cashAddr = _jToken["scriptPubKey"]["addresses"][0].Value <string>().Trim();
                if (_cashAddr != _address.Trim())
                {
                    return(_error);
                }

                //balance
                _error = "balance";
                string _value = _jToken["value"].Value <string>();
                _outBalance = decimal.Parse(_value);
                if (!_value.Contains("."))
                {
                    _outBalance = _outBalance / 100000000M;
                }
                if (_outBalance != _balance)
                {
                    return(_error);
                }

                //spent
                _error = "spent";
                if (_jToken["spentTxId"].HasValues || _jToken["spentIndex"].HasValues || _jToken["spentHeight"].HasValues)
                {
                    return(_error);
                }

                return("");
            }
            catch (Exception)
            {
                return(_error);
            }
        }