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