Пример #1
0
        private void button5_Click(object sender, EventArgs e)
        {
            // Create transaction button function

            if (String.IsNullOrEmpty(textBox2.Text) ||
                String.IsNullOrEmpty(textBox6.Text) ||                  // Check all input boxes are filled
                String.IsNullOrEmpty(textBox4.Text) ||
                String.IsNullOrEmpty(textBox5.Text))
            {
                richTextBox1.Text += "\n[ERR] Please fill in required boxed\n";         // Reports error
                return;
            }

            if (!(Wallet.Wallet.ValidatePrivateKey(textBox3.Text, textBox2.Text)))          // Checks if keys are valid
            {
                richTextBox1.Text += "\n[ERR] Keys are not valid\n";                        // Reports error
                return;
            }
            blockchain.CheckBlocksMerkle();               // Check the blockchains hashes via merkle roots and deleting blocks with broken hashes


            if (blockchain.GetBalance(textBox2.Text) < (long.Parse(textBox4.Text) + long.Parse(textBox5.Text)))         // Check the sender has enough funds to carry out the transaction
            {
                richTextBox1.Text += "\n[ERR] Not enough funds to make transaction\n";                                  // Reports funds issue
                return;
            }


            Transaction transaction = new Transaction(textBox2.Text, textBox3.Text, textBox6.Text, ulong.Parse(textBox4.Text), ulong.Parse(textBox5.Text)); // Create transaction from input text blocks

            richTextBox1.Text += transaction.GetInfo();                                                                                                     // Show info about the transaction
            blockchain.AddTransaction(transaction);                                                                                                         // Add transaction to the blockchain, where it'll sit in the pending queue
        }