Exemplo n.º 1
0
        public static string GetUsername()
        {
            if (MiningState.Instance.IsDemoMining)
            {
                return(DemoUser.BTC);
            }

            var(btc, worker, _unused) = ConfigManager.GeneralConfig.GetCredentials();

            // TESTNET
#if (TESTNET || TESTNETDEV || PRODUCTION_NEW)
#if SEND_STRATUM_WORKERNAME
            if (worker.Length > 0 && CredentialValidators.ValidateWorkerName(worker))
            {
                return($"{btc}.{worker}${RigID}");
            }
#endif

            return($"{btc}${RigID}");
#else
            // PRODUCTION
            if (worker.Length > 0 && CredentialValidators.ValidateWorkerName(worker))
            {
                return($"{btc}.{worker}");
            }

            return($"{btc}");
#endif
        }
Exemplo n.º 2
0
        public static CredentialsValidState GetCredentialsValidState()
        {
            // assume it is valid
            var ret = CredentialsValidState.VALID;

            if (!CredentialValidators.ValidateBitcoinAddress(ConfigManager.GeneralConfig.BitcoinAddress))
            {
                ret |= CredentialsValidState.INVALID_BTC;
            }
            if (!CredentialValidators.ValidateWorkerName(ConfigManager.GeneralConfig.WorkerName))
            {
                ret |= CredentialsValidState.INVALID_WORKER;
            }

            return(ret);
        }
Exemplo n.º 3
0
        // make sure to pass in trimmed workerName
        // skipCredentialsSet when calling from RPC, workaround so RPC will work
        public static SetResult SetWorkerIfValidOrDifferent(string workerName, bool skipCredentialsSet = false)
        {
            if (workerName == ConfigManager.GeneralConfig.WorkerName)
            {
                return(SetResult.NOTHING_TO_CHANGE);
            }
            if (!CredentialValidators.ValidateWorkerName(workerName))
            {
                return(SetResult.INVALID);
            }
            SetWorker(workerName);
            if (!skipCredentialsSet)
            {
                ResetNiceHashStatsCredentials();
            }

            return(SetResult.CHANGED);
        }
Exemplo n.º 4
0
 // make sure to pass in trimmedBtc
 public static SetResult SetBTCIfValidOrDifferent(string btc, bool skipCredentialsSet = false)
 {
     if (btc == ConfigManager.GeneralConfig.BitcoinAddress && btc != "")
     {
         return(SetResult.NOTHING_TO_CHANGE);
     }
     if (!CredentialValidators.ValidateBitcoinAddress(btc))
     {
         ConfigManager.GeneralConfig.BitcoinAddress = btc;
         return(SetResult.INVALID);
     }
     SetBTC(btc);
     if (!skipCredentialsSet)
     {
         ResetNiceHashStatsCredentials();
     }
     return(SetResult.CHANGED);
 }