Ejemplo n.º 1
0
 void GetBalanceThread()
 {
     try
     {
         while (ispd)
         {
             if (CrrentLogin != null && ((DateTime.Now - lastupdate).TotalSeconds > 60 || ForceUpdateStats))
             {
                 lastupdate       = DateTime.Now;
                 ForceUpdateStats = false;
                 try
                 {
                     string     result   = Client.GetStringAsync("auth/me?currency=" + Currency.ToLower() + "&hash=" + hash).Result;
                     StakeLogin newlogin = json.JsonDeserialize <StakeLogin>(result);
                     if (newlogin != null)
                     {
                         if (newlogin.user != null)
                         {
                             CrrentLogin.user = newlogin.user;
                             CrrentLogin.user = newlogin.user;
                             balance          = (decimal)((Currency.ToLower() == "btc"? CrrentLogin.user.balances.btc.available_balance: Currency.ToLower() == "eth"? CrrentLogin.user.balances.eth.available_balance: CrrentLogin.user.balances.btc.available_balance)) / 100000000.0m;
                             bets             = (int)CrrentLogin.user.stats.dice.bets;
                             wins             = (int)CrrentLogin.user.stats.dice.wins;
                             losses           = (int)CrrentLogin.user.stats.dice.losses;
                             profit           = (decimal)CrrentLogin.user.stats.dice.profit / 100000000.0m;
                             wagered          = (decimal)CrrentLogin.user.stats.dice.wagered / 100000000.0m;
                             Parent.updateBalance(balance);
                             Parent.updateBets(bets);
                             Parent.updateWins(wins);
                             Parent.updateLosses(losses);
                             Parent.updateProfit(profit);
                             Parent.updateWagered(wagered);
                         }
                     }
                 }
                 catch (Exception er)
                 {
                     Parent.DumpLog(er.ToString(), 0);
                 }
             }
             Thread.Sleep(1000);
         }
     }
     catch
     {
     }
 }
Ejemplo n.º 2
0
        public override void Login(string username, string password, string ga)
        {
            try
            {
                ClientHandlr = new HttpClientHandler {
                    UseCookies = true, AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip
                };
                Client = new HttpClient(ClientHandlr)
                {
                    BaseAddress = new Uri("https://api.stake.com/api/")
                };
                Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("gzip"));
                Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("deflate"));
                cookies = new CookieContainer();
                ClientHandlr.CookieContainer = cookies;
                hash = "";
                var content = new StringContent(string.Format(System.Globalization.NumberFormatInfo.InvariantInfo, "{{\"username\":\"{0}\",\"password\":\"{1}\",\"tfa\":\"{2}\",\"captcha\":\"\"}}", username, password, ga), Encoding.UTF8, "application/json");

                HttpResponseMessage response = Client.PostAsync("auth/login?hash=" + hash, content).Result;
                if (response.IsSuccessStatusCode)
                {
                    string     ResponseMsg = response.Content.ReadAsStringAsync().Result;
                    StakeLogin login       = json.JsonDeserialize <StakeLogin>(ResponseMsg);
                    this.CrrentLogin = login;
                    if (login.token != null && login.user != null)
                    {
                        Client.DefaultRequestHeaders.Add("x-access-token", login.token);
                        Client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", login.token);



                        balance = (decimal)((Currency.ToLower() == "btc" ? CrrentLogin.user.balances.btc.available_balance : Currency.ToLower() == "eth" ? CrrentLogin.user.balances.eth.available_balance : CrrentLogin.user.balances.btc.available_balance)) / 100000000.0m;
                        bets    = (int)login.user.stats.dice.bets;
                        wins    = (int)login.user.stats.dice.wins;
                        losses  = (int)login.user.stats.dice.losses;
                        profit  = (decimal)login.user.stats.dice.profit / 100000000.0m;
                        wagered = (decimal)login.user.stats.dice.wagered / 100000000.0m;
                        Parent.updateBalance(balance);
                        Parent.updateBets(bets);
                        Parent.updateWins(wins);
                        Parent.updateLosses(losses);
                        Parent.updateProfit(profit);
                        Parent.updateWagered(wagered);

                        finishedlogin(true);
                        lastupdate = DateTime.Now;
                        ispd       = true;
                        Thread t = new Thread(GetBalanceThread);
                        t.Start();
                        return;
                    }
                }
                else
                {
                    Parent.updateStatus(response.Content.ReadAsStringAsync().Result);
                }
            }
            catch (Exception E)
            {
                Parent.DumpLog(E.ToString(), 0);
            }
            finishedlogin(false);
            return;
        }