示例#1
0
        public static void Main(string[] args)
        {
            ProxyDateStart          = DateTimeOffset.Now.ToUnixTimeSeconds();
            Console.CancelKeyPress += Console_CancelKeyPress;
            ExceptionUnexpectedHandler();

            Thread.CurrentThread.Name = Path.GetFileName(Environment.GetCommandLineArgs()[0]);
            ConsoleLog.WriteLine("Xiropht Proxy Solo Miner - " + Assembly.GetExecutingAssembly().GetName().Version + "R", ClassConsoleColorEnumeration.IndexConsoleMagentaLog);

            ReadConfig();


            if (Config.WriteLog)
            {
                ConsoleLog.InitializeLog();
                ConsoleLog.WriteLine("Write Log Enabled.", ClassConsoleColorEnumeration.IndexConsoleMagentaLog);
            }

            ConsoleLog.WriteLine("Wallet Address selected: " + Config.WalletAddress, ClassConsoleColorEnumeration.IndexConsoleMagentaLog);
            ConsoleLog.WriteLine("Proxy IP Selected: " + Config.ProxyIP, ClassConsoleColorEnumeration.IndexConsoleMagentaLog);
            ConsoleLog.WriteLine("Proxy Port Selected: " + Config.ProxyPort, ClassConsoleColorEnumeration.IndexConsoleMagentaLog);

            if (Config.EnableApi)
            {
                ConsoleLog.WriteLine("Start HTTP API..", ClassConsoleColorEnumeration.IndexConsoleMagentaLog);
                ClassApi.StartApiHttpServer();
                ConsoleLog.WriteLine("HTTP API started.", ClassConsoleColorEnumeration.IndexConsoleMagentaLog);
            }

            ThreadCheckNetworkConnection = new Thread(async delegate()
            {
                bool connectSuccess = false;
                while (!connectSuccess)
                {
                    while (!await NetworkBlockchain.ConnectToBlockchainAsync())
                    {
                        ConsoleLog.WriteLine("Can't connect to the network, retry in 5 seconds..", ClassConsoleColorEnumeration.IndexConsoleMagentaLog);
                        Thread.Sleep(5000);
                    }
                    ConsoleLog.WriteLine("Connection success, generate dynamic certificate for the network.", ClassConsoleColorEnumeration.IndexConsoleGreenLog);
                    NetworkCertificate = ClassUtils.GenerateCertificate();
                    ConsoleLog.WriteLine("Certificate generate, send to the network..", ClassConsoleColorEnumeration.IndexConsoleYellowLog);
                    if (!await NetworkBlockchain.SendPacketAsync(NetworkCertificate, false))
                    {
                        ConsoleLog.WriteLine("Can't send certificate, reconnect now..", ClassConsoleColorEnumeration.IndexConsoleRedLog);
                    }
                    else
                    {
                        ConsoleLog.WriteLine("Certificate sent, start to login..", ClassConsoleColorEnumeration.IndexConsoleYellowLog);
                        NetworkBlockchain.ListenBlockchain();
                        Thread.Sleep(1000);
                        if (!await NetworkBlockchain.SendPacketAsync(ClassConnectorSettingEnumeration.MinerLoginType + "|" + Config.WalletAddress, true))
                        {
                            ConsoleLog.WriteLine("Can't login to the network, reconnect now.", ClassConsoleColorEnumeration.IndexConsoleRedLog);
                        }
                        else
                        {
                            ConsoleLog.WriteLine("Login successfully sent, waiting confirmation..", ClassConsoleColorEnumeration.IndexConsoleYellowLog);
                            connectSuccess = true;
                        }
                    }
                }
            });
            ThreadCheckNetworkConnection.Start();

            ThreadProxyCommandLine = new Thread(delegate()
            {
                while (true)
                {
                    string commandLine = GetHiddenConsoleInput();
                    CommandLine(commandLine);
                }
            });
            ThreadProxyCommandLine.Start();
        }
