コード例 #1
0
 void SetStats(WolfBetStats Stats)
 {
     try
     {
         PropertyInfo tmp = typeof(Dice).GetProperty(CurrentCurrency.ToLower());
         if (tmp != null)
         {
             WBStat stat = tmp.GetValue(Stats.dice) as WBStat;
             if (stat != null)
             {
                 this.Stats.Bets    = int.Parse(stat.total_bets);
                 this.Stats.Wins    = int.Parse(stat.win);
                 this.Stats.Losses  = int.Parse(stat.lose);
                 this.Stats.Wagered = decimal.Parse(stat.waggered, System.Globalization.NumberFormatInfo.InvariantInfo);
                 this.Stats.Profit  = decimal.Parse(stat.profit, System.Globalization.NumberFormatInfo.InvariantInfo);
             }
         }
     }
     catch
     {
         this.Stats.Bets    = 0;
         this.Stats.Wins    = 0;
         this.Stats.Losses  = 0;
         this.Stats.Wagered = 0;
         this.Stats.Profit  = 0;
     }
 }
コード例 #2
0
ファイル: BitExo.cs プロジェクト: hbernaciak/Doormat
        void ProcessBalance(string Res)
        {
            BEBalanceBase tmpResult = json.JsonDeserialize <BEBalanceBase>(Res);

            switch (CurrentCurrency.ToLower())
            {
            case "btc":
                Stats.Balance = tmpResult.user.balances.btc / 100000000m;
                Stats.Bets    = (int)tmpResult.user.stats.btc.bets;
                Stats.Wagered = tmpResult.user.stats.btc.wager / 100000000m;
                Stats.Profit  = tmpResult.user.stats.btc.profit / 100000000m;
                break;

            case "bxo":
                Stats.Balance = tmpResult.user.balances.bxo / 100000000m;
                Stats.Bets    = (int)tmpResult.user.stats.bxo.bets;
                Stats.Wagered = tmpResult.user.stats.bxo.wager / 100000000m;
                Stats.Profit  = tmpResult.user.stats.bxo.profit / 100000000m;
                break;

            case "clam":
                Stats.Balance = tmpResult.user.balances.clam / 100000000m;
                Stats.Bets    = (int)tmpResult.user.stats.clam.bets;
                Stats.Wagered = tmpResult.user.stats.clam.wager / 100000000m;
                Stats.Profit  = tmpResult.user.stats.clam.profit / 100000000m;
                break;

            case "doge":
                Stats.Balance = tmpResult.user.balances.doge / 100000000m;
                Stats.Bets    = (int)tmpResult.user.stats.doge.bets;
                Stats.Wagered = tmpResult.user.stats.doge.wager / 100000000m;
                Stats.Profit  = tmpResult.user.stats.doge.profit / 100000000m;
                break;

            case "eth":
                Stats.Balance = tmpResult.user.balances.eth / 100000000m;
                Stats.Bets    = (int)tmpResult.user.stats.eth.bets;
                Stats.Wagered = tmpResult.user.stats.eth.wager / 100000000m;
                Stats.Profit  = tmpResult.user.stats.eth.profit / 100000000m;
                break;

            case "flash":
                Stats.Balance = tmpResult.user.balances.flash / 100000000m;
                Stats.Bets    = (int)tmpResult.user.stats.flash.bets;
                Stats.Wagered = tmpResult.user.stats.flash.wager / 100000000m;
                Stats.Profit  = tmpResult.user.stats.flash.profit / 100000000m;
                break;

            case "ltc":
                Stats.Balance = tmpResult.user.balances.ltc / 100000000m;
                Stats.Bets    = (int)tmpResult.user.stats.ltc.bets;
                Stats.Wagered = tmpResult.user.stats.ltc.wager / 100000000m;
                Stats.Profit  = tmpResult.user.stats.ltc.profit / 100000000m;
                break;
            }
        }
