Beispiel #1
0
        private void RefreshAccount(string account)
        {
            var balance = EthereumService.GetBalance(account, BlockTag.Latest);
            var pending = EthereumService.GetBalance(account, BlockTag.Pending);
            var txCount = EthereumService.GetTransactionCount(account, BlockTag.Latest);
            var changes = EthereumService.GetFilterChanges(GetCurrentAccount().FilterId);

            BeginInvoke((MethodInvoker) delegate
            {
                lblBalance.Text = string.Format("{0} Eth", balance.WeiToEther());
                lblPending.Text = string.Format("{0} Eth", pending.WeiToEther());
                lblTxCount.Text = txCount.ToString();
            });
        }
Beispiel #2
0
        public static void Run(string file)
        {
            if (string.IsNullOrEmpty(file) || !File.Exists(file))
            {
                Console.WriteLine("File required");
                return;
            }

            object            console           = new object();
            ConnectionOptions connectionOptions = new ConnectionOptions()
            {
                Port = "8545",
                Url  = "http://127.0.0.1"
            };

            long            count = 0, have = 0;
            EthereumService ethereumService = new EthereumService(connectionOptions);

            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("Start checking accounts");
            Console.WriteLine("");

            Parallel.ForEach(File.ReadAllLines(file), (address) =>
                             //foreach(string address in File.ReadAllLines(file))
            {
                string endAddress = address;

                if (!address.StartsWith("0x"))
                {
                    endAddress = "0x" + address;
                }

                Interlocked.Increment(ref count);

                string sammout;
                try
                {
                    long tx = ethereumService.GetTransactionCount(endAddress, BlockTag.Latest);
                    if (tx == 0)
                    {
                        return;
                    }

                    BigInteger ammout = ethereumService.GetBalance(endAddress, BlockTag.Latest);

                    sammout = ammout.ToString();
                    Interlocked.Increment(ref have);
                }
                catch (Exception ex)
                {
                    sammout = "ERROR " + ex.Message;
                }

                lock (console)
                {
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.Write("[" + endAddress + "] ");
                    Console.ForegroundColor = sammout.StartsWith("ERROR ") ? ConsoleColor.Red : ConsoleColor.Yellow;
                    Console.WriteLine(sammout);
                }
            });

            // END

            lock (console)
            {
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine();
                Console.WriteLine("*****************************************");
                Console.WriteLine("Checked accounts [" + count + "] ");
                Console.WriteLine("Accounts with balance [" + have + "] ");
            }
        }
        public static void Run()
        {
            Console.WriteLine("Press Control+C for cancel");
            Console.CancelKeyPress += Console_CancelKeyPress;

            object            console           = new object();
            ConnectionOptions connectionOptions = new ConnectionOptions()
            {
                Port = "8545",
                Url  = "http://127.0.0.1"
            };

            long            have            = 0;
            Random          r               = new Random();
            EthereumService ethereumService = new EthereumService(connectionOptions);

            while (!Cancel)
            {
                Parallel.For(0, 1000, (i) =>
                {
                    if (Cancel)
                    {
                        return;
                    }

                    byte[] privKey = new byte[32];
                    r.NextBytes(privKey);

                    EthAddress e      = new EthAddress(privKey);
                    string endAddress = e.Address;

                    if (!endAddress.StartsWith("0x"))
                    {
                        endAddress = "0x" + endAddress;
                    }

                    string sammout;
                    try
                    {
                        //Thread.Sleep(5);
                        Interlocked.Increment(ref have);

                        long tx = ethereumService.GetTransactionCount(endAddress, BlockTag.Latest);
                        if (tx == 0)
                        {
                            return;
                        }

                        BigInteger ammout = ethereumService.GetBalance(endAddress, BlockTag.Latest);
                        sammout           = ammout.ToString();
                    }
                    catch (Exception ex)
                    {
                        sammout = "ERROR " + ex.Message;
                    }
                    finally
                    {
                        lock (console) Console.Title = have.ToString();
                    }

                    lock (console)
                    {
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.Write("[" + privKey.ToHex() + "] ");
                        Console.ForegroundColor = sammout.StartsWith("ERROR ") ? ConsoleColor.Red : ConsoleColor.Yellow;
                        Console.WriteLine(sammout);

                        File.AppendAllText("./Lotery.txt", privKey.ToHex() + " " + sammout + Environment.NewLine);
                    }
                });
            }
        }