示例#2
0
        /// <summary>
        /// Initialization of the mining pool.
        /// </summary>
        /// <returns></returns>
        private static bool InitializeMiningPool()
        {
            ClassLog.ConsoleWriteLog("Initialize Log system..", ClassLogEnumeration.IndexPoolGeneralLog, ClassLogConsoleEnumeration.IndexPoolConsoleYellowLog, true);

            if (ClassLog.LogInitialization())
            {
                ClassLog.ConsoleWriteLog("Initialize pool settings..", ClassLogEnumeration.IndexPoolGeneralLog, ClassLogConsoleEnumeration.IndexPoolConsoleYellowLog, true);
                if (MiningPoolSettingInitialization.InitializationPoolSettingFile())
                {
                    ClassLog.ConsoleWriteLog("Pool settings initialized.", ClassLogEnumeration.IndexPoolGeneralLog, ClassLogConsoleEnumeration.IndexPoolConsoleGreenLog, true);

                    ClassLog.ConsoleWriteLog("Intialize pool databases..", ClassLogEnumeration.IndexPoolGeneralLog, ClassLogConsoleEnumeration.IndexPoolConsoleYellowLog, true);
                    if (ClassMiningPoolDatabase.InitializationMiningPoolDatabases())
                    {
                        ClassMiningPoolDatabase.AutoSaveMiningPoolDatabases();

                        ClassLog.ConsoleWriteLog("Pool databases initialized.", ClassLogEnumeration.IndexPoolGeneralLog, ClassLogConsoleEnumeration.IndexPoolConsoleGreenLog, true);

                        ClassLog.ConsoleWriteLog("Log System initialized.", ClassLogEnumeration.IndexPoolGeneralLog, ClassLogConsoleEnumeration.IndexPoolConsoleGreenLog, true);

                        ThreadNetworkBlockchain = new Thread(async delegate()
                        {
                            ClassLog.ConsoleWriteLog("Connect Pool to the network for retrieve current blocktemplate..", ClassLogEnumeration.IndexPoolGeneralLog, ClassLogConsoleEnumeration.IndexPoolConsoleYellowLog, true);

                            bool notConnected = true;
                            while (notConnected)
                            {
                                Certificate = ClassUtils.GenerateCertificate();

                                while (!await ClassNetworkBlockchain.ConnectToBlockchainAsync())
                                {
                                    Thread.Sleep(5000);
                                    ClassLog.ConsoleWriteLog("Can't connect Pool to the network, retry in 5 seconds.. (Press CTRL+C to cancel and close the pool.)", ClassLogEnumeration.IndexPoolGeneralLog, ClassLogConsoleEnumeration.IndexPoolConsoleRedLog, true);
                                }
                                Certificate = ClassUtils.GenerateCertificate();
                                ClassLog.ConsoleWriteLog("Certificate generate, send to the network..", ClassLogEnumeration.IndexPoolGeneralLog, ClassLogConsoleEnumeration.IndexPoolConsoleYellowLog, true);
                                if (!await ClassNetworkBlockchain.SendPacketToNetworkBlockchain(Certificate, false))
                                {
                                    ClassLog.ConsoleWriteLog("Can't send certificate, reconnect now..", ClassLogEnumeration.IndexPoolGeneralLog, ClassLogConsoleEnumeration.IndexPoolConsoleRedLog, true);
                                }
                                else
                                {
                                    ClassLog.ConsoleWriteLog("Certificate sent, start to login..", ClassLogEnumeration.IndexPoolGeneralLog, ClassLogConsoleEnumeration.IndexPoolConsoleYellowLog, true);
                                    ClassNetworkBlockchain.ListenBlockchain();
                                    Thread.Sleep(1000);
                                    if (!await ClassNetworkBlockchain.SendPacketToNetworkBlockchain(ClassConnectorSettingEnumeration.MinerLoginType + "|" + MiningPoolSetting.MiningPoolWalletAddress, true))
                                    {
                                        ClassLog.ConsoleWriteLog("Can't login to the network, reconnect now.", ClassLogEnumeration.IndexPoolGeneralLog, ClassLogConsoleEnumeration.IndexPoolConsoleRedLog, true);
                                    }
                                    else
                                    {
                                        ClassLog.ConsoleWriteLog("Login successfully sent, waiting confirmation..", ClassLogEnumeration.IndexPoolGeneralLog, ClassLogConsoleEnumeration.IndexPoolConsoleYellowLog, true);
                                        notConnected = false;
                                    }
                                }
                                if (notConnected)
                                {
                                    ClassLog.ConsoleWriteLog("Can't long Pool to the network, retry in 5 seconds.. (Press CTRL+C to cancel and close the pool.)", ClassLogEnumeration.IndexPoolGeneralLog, ClassLogConsoleEnumeration.IndexPoolConsoleYellowLog, true);
                                    Thread.Sleep(5000);
                                }
                                else
                                {
                                    break;
                                }
                            }
                        })
                        {
                            IsBackground = true
                        };
                        ThreadNetworkBlockchain.Start();
                        if (MiningPoolSetting.MiningPoolEnableFiltering)
                        {
                            ClassLog.ConsoleWriteLog("Enable Filtering Miner System..", ClassLogEnumeration.IndexPoolGeneralLog, ClassLogConsoleEnumeration.IndexPoolConsoleYellowLog, true);
                            ClassFilteringMiner.EnableFilteringMiner();
                        }
                        if (MiningPoolSetting.MiningPoolEnableCheckMinerStats)
                        {
                            ClassLog.ConsoleWriteLog("Enable Check Miner Stats System..", ClassLogEnumeration.IndexPoolGeneralLog, ClassLogConsoleEnumeration.IndexPoolConsoleYellowLog, true);
                            ClassMinerStats.EnableCheckMinerStats();
                        }
                        if (MiningPoolSetting.MiningPoolEnableTrustedShare)
                        {
                            ClassLog.ConsoleWriteLog("Enable Trusted Share System..", ClassLogEnumeration.IndexPoolGeneralLog, ClassLogConsoleEnumeration.IndexPoolConsoleYellowLog, true);
                            ClassMinerStats.EnableCheckTrustedMinerStats();
                        }
                        if (MiningPoolSetting.MiningPoolEnablePayment)
                        {
                            ClassPayment.EnableAutoPaymentSystem();
                        }
                        if (MiningPoolSetting.MiningPoolMiningPort.Count > 0)
                        {
                            foreach (var miningPoolPort in MiningPoolSetting.MiningPoolMiningPort)
                            {
                                var miningPoolObject = new ClassMiningPool(miningPoolPort.Key, miningPoolPort.Value);
                                miningPoolObject.StartMiningPool();
                                ListMiningPool.Add(miningPoolPort.Key, miningPoolObject);
                            }
                            ClassApi.StartApiHttpServer();
                            EnableMiningPoolCommandLine();
                        }
                        else
                        {
                            ClassLog.ConsoleWriteLog("Cannot start mining pool, their is any ports on the setting.", ClassLogEnumeration.IndexPoolGeneralErrorLog, ClassLogConsoleEnumeration.IndexPoolConsoleRedLog, true);
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
            return(true);
        }
示例#3
0
 static void Main(string[] args)
 {
     EnableCatchUnexpectedException();
     Console.CancelKeyPress   += Console_CancelKeyPress;
     Thread.CurrentThread.Name = Path.GetFileName(Environment.GetCommandLineArgs()[0]);
     GlobalCultureInfo         = new CultureInfo("fr-FR");
     ClassLog.LogInitialization();
     ServicePointManager.DefaultConnectionLimit = 65535;
     ClassConsole.ConsoleWriteLine(ClassConnectorSetting.CoinName + " RPC Wallet - " + Assembly.GetExecutingAssembly().GetName().Version + "R", ClassConsoleColorEnumeration.IndexConsoleBlueLog, LogLevel);
     if (ClassRpcSetting.InitializeRpcWalletSetting())
     {
         ClassConsole.ConsoleWriteLine("Please write your rpc wallet password for decrypt your databases of wallet (Input keys are hidden): ", ClassConsoleColorEnumeration.IndexConsoleYellowLog, LogLevel);
         ClassRpcDatabase.SetRpcDatabasePassword(ClassUtility.GetHiddenConsoleInput());
         ClassConsole.ConsoleWriteLine("RPC Wallet Database loading..", ClassConsoleColorEnumeration.IndexConsoleYellowLog, LogLevel);
         if (ClassRpcDatabase.LoadRpcDatabaseFile())
         {
             ClassConsole.ConsoleWriteLine("RPC Wallet Database successfully loaded.", ClassConsoleColorEnumeration.IndexConsoleGreenLog, LogLevel);
             ClassConsole.ConsoleWriteLine("RPC Sync Database loading..", ClassConsoleColorEnumeration.IndexConsoleYellowLog, LogLevel);
             if (ClassSyncDatabase.InitializeSyncDatabase())
             {
                 ClassConsole.ConsoleWriteLine("RPC Sync Database successfully loaded.", ClassConsoleColorEnumeration.IndexConsoleGreenLog, LogLevel);
                 if (ClassRpcSetting.WalletEnableAutoUpdateWallet)
                 {
                     ClassConsole.ConsoleWriteLine("Enable Auto Update Wallet System..", ClassConsoleColorEnumeration.IndexConsoleYellowLog, LogLevel);
                     ClassWalletUpdater.EnableAutoUpdateWallet();
                     ClassConsole.ConsoleWriteLine("Enable Auto Update Wallet System done.", ClassConsoleColorEnumeration.IndexConsoleGreenLog, LogLevel);
                 }
                 ClassConsole.ConsoleWriteLine("Start RPC Wallet API Server..", ClassConsoleColorEnumeration.IndexConsoleYellowLog, LogLevel);
                 ClassApi.StartApiHttpServer();
                 ClassConsole.ConsoleWriteLine("Start RPC Wallet API Server sucessfully started.", ClassConsoleColorEnumeration.IndexConsoleGreenLog, LogLevel);
                 if (ClassRpcSetting.RpcWalletEnableRemoteNodeSync && ClassRpcSetting.RpcWalletRemoteNodeHost != string.Empty && ClassRpcSetting.RpcWalletRemoteNodePort != 0)
                 {
                     ClassConsole.ConsoleWriteLine("RPC Remote Node Sync system loading..", ClassConsoleColorEnumeration.IndexConsoleYellowLog, LogLevel);
                     ThreadRemoteNodeSync = new Thread(async() => await ClassRemoteSync.ConnectRpcWalletToRemoteNodeSyncAsync());
                     ThreadRemoteNodeSync.Start();
                 }
                 ClassConsole.ConsoleWriteLine("Enable Command Line system.", ClassConsoleColorEnumeration.IndexConsoleGreenLog, LogLevel);
                 ClassConsoleCommandLine.EnableConsoleCommandLine();
             }
             else
             {
                 ClassConsole.ConsoleWriteLine("Cannot read RPC Sync Database, the database is maybe corrupted.", ClassConsoleColorEnumeration.IndexConsoleRedLog, LogLevel);
                 Console.WriteLine("Press ENTER to exit.");
                 Console.ReadLine();
                 Environment.Exit(0);
             }
         }
         else
         {
             ClassConsole.ConsoleWriteLine("Cannot read RPC Wallet Database, the database is maybe corrupted.", ClassConsoleColorEnumeration.IndexConsoleRedLog, LogLevel);
             Console.WriteLine("Press ENTER to exit.");
             Console.ReadLine();
             Environment.Exit(0);
         }
     }
     else
     {
         ClassConsole.ConsoleWriteLine("Cannot read RPC Wallet setting, the setting is maybe corrupted, you can delete your setting file to build another one.", ClassConsoleColorEnumeration.IndexConsoleRedLog, LogLevel);
         Console.WriteLine("Press ENTER to exit.");
         Console.ReadLine();
         Environment.Exit(0);
     }
 }