コード例 #3
0
        bool getbalance()
        {
            string         response   = Client.GetStringAsync("user").Result;
            WDUserResponse tmpBalance = json.JsonDeserialize <WDUserResponse>(response);

            if (tmpBalance.data != null)
            {
                PropertyInfo tmp = typeof(WDBalance).GetProperty(CurrentCurrency.ToLower());
                if (tmp != null)
                {
                    decimal balance = (decimal)tmp.GetValue(tmpBalance.data.balance);
                    Stats.Balance = balance;
                }
            }
            return(tmpBalance.status == "success");
        }
コード例 #4
0
        protected override void _UpdateStats()
        {
            string         sEmitResponse = Client.GetStringAsync("user/balances").Result;
            WolfBetProfile tmpProfile    = json.JsonDeserialize <WolfBetProfile>(sEmitResponse);

            if (tmpProfile.user != null)
            {
                //set balance here
                foreach (Balance x in tmpProfile.user.balances)
                {
                    if (x.currency.ToLower() == CurrentCurrency.ToLower())
                    {
                        Stats.Balance = decimal.Parse(x.amount, System.Globalization.NumberFormatInfo.InvariantInfo);
                    }
                }
                //get stats
                //set stats
                sEmitResponse = Client.GetStringAsync("user/stats/bets").Result;
                WolfBetStats tmpStats = json.JsonDeserialize <WolfBetStats>(sEmitResponse);
                SetStats(tmpStats);
            }
        }
コード例 #5
0
ファイル: YoloDice.cs プロジェクト: hbernaciak/Doormat
        protected override void _Login(LoginParamValue[] LoginParams)
        {
            try
            {
                privkey   = LoginParams[0].Value;
                apiclient = new TcpClient();

                apiclient.Connect("api.yolodice.com", 4444);
                if (apiclient.Connected)
                {
                    sslStream = new SslStream(apiclient.GetStream());
                    sslStream.AuthenticateAsClient("api.yolodice.com");//, null, System.Security.Authentication.SslProtocols.Ssl2| System.Security.Authentication.SslProtocols.Ssl3| System.Security.Authentication.SslProtocols.Tls11|System.Security.Authentication.SslProtocols.Tls12, false);

                    string frstchallenge = string.Format(basestring, id++, "generate_auth_challenge", "");

                    sslStream.Write(Encoding.ASCII.GetBytes(frstchallenge));
                    int bytes = sslStream.Read(ReadBuffer, 0, 512);
                    challenge = Encoding.ASCII.GetString(ReadBuffer, 0, bytes);
                    YLChallenge tmp = null;
                    try
                    {
                        tmp = json.JsonDeserialize <YLChallenge>(challenge);
                    }
                    catch (Exception e)
                    {
                        callError("error: ", true, ErrorType.Other);
                        callLoginFinished(false);
                        return;
                    }
                    string address = "";
                    string message = "";
                    try
                    {
                        NBitcoin.Key tmpkey = NBitcoin.Key.Parse(privkey, NBitcoin.Network.Main);
                        address = tmpkey.ScriptPubKey.GetDestinationAddress(NBitcoin.Network.GetNetwork("Main")).ToString();
                        message = tmpkey.SignMessage(tmp.result);
                    }
                    catch (Exception e)
                    {
                        callError("API key format error. Are you using your Private key?", true, ErrorType.Other);
                        callLoginFinished(false);
                        return;
                    }
                    frstchallenge = string.Format(basestring, id++, "auth_by_address", ",\"params\":" + json.JsonSerializer <YLAuthSend>(new YLAuthSend {
                        address = address, signature = message
                    }));

                    sslStream.Write(Encoding.ASCII.GetBytes(frstchallenge));
                    bytes     = sslStream.Read(ReadBuffer, 0, 512);
                    challenge = Encoding.ASCII.GetString(ReadBuffer, 0, bytes);
                    YLOgin tmologin = null;
                    try
                    {
                        tmologin = json.JsonDeserialize <YLOgin>(challenge);
                    }
                    catch (Exception e)
                    {
                        callError("error: " + challenge, true, ErrorType.Other);
                        callLoginFinished(false);
                        return;
                    }

                    uid           = tmologin.result.id;
                    this.username = tmologin.result.name;
                    frstchallenge = string.Format(basestring, id++, "read_user_coin_data", ",\"params\":{\"selector\":{\"id\":\"" + uid + "_" + CurrentCurrency.ToLower() + "\"}}");
                    sslStream.Write(Encoding.ASCII.GetBytes(frstchallenge));
                    bytes     = sslStream.Read(ReadBuffer, 0, 512);
                    challenge = Encoding.ASCII.GetString(ReadBuffer, 0, bytes);
                    YLUserStats tmpstats = null;
                    try
                    {
                        tmpstats = json.JsonDeserialize <YLUserStats>(challenge).result;
                    }
                    catch (Exception e)
                    {
                        callError("error: " + challenge, true, ErrorType.Other);
                        callLoginFinished(false);
                        return;
                    }

                    if (tmpstats != null)
                    {
                        Stats.Balance = (decimal)tmpstats.balance / 100000000m;
                        Stats.Bets    = (int)tmpstats.bets;
                        Stats.Wins    = (int)tmpstats.wins;
                        Stats.Losses  = (int)tmpstats.losses;
                        Stats.Profit  = (decimal)tmpstats.profit / 100000000m;
                        Stats.Wagered = (decimal)tmpstats.wagered / 100000000m;
                        ispd          = true;
                        lastupdate    = DateTime.Now;
                        new Thread(new ThreadStart(BalanceThread)).Start();

                        new Thread(new ThreadStart(Beginreadthread)).Start();
                        Thread.Sleep(50);
                        callLoginFinished(true);

                        return;
                    }
                    //tmp2.ImportPrivKey(Password, "", false);
                    //string message = tmp2.SignMessage(username, tmp.result);
                    //string message = //FullSignatureTest(tmp.result, new AsymmetricCipherKeyPair("", ""));


                    /*ispd = true;
                     * new Thread(new ThreadStart(BalanceThread)).Start();*/
                }
            }
            catch (Exception e)
            {
                Logger.DumpLog(e);
            }
            callLoginFinished(false);
        }
