private void sbLoadKey_Click(object sender, EventArgs e) { var ofd = new OpenFileDialog(); ofd.Filter = "File Keys|*.txt"; ofd.Title = "File Keys"; ofd.Multiselect = false; if (ofd.ShowDialog() == DialogResult.Cancel) { return; } var files = File.ReadAllLines(ofd.FileName); if (files.Length == 0) { return; } var listKeys = StaticHomeModule.LoadListKeysFromFile(files); teKeyLoaded.Text = listKeys.Count.ToString(); keys = new List <BtcKeys>(); keys = listKeys; }
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { var quitConfirm = XtraMessageBox.Show("Quit ??", "Message", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (quitConfirm == DialogResult.Cancel) { e.Cancel = true; } else { StaticHomeModule.KillProcessByName("BvSsh"); } }
//private bool isStopScan; private async void sbStart_Click(object sender, EventArgs e) { if (teKeyLoaded.Text == string.Empty) { XtraMessageBox.Show("Private Keys must not be Empty.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } DisableFunctions(); StaticHomeModule.SaveSettingsToFile(Convert.ToInt32(seTimeOut.Value), leProxy.EditValue.ToString()); await checkAsyn.CheckBalanceAsyn(new InfoRequired() { keys = keys, listSsh = listSsh, Port = Convert.ToInt32(sePort.Value), Thread = Convert.ToInt32(seThread.Value), Timeout = Convert.ToInt32(seTimeOut.Value), SshFileSelected = leProxy.EditValue.ToString() }); EnableFunctions(); }
private void trmRunTime_Tick(object sender, EventArgs e) //StaticHomeModule.ChangeImages(bstRunning); { new Thread(() => { while (true) { lock (o) { if (lockTaken) { break; } StaticHomeModule.ChangeImages(bstRunning); } } }) { IsBackground = true }.Start(); ElapsedTime++; var timeToDisplay = TimeSpan.FromSeconds(ElapsedTime).ToString("hh\\:mm\\:ss"); bstTime.Caption = timeToDisplay; }
public async Task CheckBalanceAsyn(InfoRequired info) { StaticHomeModule.KillProcessByName("BvSsh"); _taskManagers.Clear(); cancelSources.Clear(); AddTaskManager(info); var keyBag = new ConcurrentBag <BtcKeys>(info.keys); var sshBag = RenewSsh(info.SshFileSelected); var temKeyBag = keyBag.Count; temSshCount = StaticSsh.LoadListSshFromFile(info.SshFileSelected).Count; listKeyHaveMoney = new List <WithBalanceToSave>(); listEmptyBalance = new List <EmptyBalanceToSave>(); listErrorKey = new List <ErrorKeyToSave>(); await Task.Run(async() => { int taskCancel = 0; var tasks = new List <Task>(); for (int i = 1; i <= info.Thread; i++) { var _cancelSource = new CancellationTokenSource(); int taskId = i; Thread.Sleep(20); var t = Task.Run(() => { var temTask = taskId; var manager = GetTaskManager(taskId); try { manager.ChangeIp(sshBag); OnProxyUsed(new ProxyUsedEventArg() { ProxyUsed = temSshCount - sshBag.Count, }); while (!keyBag.IsEmpty) // >>>>>>>>>> { _cancelSource.Token.ThrowIfCancellationRequested(); OnKeyQueue(new KeyQueueEventArgs() { KeyQueue = keyBag.Count, }); OnKeyChecked(new KeyCheckedEventArgs() { KeyChecked = temKeyBag - keyBag.Count, }); if (keyBag.TryTake(out BtcKeys key)) { lock (o) { GetKeybalanceInfo(key, manager, sshBag, temSshCount); } } } } catch (OperationCanceledException) { taskCancel++; OnTaskStop(new TaskStopEventArg() { ThreadNumber = taskCancel, StopReason = $"Stop Thread: " }); } }, _cancelSource.Token); cancelSources.Add(_cancelSource); tasks.Add(t); } await Task.WhenAll(tasks); if (taskCancel == info.Thread) { return; } tasks.Clear(); cancelSources.Clear(); }); }
private void GetKeybalanceInfo(BtcKeys key, TaskManager manager, ConcurrentBag <SshDetail> sshBag, int temSshCount) { var temKey = string.Empty; var http = manager.Http; HttpResponse res = null; try { res = http.Get($"https://blockchain.info/address/{key.Key}"); } catch (Exception ex) { var processes = Process.GetProcessesByName("BvSsh").Length == 0; while (res == null) { if (processes) { return; } manager.ChangeIp(sshBag); OnProxyUsed(new ProxyUsedEventArg() { ProxyUsed = temSshCount - sshBag.Count, }); res = http.Get($"https://blockchain.info/address/{key.Key}"); } } if (res.Text.Contains("Oops")) { manager.ErrorKey.ErrorKeys = key.Key; listErrorKey.Add(manager.ErrorKey); OnErrorKey(new ErrorKeysEventArgs() { ErrorKeys = listErrorKey.Count, }); temKey = key.Key; StaticHomeModule.WriteErrorKeyToFile(temKey); } else { var numberTransaction = res.DocumentNode.SelectSingleNode("//*[@id='n_transactions']").InnerText; //var totalMoneyReceived = res.DocumentNode.SelectSingleNode("//*[@id='total_received']/font/span").InnerText;//*[@id="final_balance"]/font/span var finalBalance = res.DocumentNode.SelectSingleNode("//*[@id='final_balance']/font/span").InnerText.Split(' ')[0]; if (double.Parse((finalBalance)) != 0) { manager.WithBalance.NumberTransaction = numberTransaction; manager.WithBalance.FinalBalance = finalBalance; listKeyHaveMoney.Add(manager.WithBalance); OnWithBalance(new WithBalanceEventArg() { WithBalance = listKeyHaveMoney.Count, }); temKey = $"{key.Key}({manager.WithBalance.FinalBalance})"; StaticHomeModule.WriteWithbalanceToFile(temKey); } else { listEmptyBalance.Add(manager.EmptyBalance); OnEmptyBalance(new EmptyBalanceEventArg() { EmptyBalance = listEmptyBalance.Count, }); temKey = key.Key; StaticHomeModule.WriteEmptyBalanceToFile(temKey); } } }