예제 #1
0
        void placebetthread(object _High)
        {
            try
            {
                bool       High      = (bool)_High;
                int        client    = R.Next(0, int.MaxValue);
                double     tmpchance = High ? maxRoll - chance : chance;
                MPBetPlace betplace  = new MPBetPlace
                {
                    client_seed = client,
                    cond        = High ? ">" : "<",
                    hash        = next,
                    payout      = (((double)(100.0m - edge) / chance) * (amount * 100000000)),
                    target      = tmpchance,
                    wager       = amount * 100000000
                };

                HttpContent cont = new StringContent(json.JsonSerializer <MPBetPlace>(betplace));
                cont.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
                string Resp = "";
                using (var response = Client.PostAsync("bets/simple-dice?access_token=" + token, cont))
                {
                    Resp = response.Result.Content.ReadAsStringAsync().Result;
                }


                MPBet tmp = json.JsonDeserialize <MPBet>(Resp);
                if (tmp.error != null)
                {
                    if (tmp.error.ToLower().Contains("invalid_hash") || tmp.error.ToLower().Contains("valid hash"))
                    {
                        ResetSeed();
                        placebetthread(High);
                        return;
                    }
                    else
                    {
                        Parent.updateStatus(tmp.error);
                    }
                    return;
                }


                Bet tmpBet = new Bet {
                    Amount     = (decimal)amount,
                    date       = DateTime.Now,
                    Id         = tmp.bet_id,
                    Profit     = (decimal)tmp.profit / 100000000m,
                    Roll       = (decimal)tmp.outcome,
                    high       = High,
                    Chance     = (decimal)chance,
                    nonce      = 0,
                    serverhash = next,
                    serverseed = tmp.secret.ToString(),
                    clientseed = client.ToString()
                };
                next = tmp.next_hash;
                //lastupdate = DateTime.Now;
                balance += tmp.profit / 100000000.0; //i assume
                bets++;
                bool Win = (((bool)tmpBet.high ? (decimal)tmpBet.Roll > (decimal)maxRoll - (decimal)(tmpBet.Chance) : (decimal)tmpBet.Roll < (decimal)(tmpBet.Chance)));
                if (Win)
                {
                    wins++;
                }
                else
                {
                    losses++;
                }

                wagered   += amount;
                profit    += (tmp.profit / 100000000.0);
                retrycount = 0;
                FinishedBet(tmpBet);
            }
            catch (AggregateException e)
            {
                if (retrycount++ < 3)
                {
                    placebetthread(High);
                    return;
                }
                if (e.InnerException.InnerException.Message.Contains("tsl/ssl") || e.InnerException.Message.Contains("502"))
                {
                    Thread.Sleep(200);
                    placebetthread(High);
                }
            }
            catch (Exception e2)
            {
            }
        }
예제 #2
0
        void placebetthread(object _High)
        {
            try
            {
                bool           High       = (bool)_High;
                int            client     = R.Next(0, int.MaxValue);
                HttpWebRequest betrequest = (HttpWebRequest)HttpWebRequest.Create("https://api.moneypot.com/v1/bets/simple-dice?access_token=" + token);
                betrequest.CookieContainer = new CookieContainer();
                betrequest.CookieContainer.Add(new Cookie("sessionId", token, "/", "moneypot.com"));
                if (Prox != null)
                {
                    betrequest.Proxy = Prox;
                }
                betrequest.Method = "POST";
                double     tmpchance = High ? maxRoll - chance : chance;
                MPBetPlace betplace  = new MPBetPlace {
                    client_seed = client,
                    cond        = High ? ">" : "<",
                    hash        = next,
                    payout      = (((double)(100.0m - edge) / chance) * (amount * 100000000)),
                    target      = tmpchance,
                    wager       = amount * 100000000
                };
                string post = json.JsonSerializer <MPBetPlace>(betplace);
                betrequest.ContentLength = post.Length;
                betrequest.ContentType   = "application/json";

                using (var writer = new StreamWriter(betrequest.GetRequestStream()))
                {
                    writer.Write(post);
                }
                HttpWebResponse EmitResponse  = (HttpWebResponse)betrequest.GetResponse();
                string          sEmitResponse = new StreamReader(EmitResponse.GetResponseStream()).ReadToEnd();

                MPBet tmp = json.JsonDeserialize <MPBet>(sEmitResponse);

                Bet tmpBet = new Bet {
                    Amount     = (decimal)amount,
                    date       = DateTime.Now,
                    Id         = tmp.bet_id,
                    Profit     = (decimal)tmp.profit / 100000000m,
                    Roll       = (decimal)tmp.outcome,
                    high       = High,
                    Chance     = (decimal)chance,
                    nonce      = 0,
                    serverhash = next,
                    serverseed = tmp.secret.ToString(),
                    clientseed = client.ToString()
                };
                next = tmp.next_hash;
                //lastupdate = DateTime.Now;
                balance += tmp.profit / 100000000.0; //i assume
                bets++;
                bool Win = (((bool)tmpBet.high ? (decimal)tmpBet.Roll > (decimal)maxRoll - (decimal)(tmpBet.Chance) : (decimal)tmpBet.Roll < (decimal)(tmpBet.Chance)));
                if (Win)
                {
                    wins++;
                }
                else
                {
                    losses++;
                }

                wagered += amount;
                profit  += (tmp.profit / 100000000.0);
                FinishedBet(tmpBet);
            }
            catch (WebException e)
            {
                if (e.Response != null)
                {
                    string sEmitResponse = new StreamReader(e.Response.GetResponseStream()).ReadToEnd();
                    Parent.updateStatus(sEmitResponse);
                }
                if (e.Message.Contains("429") || e.Message.Contains("502"))
                {
                    Thread.Sleep(200);
                    placebetthread(High);
                }
            }
        }