コード例 #6
0
ファイル: YoloDice.cs プロジェクト: hbernaciak/Doormat
        public void PlaceDiceBet(PlaceDiceBet BetDetails)
        {
            this.Guid = BetDetails.GUID;

            string bet = string.Format(System.Globalization.NumberFormatInfo.InvariantInfo, "{{\"attrs\":{0}}}",
                                       json.JsonSerializer <YLBetSend>(
                                           new YLBetSend {
                amount = (long)(BetDetails.Amount * 100000000), range = BetDetails.High ? "hi" : "lo", target = (int)(BetDetails.Chance * 10000), coin = CurrentCurrency.ToLower()
            }));

            Write("create_bet", bet);
        }
コード例 #7
0
ファイル: YoloDice.cs プロジェクト: hbernaciak/Doormat
        void Auth()
        {
            inauth = true;
            try
            {
                apiclient.Close();
            }
            catch { }
            try
            {
                apiclient = new TcpClient();

                apiclient.Connect("api.yolodice.com", 4444);
                if (apiclient.Connected)
                {
                    sslStream = new SslStream(apiclient.GetStream());
                    sslStream.AuthenticateAsClient("https://api.yolodice.com");

                    string frstchallenge = string.Format(basestring, id++, "generate_auth_challenge", "");

                    sslStream.Write(Encoding.ASCII.GetBytes(frstchallenge));
                    int bytes = sslStream.Read(ReadBuffer, 0, 512);
                    challenge = Encoding.ASCII.GetString(ReadBuffer, 0, bytes);
                    YLChallenge tmp = null;
                    try
                    {
                        tmp = json.JsonDeserialize <YLChallenge>(challenge);
                    }
                    catch (Exception e)
                    {
                        Logger.DumpLog(e);
                        callError("error: " + challenge, true, ErrorType.Unknown);

                        /*finishedlogin(false);
                         * return;*/
                    }
                    NBitcoin.Key tmpkey  = NBitcoin.Key.Parse(privkey, NBitcoin.Network.Main);
                    string       address = tmpkey.ScriptPubKey.GetDestinationAddress(NBitcoin.Network.GetNetwork("Main")).ToString();
                    string       message = tmpkey.SignMessage(tmp.result);

                    frstchallenge = string.Format(basestring, id++, "auth_by_address", ",\"params\":" + json.JsonSerializer <YLAuthSend>(new YLAuthSend {
                        address = address, signature = message
                    }));

                    sslStream.Write(Encoding.ASCII.GetBytes(frstchallenge));
                    bytes     = sslStream.Read(ReadBuffer, 0, 512);
                    challenge = Encoding.ASCII.GetString(ReadBuffer, 0, bytes);
                    YLOgin tmologin = null;
                    try
                    {
                        tmologin = json.JsonDeserialize <YLOgin>(challenge);
                    }
                    catch (Exception e)
                    {
                        Logger.DumpLog(e);
                        callError("error: " + challenge, true, ErrorType.Unknown);

                        /*finishedlogin(false);
                         * return;*/
                    }

                    uid           = tmologin.result.id;
                    this.username = tmologin.result.name;
                    frstchallenge = string.Format(basestring, id++, "read_user_coin_data", ",\"params\":{\"selector\":{\"id\":\"" + uid + "_" + CurrentCurrency.ToLower() + "\"}}");
                    sslStream.Write(Encoding.ASCII.GetBytes(frstchallenge));
                    bytes     = sslStream.Read(ReadBuffer, 0, 512);
                    challenge = Encoding.ASCII.GetString(ReadBuffer, 0, bytes);
                    YLUserStats tmpstats = null;
                    try
                    {
                        tmpstats = json.JsonDeserialize <YLUserStats>(challenge).result;
                    }
                    catch (Exception e)
                    {
                        callError("error: " + challenge, true, ErrorType.Unknown);

                        /*finishedlogin(false);
                         * return;*/
                    }

                    if (tmpstats != null)
                    {
                        Stats.Balance = (decimal)tmpstats.balance / 100000000m;
                        Stats.Bets    = (int)tmpstats.bets;
                        Stats.Wins    = (int)tmpstats.wins;
                        Stats.Losses  = (int)tmpstats.losses;
                        Stats.Profit  = (decimal)tmpstats.profit / 100000000m;
                        Stats.Wagered = (decimal)tmpstats.wagered / 100000000m;
                        ispd          = true;
                        lastupdate    = DateTime.Now;
                        new Thread(new ThreadStart(BalanceThread)).Start();
                        new Thread(new ThreadStart(Beginreadthread)).Start();

                        inauth = false;

                        return;
                    }
                }
            }
            catch (Exception e)
            {
            }
            //finishedlogin(false);
            inauth = false;
        }
