Exemple #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
        }
        private void createTransaction_Click(object sender, EventArgs e)
        {
            if (!Wallet.Wallet.ValidatePrivateKey(privateKey.Text, publicKey.Text))
            {
                richTextBox1.Text = "Transaction could not be created due to invalid public/private key pair.";
                return;
            }

            if (blockchain.GetBalance(publicKey.Text) < (Double.Parse(amount.Text) + Double.Parse(fee.Text)))
            {
                richTextBox1.Text = "Insufficient funds for transaction.";
                return;
            }

            Transaction transaction = new Transaction(publicKey.Text, receiverKey.Text, Double.Parse(amount.Text), Double.Parse(fee.Text), privateKey.Text);

            blockchain.transactionPool.Add(transaction);
            richTextBox1.Text = transaction.ToString();
        }
 // Check the balance of current user
 private void CheckBalance_Click(object sender, EventArgs e)
 {
     UpdateText(blockchain.GetBalance(publicKey.Text).ToString() + " Assignment Coin");
 }
Exemple #4
0
 //Checks funds of wallet using public key
 private void checkBalancce_Click(object sender, EventArgs e)
 {
     richTextBox1.Text = blockchain.GetBalance(publicKey.Text).ToString() + " Bob Coin";
 }
Exemple #5
0
 // Check current user balance
 private void CheckBalance_Click(object sender, EventArgs e)
 {
     outputToRichTextBox1(blockchain.GetBalance(pubKeyTBox.Text).ToString() + " Assignment Coin");
 }