Esempio n. 1
0
        public static bool IsReach()
        {
            try
            {
                modules.getData checkServer = new modules.getData("http://minerstat.farm/server.php", "POST", "");

                string res;
                res = checkServer.GetResponse().ToString();

                if (res.Contains("ok"))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }
Esempio n. 2
0
        async public static void loop(object sender, ElapsedEventArgs exw)
        {
            wclient = new WebSocket(host);



            try
            {
                if (modules.checkNet(false) == false)
                {
                    Program.NewMessage("SYNC => Skip: CONNECTION LOST", "ERROR");
                    Program.connectionError = true;
                }
                else
                {
                    if (modules.IsReach().Equals(false))
                    {
                        Program.NewMessage("SYNC => Skip: MINERSTAT UNREACHABLE", "ERROR");
                        Program.connectionError = true;
                    }
                    else
                    {
                        // SET null
                        apiResponse             = "";
                        apiHardware             = "";
                        apiCpu                  = "";
                        Program.connectionError = false;


                        // CHECK IP
                        if (Program.currentIP.Equals("0.0.0.0"))
                        {
                            Program.currentIP = modules.GetUserIP();
                        }

                        // 1) PREPARE THE URL'S if Needed
                        switch (mining.minerDefault.ToLower())
                        {
                        case "cast-xmr":
                            monitorURL = "http://127.0.0.1:7777";
                            break;

                        case "xmr-stak":
                            monitorURL = "http://127.0.0.1:2222/api.json";
                            break;

                        case "xmrig-amd":
                            monitorURL = "http://127.0.0.1:4028/";
                            break;

                        case "xmrig-nvidia":
                            monitorURL = "http://127.0.0.1:4028/";
                            break;

                        case "wildrig-multi":
                            monitorURL = "http://127.0.0.1:4028/";
                            break;

                        case "trex":
                            monitorURL = "http://127.0.0.1:4068/summary";
                            break;

                        case "bminer":
                            monitorURL = "http://127.0.0.1:1880/api/status";
                            break;

                        case "lolminer":
                            monitorURL = "http://127.0.0.1:3333/summary";
                            break;

                        case "gminer":
                            monitorURL = "http://127.0.0.1:3333/api/v1/status";
                            break;

                        case "grinprominer":
                            monitorURL = "http://127.0.0.1:5777/api/status";
                            break;

                        case "srbminer":
                            monitorURL = "http://127.0.0.1:21555";
                            break;

                        case "claymore-zec":
                            monitorURL = "http://127.0.0.1:3333";
                            break;
                        }


                        // 2) Fetch API's
                        if (mining.minerDefault.ToLower().Contains("ccminer") || mining.minerDefault.ToLower().Contains("cryptodredge") || mining.minerDefault.ToLower().Contains("z-enemy"))
                        {
                            modules.getStat();
                        }
                        if (mining.minerDefault.ToLower().Contains("ewbf"))
                        {
                            modules.getStat_ewbf();
                        }
                        if (mining.minerDefault.ToLower().Contains("zm-zec"))
                        {
                            modules.getStat_zm();
                        }
                        if (mining.minerDefault.ToLower().Contains("phoenix-eth") || mining.minerDefault.ToLower().Contains("claymore-eth") || mining.minerDefault.ToLower().Contains("claymore-xmr") || mining.minerDefault.ToLower().Contains("claymore-neoscrypt"))
                        {
                            modules.getStat_claymore();
                        }
                        if (mining.minerDefault.ToLower().Contains("ethminer") || mining.minerDefault.ToLower().Contains("progpowminer"))
                        {
                            modules.getStat_ethminer();
                        }
                        if (mining.minerDefault.ToLower().Contains("mkxminer"))
                        {
                            modules.getStat_mkxminer();
                        }
                        if (mining.minerDefault.ToLower().Contains("gateless"))
                        {
                            modules.getStat_sgminer();
                        }
                        if (mining.minerDefault.ToLower().Contains("miniz"))
                        {
                            modules.getStat_miniz();
                        }
                        if (mining.minerDefault.ToLower().Contains("cast-xmr") || mining.minerDefault.ToLower().Contains("xmr-stak") || mining.minerDefault.ToLower().Contains("claymore-zec") || mining.minerDefault.ToLower().Contains("bminer") || mining.minerDefault.ToLower().Contains("trex") || mining.minerDefault.ToLower().Contains("grinprominer") || mining.minerDefault.ToLower().Contains("lolminer") || mining.minerDefault.ToLower().Contains("srbminer") || mining.minerDefault.ToLower().Contains("xmrig-amd") || mining.minerDefault.ToLower().Contains("xmrig-nvidia") || mining.minerDefault.ToLower().Contains("wildrig-multi") || mining.minerDefault.ToLower().Equals("gminer"))
                        {
                            string          input;
                            HttpWebRequest  request  = (HttpWebRequest)WebRequest.Create(monitorURL);
                            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                            StreamReader    sr       = new StreamReader(response.GetResponseStream());
                            input = sr.ReadToEnd();
                            sr.Close();
                            apiResponse = input;
                        }
                        if (mining.minerDefault.ToLower().Contains("sgminer") || mining.minerDefault.ToLower().Contains("teamredminer"))
                        {
                            modules.getStat_sgminer();
                        }

                        // Hardware Monitor
                        modules.getData hwQuery = new modules.getData("http://*****:*****@Program.minerstatDir + "/test.json", JsonConvert.SerializeObject(API));

                            wclient.Send(JsonConvert.SerializeObject(API));

                            //Program.NewMessage(JsonConvert.SerializeObject(API), "");

                            if (apiResponse.Equals(""))
                            {
                                Program.NewMessage("ERROR => UNABLE TO FETCH MINER API.", "");
                            }
                        }
                        catch (Exception ex) { Program.NewMessage("ERROR => " + ex.ToString(), ""); }
                    }
                }
            }
            catch (Exception error)
            {
                Program.NewMessage("ERROR => " + error.ToString(), "");
            }
        }
Esempio n. 3
0
        async public static void Start()
        {
            minerCpu           = "false";
            Program.SyncStatus = false;

            if (Program.StartDelayOver.Equals(false))
            {
                Program.SyncStatus = false;
                Program.NewMessage("INFO => STARTED WITH WINDOWS", "INFO");
                Program.NewMessage("INFO => Programmed mining start delay: " + Program.StartDelay + "ms", "INFO");
                await Task.Delay(Program.StartDelay);

                Program.StartDelayOver = true;
                Program.SyncStatus     = true;
            }

            if (CheckforUpdates().Equals(true))
            {
                StartUpdate();
                Application.Exit();
            }

            _instanceMainForm.Invoke((MethodInvoker) delegate {
                _instanceMainForm.TopMost = true;
            });

            try
            {
                if (File.Exists(@Program.minerstatDir + "/user.json"))
                {
                    string json = File.ReadAllText(@Program.minerstatDir + "/user.json");
                    Program.loginjson = json;

                    var jObject = Newtonsoft.Json.Linq.JObject.Parse(json);
                    Program.token  = (string)jObject["token"];
                    Program.worker = (string)jObject["worker"];
                }

                downloadConfig(Program.token, Program.worker);

                if (!Directory.Exists(@Program.currentDir + "/clients"))
                {
                    Directory.CreateDirectory(@Program.currentDir + "/clients");
                }

                modules.getData minersVersion = new modules.getData("https://static.minerstat.farm/miners/windows/version.json", "POST", "");
                string          version       = minersVersion.GetResponse();

                var vObject      = Newtonsoft.Json.Linq.JObject.Parse(version);
                var minerVersion = (string)vObject[minerDefault.ToLower()];
                cpuVersion = (string)vObject[cpuDefault.ToLower()];

                // main MINER

                if (!Directory.Exists(Program.currentDir + "/clients/" + minerDefault.ToLower() + "/"))
                {
                    Directory.CreateDirectory(Program.currentDir + "/clients/" + minerDefault.ToLower() + "/");
                }

                string localMinerVersion;

                if (File.Exists(Program.currentDir + "/clients/" + minerDefault.ToLower() + "/minerVersion.txt"))
                {
                    localMinerVersion = File.ReadAllText(Program.currentDir + "/clients/" + minerDefault.ToLower() + "/minerVersion.txt");
                }
                else
                {
                    localMinerVersion = "0";
                }

                if (!File.Exists(Program.currentDir + "/clients/" + minerDefault.ToLower() + "/minerUpdated.txt") || !localMinerVersion.Equals(minerVersion))
                {
                    // DELETE ALL FILES
                    System.IO.DirectoryInfo di = new DirectoryInfo(Program.currentDir + "/clients/" + minerDefault.ToLower() + "/");

                    foreach (FileInfo file in di.GetFiles())
                    {
                        file.Delete();
                    }
                    foreach (DirectoryInfo dir in di.GetDirectories())
                    {
                        dir.Delete(true);
                    }

                    Downloader.minerVersion = minerVersion;

                    // DOWNLOAD FRESH PACKAGE
                    Downloader.downloadFile(minerDefault.ToLower() + ".zip", minerDefault.ToLower(), "main");
                    Program.SyncStatus = false;
                }
                else
                {
                    await Task.Delay(1500);

                    Program.NewMessage("CONFIG => Default miner: " + minerDefault, "INFO");
                    Program.NewMessage("CONFIG => Worker type: " + minerType, "INFO");
                    Program.NewMessage("CONFIG => CPU Mining: " + minerCpu, "INFO");
                    Program.NewMessage(minerDefault.ToUpper() + " => " + minerConfig, "INFO");
                    // Start miner
                    Program.NewMessage("NODE => Waiting for the next sync..", "INFO");

                    Program.SyncStatus = true;
                    startMiner(true, false);

                    // Start watchDog
                    Program.watchDogs.Start();

                    // Start Crash Protection
                    //Program.crashLoop.Start();

                    // Start SYNC & Remote Command
                    Program.syncLoop.Start();
                }
            }
            catch (Exception ex)
            {
                Program.NewMessage(ex.ToString(), "");
            }
        }
Esempio n. 4
0
        public static void downloadConfig(string token, string worker)
        {
            try
            {
                modules.getData nodeConfig = new modules.getData("https://api.minerstat.com/v2/node/gpu/" + token + "/" + worker, "POST", "");
                configJSON = nodeConfig.GetResponse();

                var jObject = Newtonsoft.Json.Linq.JObject.Parse(configJSON);
                minerDefault   = (string)jObject["default"];
                cpuDefault     = (string)jObject["cpuDefault"];
                minerType      = (string)jObject["type"];
                minerOverclock = JsonConvert.SerializeObject(jObject["overclock"]);
                minerCpu       = (string)jObject["cpu"];

                modules.getData configRequest = new modules.getData("https://api.minerstat.com/v2/conf/gpu/" + token + "/" + worker + "/" + minerDefault.ToLower(), "POST", "");
                minerConfig = configRequest.GetResponse();

                string fileExtension = "start.bat";

                if (minerDefault.Contains("claymore"))
                {
                    fileExtension = "config.txt";
                }
                if (minerDefault.Contains("phoenix"))
                {
                    fileExtension = "config.txt";
                }
                if (minerDefault.Contains("sgminer"))
                {
                    fileExtension = "sgminer.conf";
                }
                if (minerDefault.Contains("xmr-stak"))
                {
                    fileExtension = "pools.txt";
                }
                if (minerDefault.Contains("trex"))
                {
                    fileExtension = "config.json";
                }

                string folderPath = Program.currentDir + "/clients/" + minerDefault + "/" + fileExtension;
                File.WriteAllText(@folderPath, minerConfig);

                if (minerCpu.Equals("True"))
                {
                    modules.getData cpuRequest = new modules.getData("https://api.minerstat.com/v2/conf/gpu/" + token + "/" + worker + "/" + cpuDefault.ToLower(), "POST", "");
                    cpuConfig = cpuRequest.GetResponse();

                    switch (cpuDefault.ToLower())
                    {
                    case "xmr-stak-cpu":
                        cpuConfigFile = "config.txt";
                        break;

                    case "cpuminer-opt":
                        cpuConfigFile = "start.bat";
                        break;

                    case "xmrig":
                        cpuConfigFile = "config.json";
                        break;
                    }

                    string folderPathCpu = Program.currentDir + "/clients/" + cpuDefault.ToLower() + "/" + cpuConfigFile;
                    File.WriteAllText(@folderPathCpu, cpuConfig);
                }

                if (!JsonConvert.SerializeObject(jObject["overclock"]).Equals(""))
                {
                    if (Process.GetProcessesByName("msiafterburner").Length > 0)
                    {
                        try
                        {
                            Program.NewMessage("OVERCLOCK => " + JsonConvert.SerializeObject(jObject["overclock"]), "WARNING");
                        } catch (Exception) { }
                        var mObject     = Newtonsoft.Json.Linq.JObject.Parse(JsonConvert.SerializeObject(jObject["overclock"]));
                        var coreclock   = (string)mObject["coreclock"];
                        var memoryclock = (string)mObject["memoryclock"];
                        var powerlimit  = (string)mObject["powerlimit"];
                        var fan         = (string)mObject["fan"];
                        if (coreclock.Equals("skip"))
                        {
                            coreclock = "9999";
                        }
                        if (memoryclock.Equals("skip"))
                        {
                            memoryclock = "9999";
                        }
                        if (powerlimit.Equals("skip"))
                        {
                            powerlimit = "9999";
                        }
                        if (fan.Equals("skip"))
                        {
                            fan = "9999";
                        }
                        clocktune.Manual(minerType, Convert.ToInt32(powerlimit), Convert.ToInt32(coreclock), Convert.ToInt32(fan), Convert.ToInt32(memoryclock));
                    }
                    else
                    {
                        Program.NewMessage("WARNING => Install MSI Afterburner to enable overclocking", "WARNING");
                    }
                }

                // Delete pending remote commands
                modules.getData response       = new modules.getData("https://api.minerstat.com/v2/get_command_only.php?token=" + Program.token + "&worker=" + Program.worker, "POST", "");
                string          responseString = response.GetResponse();

                if (!responseString.Equals(""))
                {
                    Program.NewMessage("PENDING COMMAND REMOVED  => " + responseString, "");
                }
            }
            catch (Exception ex) { Console.WriteLine(ex.ToString()); }
        }
Esempio n. 5
0
        public static void downloadConfig(string token, string worker)
        {
            try
            {
                modules.getData nodeConfig = new modules.getData("https://api.minerstat.com/v2/node/gpu/" + token + "/" + worker, "POST", "");
                configJSON = nodeConfig.GetResponse();

                var jObject = Newtonsoft.Json.Linq.JObject.Parse(configJSON);
                minerDefault   = (string)jObject["default"];
                cpuDefault     = (string)jObject["cpuDefault"];
                minerType      = (string)jObject["type"];
                minerOverclock = JsonConvert.SerializeObject(jObject["overclock"]);
                minerCpu       = (string)jObject["cpu"];

                if (benchmark.Equals("NO"))
                {
                    modules.getData configRequest = new modules.getData("https://api.minerstat.com/v2/conf/gpu/" + token + "/" + worker + "/" + minerDefault.ToLower(), "POST", "");
                    minerConfig = configRequest.GetResponse();
                }
                else
                {
                    minerDefault = BenchMark.B_CLIENT.ToLower();
                    minerConfig  = BenchMark.B_CONFIG;
                }

                string fileExtension = "start.bat";

                if (minerDefault.Contains("claymore"))
                {
                    fileExtension = "config.txt";
                }
                if (minerDefault.Contains("phoenix"))
                {
                    fileExtension = "config.txt";
                }
                if (minerDefault.Contains("sgminer"))
                {
                    fileExtension = "sgminer.conf";
                }
                if (minerDefault.Contains("xmr-stak"))
                {
                    fileExtension = "pools.txt";
                }
                if (minerDefault.Contains("trex"))
                {
                    fileExtension = "config.json";
                }
                if (minerDefault.Contains("lolminer"))
                {
                    fileExtension = "user_config.json";
                }

                string folderPath = Program.currentDir + "/clients/" + minerDefault + "/" + fileExtension;
                File.WriteAllText(@folderPath, minerConfig);

                if (minerCpu.Equals("True"))
                {
                    modules.getData cpuRequest = new modules.getData("https://api.minerstat.com/v2/conf/gpu/" + token + "/" + worker + "/" + cpuDefault.ToLower(), "POST", "");
                    cpuConfig = cpuRequest.GetResponse();

                    switch (cpuDefault.ToLower())
                    {
                    case "xmr-stak-cpu":
                        cpuConfigFile = "config.txt";
                        break;

                    case "cpuminer-opt":
                        cpuConfigFile = "start.bat";
                        break;

                    case "xmrig":
                        cpuConfigFile = "config.json";
                        break;
                    }

                    string folderPathCpu = Program.currentDir + "/clients/" + cpuDefault.ToLower() + "/" + cpuConfigFile;
                    File.WriteAllText(@folderPathCpu, cpuConfig);
                }

                if (!JsonConvert.SerializeObject(jObject["overclock"]).Equals(""))
                {
                    if (Process.GetProcessesByName("msiafterburner").Length > 0)
                    {
                        try
                        {
                            Program.NewMessage("CLOCKTUNE => " + JsonConvert.SerializeObject(jObject["overclock"]), "WARNING");
                        }
                        catch (Exception clockTuneJson)
                        {
                            //MessageBox.Show(clockTuneJson.ToString());
                        }

                        try
                        {
                            var mObject     = Newtonsoft.Json.Linq.JObject.Parse(JsonConvert.SerializeObject(jObject["overclock"]));
                            var coreclock   = (string)mObject["coreclock"];
                            var memoryclock = (string)mObject["memoryclock"];
                            var powerlimit  = (string)mObject["powerlimit"];
                            var fan         = (string)mObject["fan"];

                            if (coreclock.Contains(" ") || memoryclock.Contains(" ") || powerlimit.Contains(" ") || fan.Contains(" "))
                            {
                                string[] coreArray   = explode(" ", coreclock);
                                string[] memoryArray = explode(" ", memoryclock);
                                string[] fanArray    = explode(" ", fan);
                                string[] powerArray  = explode(" ", powerlimit);

                                for (int i = 0; i <= 16; i++)
                                {
                                    coreclock   = coreArray[i];
                                    memoryclock = memoryArray[i];
                                    powerlimit  = powerArray[i];
                                    fan         = fanArray[i];

                                    if (coreclock.Equals("skip"))
                                    {
                                        coreclock = "9999";
                                    }
                                    if (memoryclock.Equals("skip"))
                                    {
                                        memoryclock = "9999";
                                    }
                                    if (powerlimit.Equals("skip"))
                                    {
                                        powerlimit = "9999";
                                    }
                                    if (fan.Equals("skip"))
                                    {
                                        fan = "9999";
                                    }

                                    if (!string.IsNullOrWhiteSpace(coreclock))
                                    {
                                        if (!coreclock.Equals("9999") && !memoryclock.Equals("9999") && !powerlimit.Equals("9999") && !fan.Equals("9999"))
                                        {
                                            clocktune.Advanced(minerType, Convert.ToInt32(powerlimit), Convert.ToInt32(coreclock), Convert.ToInt32(fan), Convert.ToInt32(memoryclock), i);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                if (coreclock.Equals("skip"))
                                {
                                    coreclock = "9999";
                                }
                                if (memoryclock.Equals("skip"))
                                {
                                    memoryclock = "9999";
                                }
                                if (powerlimit.Equals("skip"))
                                {
                                    powerlimit = "9999";
                                }
                                if (fan.Equals("skip"))
                                {
                                    fan = "9999";
                                }
                                if (!coreclock.Equals("9999") && !memoryclock.Equals("9999") && !powerlimit.Equals("9999") && !fan.Equals("9999"))
                                {
                                    clocktune.Manual(minerType, Convert.ToInt32(powerlimit), Convert.ToInt32(coreclock), Convert.ToInt32(fan), Convert.ToInt32(memoryclock));
                                }
                            }
                        }
                        catch (Exception clockTuneErrorII)
                        {
                            Program.NewMessage("Use afterburner 4.5.0 version to use ClockTune.", "ERROR");
                            Program.NewMessage("Use afterburner 4.5.0 version to use ClockTune.", "ERROR");
                        }
                    }
                    else
                    {
                        Program.NewMessage("WARNING => MSIAfterburner.exe is not running..", "INFO");
                        Program.NewMessage("WARNING => Install & Run - MSI Afterburner to enable overclocking", "WARNING");
                    }
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.ToString());
            }
        }
Esempio n. 6
0
        async public static void Start()
        {
            minerCpu           = "false";
            minerStarted       = "NO";
            Program.SyncStatus = false;

            if (Program.StartDelayOver.Equals(false))
            {
                Program.SyncStatus = false;
                Program.NewMessage("INFO => STARTED WITH WINDOWS", "INFO");
                Program.NewMessage("INFO => Programmed mining start delay: " + Program.StartDelay + "ms", "INFO");
                await Task.Delay(Program.StartDelay);

                Program.StartDelayOver = true;
                Program.SyncStatus     = true;
            }

            if (CheckforUpdates().Equals(true))
            {
                StartUpdate();
                Application.Exit();
            }

            _instanceMainForm.Invoke((MethodInvoker) delegate {
                _instanceMainForm.TopMost = true;
            });

            try
            {
                if (File.Exists(@Program.minerstatDir + "/user.json"))
                {
                    string json = File.ReadAllText(@Program.minerstatDir + "/user.json");
                    Program.loginjson = json;

                    var jObject = Newtonsoft.Json.Linq.JObject.Parse(json);
                    Program.token  = (string)jObject["token"];
                    Program.worker = (string)jObject["worker"];
                }

                downloadConfig(Program.token, Program.worker);

                if (!Directory.Exists(@Program.currentDir + "/clients"))
                {
                    Directory.CreateDirectory(@Program.currentDir + "/clients");
                }

                // Delete pending remote commands
                modules.getData response       = new modules.getData("https://api.minerstat.com/v2/get_command_only.php?token=" + Program.token + "&worker=" + Program.worker, "POST", "");
                string          responseString = response.GetResponse();

                if (!responseString.Equals(""))
                {
                    Program.NewMessage("PENDING COMMAND REMOVED  => " + responseString, "");
                }

                modules.getData minersVersion = new modules.getData("https://static-ssl.minerstat.farm/miners/windows/version.json", "POST", "");
                string          version       = minersVersion.GetResponse();

                var vObject      = Newtonsoft.Json.Linq.JObject.Parse(version);
                var minerVersion = (string)vObject[minerDefault.ToLower()];
                cpuVersion = (string)vObject[cpuDefault.ToLower()];

                // main MINER
                if (!Directory.Exists(Program.currentDir + "/clients/" + minerDefault.ToLower() + "/"))
                {
                    Directory.CreateDirectory(Program.currentDir + "/clients/" + minerDefault.ToLower() + "/");
                }

                string localMinerVersion;

                if (File.Exists(Program.currentDir + "/clients/" + minerDefault.ToLower() + "/minerVersion.txt"))
                {
                    localMinerVersion = File.ReadAllText(Program.currentDir + "/clients/" + minerDefault.ToLower() + "/minerVersion.txt");
                }
                else
                {
                    localMinerVersion = "0";
                }

                if (!File.Exists(Program.currentDir + "/clients/" + minerDefault.ToLower() + "/minerUpdated.txt") && !File.Exists(Program.minerstatDir + "/buffer.txt") || !localMinerVersion.Equals(minerVersion) && !File.Exists(Program.minerstatDir + "/buffer.txt"))
                {
                    // ECHO  WORK IN PROGRESS
                    Program.NewMessage("INFO => Download new version of: " + minerDefault.ToLower(), "");

                    if (!localMinerVersion.Equals(minerVersion) && (localMinerVersion != "0"))
                    {
                        try
                        {
                            // DELETE ALL FILES
                            System.IO.DirectoryInfo di = new DirectoryInfo(Program.currentDir + "/clients/" + minerDefault.ToLower() + "/");

                            foreach (FileInfo file in di.GetFiles())
                            {
                                file.Delete();
                            }
                            foreach (DirectoryInfo dir in di.GetDirectories())
                            {
                                dir.Delete(true);
                            }

                            await Task.Delay(1000);

                            Directory.Delete(Program.currentDir + "/clients/" + minerDefault.ToLower(), true);

                            await Task.Delay(1000);

                            if (!Directory.Exists(Program.currentDir + "/clients/" + minerDefault.ToLower()))
                            {
                                Directory.CreateDirectory(Program.currentDir + "/clients/" + minerDefault.ToLower());
                            }
                        }
                        catch (Exception) { }
                    }

                    await Task.Delay(500);

                    if (!Directory.Exists(Program.currentDir + "/clients/" + minerDefault.ToLower()))
                    {
                        Directory.CreateDirectory(Program.currentDir + "/clients/" + minerDefault.ToLower());
                    }

                    Downloader.minerVersion = minerVersion;

                    // DOWNLOAD FRESH PACKAGE
                    await Task.Delay(6500);

                    Downloader.downloadFile(minerDefault.ToLower() + ".zip", minerDefault.ToLower(), "main");
                    Program.SyncStatus = false;
                }
                else
                {
                    await Task.Delay(1500);

                    Program.NewMessage("CONFIG => Default miner: " + minerDefault, "INFO");
                    Program.NewMessage("CONFIG => Worker type: " + minerType, "INFO");
                    Program.NewMessage("CONFIG => CPU Mining: " + minerCpu, "INFO");
                    Program.NewMessage(minerDefault.ToUpper() + " => " + minerConfig, "INFO");
                    // Start miner
                    Program.NewMessage("NODE => Waiting for the next sync..", "INFO");

                    Program.SyncStatus = true;
                    startMiner(true, false);

                    // Start watchDog
                    Program.watchDogs.Start();

                    // Start Crash Protection
                    //Program.crashLoop.Start();
                    // Start SYNC & Remote Command
                    Program.syncLoop.Start();

                    // ETHPILL
                    await Task.Delay(1500);

                    try
                    {
                        if (minerType.ToLower().Equals("nvidia"))
                        {
                            // Hardware Monitor
                            // ONLY FOR: 1080, 1080Ti, Titan XP
                            modules.getData hwQuery     = new modules.getData("http://localhost:" + Program.monitorport + "/", "POST", "");
                            string          HardwareLog = hwQuery.GetResponse();

                            if (HardwareLog.ToString().ToLower().Contains("1080") || HardwareLog.ToString().ToLower().Contains("1080 ti") || HardwareLog.ToString().ToLower().Contains("titan xp"))
                            {
                                //Program.NewMessage("ETHPill => Compatible device(s) detected", "INFO");
                                if (Process.GetProcessesByName("OhGodAnETHlargementPill-r2").Length == 0)
                                {
                                    // Does your ETHlargement not work as expected? You're likely running an older memory revision.
                                    // With the use of --revA, you can specify which device should be fed our senior solution.If, for example, GPU 0, 3 and 4 aren't the young studs you thought they were, feed them with the following commands:
                                    // OhGodAnETHlargementPill-r2.exe --revA 0,3,4 at ~/minerstat-windows/mist/OhGodAnETHlargementPill-r2-args.txt
                                    //string pillPath = '"' + Program.currentDir + "/mist/" + '"';
                                    string pillArgs = "OhGodAnETHlargementPill-r2.exe";

                                    try
                                    {
                                        pillArgs = File.ReadAllText(Program.currentDir + "/mist/OhGodAnETHlargementPill-r2-args.txt").Split(new[] {
                                            '\r',
                                            '\n'
                                        }).FirstOrDefault();
                                    }
                                    catch (Exception)
                                    {
                                        pillArgs = "OhGodAnETHlargementPill-r2.exe";
                                    }

                                    Process.Start("CMD.exe", "/c " + Program.currentDir + "/mist/" + pillArgs);
                                    Program.NewMessage("ETHPill => Starting in a new window", "INFO");
                                }
                                else
                                {
                                    Program.NewMessage("ETHPill => Already running", "INFO");
                                }
                            }
                        }
                    }
                    catch (Exception) { }
                }
            }
            catch (Exception ex)
            {
                Program.NewMessage(ex.ToString(), "");
                if (ex.ToString().ToLower().Contains("json") || ex.ToString().ToLower().Contains("urlencoded"))
                {
                    Program.watchDogs.Stop();
                    Program.syncLoop.Stop();
                    Program.offlineLoop.Stop();
                    mining.killAll();

                    await Task.Delay(2000);

                    Program.offlineLoop.Start();
                    Start();
                }
            }
        }
Esempio n. 7
0
        async public static void Start()
        {
            modules.getData nodeConfig = new modules.getData("https://api.minerstat.com/v2/benchmark/" + Program.token + "/" + Program.worker, "POST", "");
            JSON = nodeConfig.GetResponse();

            mining.benchmark = "YES";

            dynamic B_JSON = JsonConvert.DeserializeObject(JSON);

            foreach (var B_ITEM in B_JSON)
            {
                if (mining.benchmark.Equals("NO"))
                {
                    break;
                }

                int delay = 70000;

                B_ID       = B_ITEM.id;
                B_HASH     = B_ITEM.hash;
                B_DURATION = B_ITEM.duration;
                B_CLIENT   = B_ITEM.client;
                B_CONFIG   = B_ITEM.config;

                mining.minerDefault = B_CLIENT.ToLower();

                Program.NewMessage("BENCHMARK => " + B_CLIENT + " / " + B_HASH, "");

                if (B_DURATION.Equals("slow"))
                {
                    delay = 120000;
                }
                if (B_DURATION.Equals("medium"))
                {
                    delay = 70000;
                }
                if (B_DURATION.Equals("fast"))
                {
                    delay = 45000;
                }

                int delaysec = (delay / 1000) - 2;

                mining.Start();

                while (mining.minerStarted == "NO")
                {
                    if (mining.minerStarted.Equals("YES"))
                    {
                        break;
                    }
                    try {
                        Program.watchDogs.Stop();
                        Program.syncLoop.Stop();
                    }
                    catch (Exception) { }
                    await Task.Delay(1000);
                }

                //Program.watchDogs.Start();
                Program.syncLoop.Start();

                syncLoop           = new System.Timers.Timer(TimeSpan.FromSeconds(delaysec).TotalMilliseconds);
                syncLoop.AutoReset = true;
                syncLoop.Elapsed  += new System.Timers.ElapsedEventHandler(sync.loop);
                syncLoop.Start();

                await Task.Delay(delay);

                await Task.Delay(2000);

                mining.killAll();

                await Task.Delay(2000);

                Program.NewMessage("https://api.minerstat.com/v2/benchmark/result/" + Program.token + "/" + Program.worker + "/" + B_ID + "/" + B_HASH, "");

                modules.getData minersVersion = new modules.getData("https://api.minerstat.com/v2/benchmark/result/" + Program.token + "/" + Program.worker + "/" + B_ID + "/" + B_HASH, "POST", "");
                string          version       = minersVersion.GetResponse();

                Program.NewMessage("BENCHMARK => " + version.ToString(), "");

                syncLoop.Stop();
            }

            // END
            mining.benchmark = "NO";
            Program.NewMessage("BENCHMARK => Finished", "");
            Program.NewMessage("BENCHMARK => Restarting node", "");
            mining.killAll();
            Program.watchDogs.Stop();
            Program.syncLoop.Stop();
            await Task.Delay(1500);

            mining.Start();
        }
Esempio n. 8
0
        public static void downloadConfig(string token, string worker)
        {
            try
            {
                modules.getData nodeConfig = new modules.getData("https://api.minerstat.com/v2/node/gpu/" + token + "/" + worker, "POST", "");
                configJSON = nodeConfig.GetResponse();

                var jObject = Newtonsoft.Json.Linq.JObject.Parse(configJSON);
                minerDefault   = (string)jObject["default"];
                cpuDefault     = (string)jObject["cpuDefault"];
                minerType      = (string)jObject["type"];
                minerOverclock = (string)jObject["overclock"];
                minerCpu       = (string)jObject["cpu"];

                modules.getData configRequest = new modules.getData("https://api.minerstat.com/v2/conf/gpu/" + token + "/" + worker + "/" + minerDefault.ToLower(), "POST", "");
                minerConfig = configRequest.GetResponse();

                string fileExtension = "start.bat";

                if (minerDefault.Contains("claymore"))
                {
                    fileExtension = "config.txt";
                }
                if (minerDefault.Contains("phoenix"))
                {
                    fileExtension = "config.txt";
                }
                if (minerDefault.Contains("sgminer"))
                {
                    fileExtension = "sgminer.conf";
                }

                string folderPath = Program.currentDir + "/clients/" + minerDefault + "/" + fileExtension;
                File.WriteAllText(@folderPath, minerConfig);

                if (minerCpu.Equals("True"))
                {
                    modules.getData cpuRequest = new modules.getData("https://api.minerstat.com/v2/conf/gpu/" + token + "/" + worker + "/" + cpuDefault.ToLower(), "POST", "");
                    cpuConfig = cpuRequest.GetResponse();

                    switch (cpuDefault.ToLower())
                    {
                    case "xmr-stak-cpu":
                        cpuConfigFile = "config.txt";
                        break;

                    case "cpuminer-opt":
                        cpuConfigFile = "start.bat";
                        break;

                    case "xmrig":
                        cpuConfigFile = "config.json";
                        break;
                    }

                    string folderPathCpu = Program.currentDir + "/clients/" + cpuDefault.ToLower() + "/" + cpuConfigFile;
                    File.WriteAllText(@folderPathCpu, cpuConfig);
                }

                if (!minerOverclock.Equals(""))
                {
                    if (Process.GetProcessesByName("msiafterburner").Length > 0)
                    {
                        var mObject = Newtonsoft.Json.Linq.JObject.Parse(minerOverclock);
                        clocktune.Manual(minerType, (int)mObject["powerlimit"], (int)mObject["coreclock"], (int)mObject["fan"], (int)mObject["memoryclock"]);
                    }
                    else
                    {
                        Program.NewMessage("WARNING > Install MSI Afterburner to enable overclocking", "WARNING");
                    }
                }
            }
            catch (Exception) { }
        }
Esempio n. 9
0
        async public static void loop(object sender, ElapsedEventArgs exw)
        {
            try
            {
                if (modules.checkNet(false) == false)
                {
                    Program.NewMessage("SYNC => Skip: CONNECTION LOST", "ERROR");
                }
                else
                {
                    if (modules.IsReach().Equals(false))
                    {
                        Program.NewMessage("SYNC => Skip: MINERSTAT UNREACHABLE", "ERROR");
                    }
                    else
                    {
                        // SET null
                        apiResponse = "";
                        apiHardware = "";
                        apiCpu      = "";


                        // 1) PREPARE THE URL'S if Needed
                        switch (mining.minerDefault.ToLower())
                        {
                        case "cast-xmr":
                            monitorURL = "http://localhost:7777";
                            break;

                        case "stak-xmr":
                            monitorURL = "http://localhost:2222/api.json";
                            break;

                        case "bminer":
                            monitorURL = "http://127.0.0.1:1880/api/status";
                            break;
                        }


                        // 2) Fetch API's
                        if (mining.minerDefault.ToLower().Contains("ccminer"))
                        {
                            modules.getStat();
                        }
                        if (mining.minerDefault.ToLower().Contains("ewbf"))
                        {
                            modules.getStat_ewbf();
                        }
                        if (mining.minerDefault.ToLower().Contains("zm-zec"))
                        {
                            modules.getStat_zm();
                        }
                        if (mining.minerDefault.ToLower().Contains("phoenix-eth") || mining.minerDefault.ToLower().Contains("claymore"))
                        {
                            modules.getStat_claymore();
                        }
                        if (mining.minerDefault.ToLower().Contains("sgminer"))
                        {
                            modules.getStat_sgminer();
                        }
                        if (mining.minerDefault.ToLower().Contains("gateless"))
                        {
                            modules.getStat_sgminer();
                        }
                        if (mining.minerDefault.ToLower().Contains("ethminer"))
                        {
                            apiResponse = "skip";
                        }
                        if (mining.minerDefault.ToLower().Contains("cast-xmr") || mining.minerDefault.ToLower().Contains("stak-xmr") || mining.minerDefault.ToLower().Contains("bminer"))
                        {
                            string          input;
                            HttpWebRequest  request  = (HttpWebRequest)WebRequest.Create(monitorURL);
                            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                            StreamReader    sr       = new StreamReader(response.GetResponseStream());
                            input = sr.ReadToEnd();
                            sr.Close();
                            apiResponse = input;
                        }

                        // Hardware Monitor
                        modules.getData hwQuery = new modules.getData("http://localhost:" + Program.monitorport + "/", "POST", "");
                        apiHardware = hwQuery.GetResponse();

                        // CPU Miner's
                        if (mining.minerCpu.Equals("True"))
                        {
                            switch (mining.cpuDefault.ToLower())
                            {
                            case "xmr-stak-cpu":
                                monitorURL = "HTTP";
                                break;

                            case "cpuminer-opt":
                                monitorURL = "TCP";
                                break;

                            case "xmrig":
                                monitorURL = "HTTP";
                                break;
                            }

                            try
                            {
                                if (monitorURL.Equals("HTTP"))
                                {
                                    string          input;
                                    HttpWebRequest  request  = (HttpWebRequest)WebRequest.Create("http://127.0.0.1:7887");
                                    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                                    StreamReader    sr       = new StreamReader(response.GetResponseStream());
                                    input = sr.ReadToEnd();
                                    sr.Close();
                                    apiCpu = input;
                                }
                                else
                                {
                                    modules.getStat_cpu();
                                }
                            } catch (Exception ex)
                            {
                                Program.NewMessage("ERROR => CPU API NOT RUNNING", "");
                                watchDog.cpuHealth();
                            }
                        }

                        // 4) POST

                        if (!mining.minerDefault.ToLower().Contains("ethminer"))
                        {
                            await Task.Delay(1000);

                            try
                            {
                                var postValue = new Dictionary <string, string>
                                {
                                    { "minerData", apiResponse },
                                    { "hwData", apiHardware },
                                    { "cpuData", apiCpu }
                                };

                                var content = new FormUrlEncodedContent(postValue);
                                try
                                {
                                    ramCounter = new PerformanceCounter("Memory", "Available MBytes", true);
                                }
                                catch (Exception ram) { }

                                var response = await client.PostAsync("https://api.minerstat.com/v2/set_node_config.php?token=" + Program.token + "&worker=" + Program.worker + "&miner=" + mining.minerDefault.ToLower() + "&ver=4&cpuu=" + mining.minerCpu + "&cpud=HASH" + "&os=win" + "&algo=&best=&space=" + modules.GetTotalFreeSpace("C") / 1000000 + "&freemem=" + Convert.ToInt32(ramCounter.NextValue()).ToString() + "&localip=" + modules.GetLocalIPAddress() + "&remoteip=" + modules.GetUserIP() + "&currentcpu=" + mining.cpuDefault.ToLower(), content);

                                var responseString = await response.Content.ReadAsStringAsync();

                                if (!responseString.Equals(""))
                                {
                                    Program.NewMessage("REMOTE COMMAND => " + responseString, "");
                                    RemoteCommand(responseString);
                                }


                                int package = (apiHardware.Length + apiResponse.Length + apiCpu.Length) * sizeof(Char);
                                modules.updateTraffic(package);

                                Program.NewMessage("SYNC => API Updated [ ~ " + (package / 1000) + " KB ]", "INFO");
                            }
                            catch (Exception ex) { }
                        }
                        else
                        {
                            // Only Remote Command Check
                            modules.getData response       = new modules.getData("https://api.minerstat.com/v2/get_command_only.php?token=" + Program.token + "&worker=" + Program.worker, "POST", "");
                            string          responseString = response.GetResponse();

                            if (!responseString.Equals(""))
                            {
                                Program.NewMessage("REMOTE COMMAND => " + responseString, "");
                                RemoteCommand(responseString);
                            }
                        }
                    }
                }
            }
            catch (Exception error)
            {
                Program.NewMessage(error.ToString(), "");
            }
        }