コード例 #8
0
ファイル: YoloDice.cs プロジェクト: hbernaciak/Doormat
 void create_withdrawal(string response)
 {
     Write("read_user_coin_data", "{\"selector\":{\"id\":\"" + uid + "_" + CurrentCurrency.ToLower() + "\"}}");
 }
コード例 #9
0
ファイル: YoloDice.cs プロジェクト: hbernaciak/Doormat
 protected override void _UpdateStats()
 {
     ForceUpdateStats = false;
     lastupdate       = DateTime.Now;
     Write("read_user_coin_data", "{\"selector\":{\"id\":\"" + uid + "_" + CurrentCurrency.ToLower() + "\"}}");
 }
コード例 #10
0
ファイル: PrimeDice.cs プロジェクト: hbernaciak/Doormat
        public void PlaceDiceBet(PlaceDiceBet BetDetails)
        {
            try
            {
                decimal amount = BetDetails.Amount;
                decimal chance = BetDetails.Chance;
                bool    High   = BetDetails.High;

                /*if (amount < 10000 && (DateTime.Now - Lastbet).TotalMilliseconds < 500)
                 * {
                 *  Thread.Sleep((int)(500.0 - (DateTime.Now - Lastbet).TotalMilliseconds));
                 * }*/
                decimal tmpchance = High ? MaxRoll - chance : chance;
                string  query     = "mutation{" + RolName + "(amount:" + amount.ToString("0.00000000", System.Globalization.NumberFormatInfo.InvariantInfo) + ", target:" + tmpchance.ToString("0.00", System.Globalization.NumberFormatInfo.InvariantInfo) + ",condition:" + (High ? "above" : "below") + ",currency:" + CurrentCurrency.ToLower() + ") { id nonce currency amount payout state { ... on " + GameName + " { result target condition } } createdAt serverSeed{seedHash seed nonce} clientSeed{seed} user{balances{available{amount currency}} statistic{game bets wins losses betAmount profit currency}}}}";
                //string query = "mutation {" + RolName + "(amount:" + amount.ToString("0.00000000", System.Globalization.NumberFormatInfo.InvariantInfo) + ", target:" + tmpchance.ToString("0.00", System.Globalization.NumberFormatInfo.InvariantInfo) + ",condition:" + (High ? "above" : "below") + ",currency:" + Currencies[Currency].ToLower() + ") { id iid nonce currency amount payout state { ... on " + GameName + " { result target condition } } createdAt serverSeed{seedHash seed nonce} clientSeed{seed} user{balances{available{amount currency}} statistic{game bets wins losses amount profit currency}}}}";
                //var primediceRoll = GQLClient.SendMutationAsync<dynamic>(new GraphQLRequest { Query = query }).Result;
                GraphQLResponse <RollDice> betresult = GQLClient.SendMutationAsync <RollDice>(new GraphQLRequest {
                    Query = query
                }).Result;

                RollDice tmp = betresult.Data.primediceRoll;

                Lastbet = DateTime.Now;
                try
                {
                    lastupdate = DateTime.Now;
                    foreach (Statistic x in tmp.user.statistic)
                    {
                        if (x.currency.ToLower() == Currencies[Currency].ToLower() && x.game == StatGameName)
                        {
                            this.Stats.Bets    = (int)x.bets;
                            this.Stats.Wins    = (int)x.wins;
                            this.Stats.Losses  = (int)x.losses;
                            this.Stats.Profit  = x.profit;
                            this.Stats.Wagered = x.amount;
                            break;
                        }
                    }
                    foreach (Balance x in tmp.user.balances)
                    {
                        if (x.available.currency.ToLower() == Currencies[Currency].ToLower())
                        {
                            this.Stats.Balance = x.available.amount;
                            break;
                        }
                    }
                    DiceBet tmpbet = tmp.ToBet();
                    tmpbet.IsWin = tmpbet.GetWin(this);
                    tmpbet.Guid  = BetDetails.GUID;
                    callBetFinished(tmpbet);
                    retrycount = 0;
                }
                catch (Exception e)
                {
                    Logger.DumpLog(e);
                    callNotify("Some kind of error happened. I don't really know graphql, so your guess as to what went wrong is as good as mine.");
                }
            }
            catch (Exception e2)
            {
                callNotify("Error occured while trying to bet, retrying in 30 seconds. Probably.");
                Logger.DumpLog(e2);
            }
        }
