Beispiel #1
0
        async public static void startMiner(Boolean m1, Boolean m2)
        {
            // Defender - Add exclusion folder programmatically
            Process.Start("C:\\windows\\system32\\windowspowershell\\v1.0\\powershell.exe ", "Add-MpPreference -ExclusionPath '" + Program.currentDir + "'");

            if (!File.Exists(Program.minerstatDir + "/buffer.txt"))
            {
                if (File.Exists(Program.currentDir + "/" + minerDefault.ToLower() + ".zip"))
                {
                    try
                    {
                        File.Delete(Program.currentDir + "/" + minerDefault.ToLower() + ".zip");
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("ERROR => File .zip removal error");
                    }
                }

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

                if (Process.GetProcessesByName(mining.getProcessName()).Length == 0)
                {
                    if (m1.Equals(true) && m2.Equals(false))
                    {
                        Program.watchDogs.Stop();
                        Program.syncLoop.Stop();
                        //Program.crashLoop.Stop();
                        if (minerCpu.Equals("True"))
                        {
                            if (!Directory.Exists(Program.currentDir + "/clients/" + cpuDefault.ToLower() + "/"))
                            {
                                Directory.CreateDirectory(Program.currentDir + "/clients/" + cpuDefault.ToLower() + "/");
                            }

                            string cpuMinerVersion;

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

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

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

                                Downloader.minerVersion = cpuVersion;

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

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

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

                        //Program.crashLoop.Start();
                    }

                    if (m1.Equals(true))
                    {
                        string folderPath = '"' + Program.currentDir + "/clients/" + minerDefault.ToLower() + "/" + '"';
                        Process.Start("C:\\windows\\system32\\windowspowershell\\v1.0\\powershell.exe ", @"set-location '" + folderPath + "'; " + "./start.bat; pause");

                        minerStarted = "YES";
                    }
                }

                if (Process.GetProcessesByName(getCPUProcess()).Length == 0)
                {
                    if (minerCpu.Equals("True") && m2.Equals(true))
                    {
                        string folderPath = '"' + Program.currentDir + "/clients/" + cpuDefault.ToLower() + "/" + '"';

                        switch (mining.cpuDefault.ToLower())
                        {
                        case "xmr-stak-cpu":
                            filePath = "xmr-stak-cpu.exe";
                            break;

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

                        case "xmrig":
                            filePath = "xmrig.exe";
                            break;
                        }

                        Program.NewMessage(cpuDefault.ToUpper() + " => " + cpuConfig, "INFO");
                        Process.Start("C:\\windows\\system32\\windowspowershell\\v1.0\\powershell.exe ", @"set-location '" + folderPath + "'; " + "./" + filePath + ";");
                    }
                }
                await Task.Delay(2000);

                Program.SyncStatus = true;

                _instanceMainForm.Invoke((MethodInvoker) delegate {
                    _instanceMainForm.TopMost = false;
                });
            }
            else
            {
                File.Delete(@Program.minerstatDir + "/buffer.txt");
            }
        }
Beispiel #2
0
        async public static void Start()
        {
            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);

                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");

                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);

                    // Start miner
                    Program.NewMessage("NODE => Waiting for the first sync..", "INFO");

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

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

                    // Start SYNC & Remote Command
                    Program.syncLoop.Start();
                }
            }
            catch (Exception ex)
            {
                Program.NewMessage(ex.ToString(), "");
            }
        }
Beispiel #3
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.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();
                }
            }
        }
Beispiel #4
0
        async public static void startMiner(Boolean m1, Boolean m2)
        {
            _instanceMainForm.Invoke((MethodInvoker) delegate {
                _instanceMainForm.TopMost = true;
            });


            if (m1.Equals(true) && m2.Equals(false))
            {
                if (minerCpu.Equals("True"))
                {
                    if (!Directory.Exists(Program.currentDir + "/clients/" + cpuDefault.ToLower() + "/"))
                    {
                        Directory.CreateDirectory(Program.currentDir + "/clients/" + cpuDefault.ToLower() + "/");
                    }

                    string cpuMinerVersion;

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

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

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

                        Downloader.minerVersion = cpuVersion;

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

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

            if (m1.Equals(true))
            {
                string folderPath = '"' + Program.currentDir + "/clients/" + minerDefault.ToLower() + "/" + '"';
                Process.Start("C:\\windows\\system32\\windowspowershell\\v1.0\\powershell.exe ", @"set-location '" + folderPath + "'; " + "./start.bat; pause");
            }

            if (minerCpu.Equals("True") && m2.Equals(true))
            {
                string folderPath = '"' + Program.currentDir + "/clients/" + cpuDefault.ToLower() + "/" + '"';

                switch (mining.cpuDefault.ToLower())
                {
                case "xmr-stak-cpu":
                    filePath = "xmr-stak-cpu.exe";
                    break;

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

                case "xmrig":
                    filePath = "xmrig.exe";
                    break;
                }

                Program.NewMessage(cpuDefault.ToUpper() + " => " + cpuConfig, "INFO");
                Process.Start("C:\\windows\\system32\\windowspowershell\\v1.0\\powershell.exe ", @"set-location '" + folderPath + "'; " + "./" + filePath + ";");
            }

            await Task.Delay(2000);

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