예제 #1
0
        static void Main(string[] args)
        {
            //examples of using MultiMiner.Xgminer.dll and MultiMiner.Xgminer.Api.dll

            //download and install the latest version of bfgminer
            const string executablePath = @"D:\bfgminer\";
            const string executableName = "bfgminer.exe";
            MinerBackend minerBackend = MinerBackend.Bfgminer;

            Console.WriteLine("Downloading and installing {0} from {1} to the directory {2}",
                executableName, Xgminer.Installer.GetMinerDownloadRoot(minerBackend), executablePath);

            //download and install bfgminer from the official website
            Xgminer.Installer.InstallMiner(minerBackend, executablePath);
            try
            {
                //create an instance of Miner with the downloaded executable
                MinerConfiguration minerConfiguration = new MinerConfiguration()
                {
                    MinerBackend = minerBackend,
                    ExecutablePath = Path.Combine(executablePath, executableName)
                };
                Miner miner = new Miner(minerConfiguration);

                //use it to iterate through devices
                List<Device> deviceList = miner.DeviceList();

                Console.WriteLine("Using {0} to list available mining devices", executableName);

                //output devices
                foreach (Device device in deviceList)
                    Console.WriteLine("Device detected: {0}\t{1}\t{2}", device.Kind, device.Driver, device.Identifier);

                //start mining if there are devices
                if (deviceList.Count > 0)
                {
                    Console.WriteLine("{0} device(s) detected, mining Bitcoin on Bitminter using all devices", deviceList.Count);

                    //setup a pool
                    MiningPool pool = new MiningPool()
                    {
                        Host = "mint.bitminter.com",
                        Port = 3333,
                        Username = "******",
                        Password = "******"
                    };
                    minerConfiguration.Pools.Add(pool);

                    //specify algorithm
                    minerConfiguration.Algorithm = CoinAlgorithm.SHA256;

                    //disable GPU mining
                    minerConfiguration.DisableGpu = true;

                    //specify device indexes to use
                    for (int i = 0; i < deviceList.Count; i++)
                        minerConfiguration.DeviceIndexes.Add(i);

                    //enable RPC API
                    minerConfiguration.ApiListen = true;
                    minerConfiguration.ApiPort = 4028;

                    Console.WriteLine("Launching {0}", executableName);

                    //start mining
                    miner = new Miner(minerConfiguration);
                    System.Diagnostics.Process minerProcess = miner.Launch();
                    try
                    {
                        //get an API context
                        Xgminer.Api.ApiContext apiContext = new Xgminer.Api.ApiContext(minerConfiguration.ApiPort);
                        try
                        {
                            //mine for one minute, monitoring hashrate via the API
                            for (int i = 0; i < 6; i++)
                            {
                                Thread.Sleep(1000 * 10); //sleep 10s

                                //query the miner process via its RPC API for device information
                                List<Xgminer.Api.DeviceInformation> deviceInformation = apiContext.GetDeviceInformation();

                                //output device information
                                foreach (Xgminer.Api.DeviceInformation item in deviceInformation)
                                    Console.WriteLine("Hasrate for device {0}: {1} current, {2} average", item.Index,
                                            item.CurrentHashrate, item.AverageHashrate);
                            }
                        }
                        finally
                        {
                            Console.WriteLine("Quitting mining via the RPC API");

                            //stop mining, try the API first
                            apiContext.QuitMining();
                        }
                    }
                    finally
                    {
                        Console.WriteLine("Killing any remaining process");

                        //then kill the process
                        try
                        {
                            minerProcess.Kill();
                            minerProcess.WaitForExit();
                            minerProcess.Close();
                        }
                        catch (InvalidOperationException ex)
                        {
                            //already closed
                        }
                    }
                }
                else
                {
                    Console.WriteLine("No devices capable of mining detected");
                }
            }
            finally
            {
                Console.WriteLine("Cleaning up, deleting directory {0}", executablePath);
                Directory.Delete(executablePath, true);
            }

            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
예제 #2
0
        private EngineConfiguration CreateEngineConfiguration()
        {
            EngineConfiguration engineConfiguration;
            engineConfiguration = new EngineConfiguration();

            CoinConfiguration coinConfiguration = new CoinConfiguration();

            CryptoCoin coin = coins.Single(c => c.Name.Equals(coinComboBox.Text));

            coinConfiguration.Coin = coin;
            coinConfiguration.Enabled = true;

            MiningPool miningPool = new MiningPool();

            miningPool.Host = hostEdit.Text;
            miningPool.Port = Int32.Parse(portEdit.Text);
            miningPool.Username = usernameEdit.Text;
            miningPool.Password = passwordEdit.Text;

            coinConfiguration.Pools.Add(miningPool);

            engineConfiguration.CoinConfigurations.Add(coinConfiguration);
            return engineConfiguration;
        }
예제 #3
0
        public static void Seed(List<CoinConfiguration> configurations)
        {
            //BTC
            CoinConfiguration donationConfiguration = new CoinConfiguration();
            donationConfiguration.Coin.Symbol = "BTC";

            MiningPool donationPool = new MiningPool()
            {
                Host = "stratum+tcp://stratum.mining.eligius.st",
                Port = 3334,
                Username = "******",
                Password = "******"
            };
            donationConfiguration.Pools.Add(donationPool);

            donationPool = new MiningPool()
            {
                Host = "stratum+tcp://mint.bitminter.com",
                Port = 3333,
                Username = "******",
                Password = "******"
            };
            donationConfiguration.Pools.Add(donationPool);

            donationPool = new MiningPool()
            {
                Host = "stratum+tcp://stratum.bitcoin.cz",
                Port = 3333,
                Username = "******",
                Password = "******"
            };
            donationConfiguration.Pools.Add(donationPool);

            configurations.Add(donationConfiguration);

            //LTC
            donationConfiguration = new CoinConfiguration();
            donationConfiguration.Coin.Symbol = "LTC";

            donationPool = new MiningPool()
            {
                Host = "stratum+tcp://world.wemineltc.com",
                Port = 3333,
                Username = "******",
                Password = "******"
            };
            donationConfiguration.Pools.Add(donationPool);

            donationPool = new MiningPool()
            {
                Host = "stratum+tcp://primary.coinhuntr.com",
                Port = 3333,
                Username = "******",
                Password = "******"
            };
            donationConfiguration.Pools.Add(donationPool);

            configurations.Add(donationConfiguration);

            //BQC
            donationConfiguration = new CoinConfiguration();
            donationConfiguration.Coin.Symbol = "BQC";

            donationPool = new MiningPool()
            {
                Host = "http://de1.bigbbq.cc",
                Port = 8446,
                Username = "******",
                Password = "******"
            };
            donationConfiguration.Pools.Add(donationPool);

            configurations.Add(donationConfiguration);

            //FTC
            donationConfiguration = new CoinConfiguration();
            donationConfiguration.Coin.Symbol = "FTC";

            donationPool = new MiningPool()
            {
                Host = "stratum+tcp://stratum.wemineftc.com",
                Port = 4444,
                Username = "******",
                Password = "******"
            };
            donationConfiguration.Pools.Add(donationPool);

            donationPool = new MiningPool()
            {
                Host = "http://feathercoin.is-a-geek.com",
                Port = 8341,
                Username = "******",
                Password = "******"
            };
            donationConfiguration.Pools.Add(donationPool);

            configurations.Add(donationConfiguration);

            //MEC
            donationConfiguration = new CoinConfiguration();
            donationConfiguration.Coin.Symbol = "MEC";

            donationPool = new MiningPool()
            {
                Host = "stratum+tcp://us.miningpool.co",
                Port = 9002,
                Username = "******",
                Password = "******"
            };
            donationConfiguration.Pools.Add(donationPool);

            donationPool = new MiningPool()
            {
                Host = "stratum+tcp://au1.miningpool.co",
                Port = 9001,
                Username = "******",
                Password = "******"
            };
            donationConfiguration.Pools.Add(donationPool);

            configurations.Add(donationConfiguration);

            //PPC
            donationConfiguration = new CoinConfiguration();
            donationConfiguration.Coin.Symbol = "PPC";

            donationPool = new MiningPool()
            {
                Host = "stratum+tcp://stratum.d7.lt",
                Port = 3333,
                Username = "******",
                Password = "******"
            };
            donationConfiguration.Pools.Add(donationPool);

            //NVC
            donationConfiguration = new CoinConfiguration();
            donationConfiguration.Coin.Symbol = "NVC";

            donationPool = new MiningPool()
            {
                Host = "stratum+tcp://stratum.khore.org",
                Port = 3334,
                Username = "******",
                Password = "******"
            };
            donationConfiguration.Pools.Add(donationPool);

            configurations.Add(donationConfiguration);

            //CAP
            donationConfiguration = new CoinConfiguration();
            donationConfiguration.Coin.Symbol = "CAP";

            donationPool = new MiningPool()
            {
                Host = "stratum+tcp://cap.coinmine.pl",
                Port = 8102,
                Username = "******",
                Password = "******"
            };
            donationConfiguration.Pools.Add(donationPool);

            configurations.Add(donationConfiguration);

            //ZET
            donationConfiguration = new CoinConfiguration();
            donationConfiguration.Coin.Symbol = "ZET";

            donationPool = new MiningPool()
            {
                Host = "stratum+tcp://mine1.coinmine.pl",
                Port = 6000,
                Username = "******",
                Password = "******"
            };
            donationConfiguration.Pools.Add(donationPool);

            configurations.Add(donationConfiguration);

            //UNO
            donationConfiguration = new CoinConfiguration();
            donationConfiguration.Coin.Symbol = "UNO";

            donationPool = new MiningPool()
            {
                Host = "stratum+tcp://de1.miningpool.co",
                Port = 10701,
                Username = "******",
                Password = "******"
            };
            donationConfiguration.Pools.Add(donationPool);

            //DOGE
            donationConfiguration = new CoinConfiguration();
            donationConfiguration.Coin.Symbol = "DOGE";

            donationPool = new MiningPool()
            {
                Host = "stratum+tcp://stratum.dogehouse.org",
                Port = 3333,
                Username = "******",
                Password = "******"
            };
            donationConfiguration.Pools.Add(donationPool);

            configurations.Add(donationConfiguration);
        }
예제 #4
0
        private static CoinConfiguration CreateCoinConfiguration(string coinSymbol, string host, int port, string username = "******")
        {
            CoinConfiguration donationConfiguration = new CoinConfiguration();
            donationConfiguration.Coin.Symbol = coinSymbol;

            MiningPool donationPool = new MiningPool()
            {
                Host = host,
                Port = port,
                Username = username,
                Password = "******"
            };
            donationConfiguration.Pools.Add(donationPool);

            return donationConfiguration;
        }