コード例 #11
0
        void ProcessBalance(string Res)
        {
            BEBalanceBase tmpResult = json.JsonDeserialize <BEBalanceBase>(Res);

            if (LoginStarted)
            {
                LoginTimer.Enabled = false;
                LoginStarted       = false;
                callLoginFinished(true);
            }
            switch (CurrentCurrency.ToLower())
            {
            case "btc":
                Stats.Balance = tmpResult.user.balances.btc / 100000000m;
                Stats.Bets    = (int)tmpResult.user.stats.btc.bets;
                Stats.Wagered = tmpResult.user.stats.btc.wager / 100000000m;
                Stats.Profit  = tmpResult.user.stats.btc.profit / 100000000m;
                break;

            case "bxo":
                Stats.Balance = tmpResult.user.balances.bxo / 100000000m;
                Stats.Bets    = (int)tmpResult.user.stats.bxo.bets;
                Stats.Wagered = tmpResult.user.stats.bxo.wager / 100000000m;
                Stats.Profit  = tmpResult.user.stats.bxo.profit / 100000000m;
                break;

            case "clam":
                Stats.Balance = tmpResult.user.balances.clam / 100000000m;
                Stats.Bets    = (int)tmpResult.user.stats.clam.bets;
                Stats.Wagered = tmpResult.user.stats.clam.wager / 100000000m;
                Stats.Profit  = tmpResult.user.stats.clam.profit / 100000000m;
                break;

            case "doge":
                Stats.Balance = tmpResult.user.balances.doge / 100000000m;
                Stats.Bets    = (int)tmpResult.user.stats.doge.bets;
                Stats.Wagered = tmpResult.user.stats.doge.wager / 100000000m;
                Stats.Profit  = tmpResult.user.stats.doge.profit / 100000000m;
                break;

            case "eth":
                Stats.Balance = tmpResult.user.balances.eth / 100000000m;
                Stats.Bets    = (int)tmpResult.user.stats.eth.bets;
                Stats.Wagered = tmpResult.user.stats.eth.wager / 100000000m;
                Stats.Profit  = tmpResult.user.stats.eth.profit / 100000000m;
                break;

            case "flash":
                Stats.Balance = tmpResult.user.balances.flash / 100000000m;
                Stats.Bets    = (int)tmpResult.user.stats.flash.bets;
                Stats.Wagered = tmpResult.user.stats.flash.wager / 100000000m;
                Stats.Profit  = tmpResult.user.stats.flash.profit / 100000000m;
                break;

            case "ltc":
                Stats.Balance = tmpResult.user.balances.ltc / 100000000m;
                Stats.Bets    = (int)tmpResult.user.stats.ltc.bets;
                Stats.Wagered = tmpResult.user.stats.ltc.wager / 100000000m;
                Stats.Profit  = tmpResult.user.stats.ltc.profit / 100000000m;
                break;
            }
            callStatsUpdated(Stats);
        }
コード例 #12
0
 protected override void _Login(LoginParamValue[] LoginParams)
 {
     ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
                                            | SecurityProtocolType.Tls11
                                            | SecurityProtocolType.Tls12;
     ClientHandlr = new HttpClientHandler {
         UseCookies = true, AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip
     };
     Client = new HttpClient(ClientHandlr)
     {
         BaseAddress = new Uri(URL + "/api/v1/")
     };
     Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("gzip"));
     Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("deflate"));
     Client.DefaultRequestHeaders.Add("UserAgent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36");
     Client.DefaultRequestHeaders.Add("Origin", "https://wolf.bet");
     Client.DefaultRequestHeaders.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9");
     try
     {
         string Password = LoginParams.First(m => m.Param?.Name?.ToLower() == "api key").Value;
         if (Password != null)
         {
             Client.DefaultRequestHeaders.Add("authorization", "Bearer " + Password);
         }
         string sEmitResponse = Client.GetStringAsync("user/balances").Result;
         try
         {
             WolfBetProfile tmpProfile = json.JsonDeserialize <WolfBetProfile>(sEmitResponse);
             if (tmpProfile.balances != null)
             {
                 //set balance here
                 foreach (Balance x in tmpProfile.balances)
                 {
                     if (x.currency.ToLower() == CurrentCurrency.ToLower())
                     {
                         Stats.Balance = decimal.Parse(x.amount, System.Globalization.NumberFormatInfo.InvariantInfo);
                     }
                 }
                 //get stats
                 //set stats
                 sEmitResponse = Client.GetStringAsync("user/stats/bets").Result;
                 WolfBetStats tmpStats = json.JsonDeserialize <WolfBetStats>(sEmitResponse);
                 SetStats(tmpStats);
                 ispd       = true;
                 lastupdate = DateTime.Now;
                 new Thread(new ThreadStart(GetBalanceThread)).Start();
                 this.callLoginFinished(true);
                 return;
             }
         }
         catch (Exception e)
         {
             Logger.DumpLog(e);
             Logger.DumpLog(sEmitResponse, 2);
             callError(sEmitResponse, false, ErrorType.Unknown);
             callNotify("Error: " + sEmitResponse);
         }
     }
     catch (Exception e)
     {
         Logger.DumpLog(e.ToString(), -1);
     }
     this.callLoginFinished(false);
 }