Exemple #1
0
        private async void GetNodeList(object sender, RoutedEventArgs e)
        {
            TransactionProtocol protocol = new TransactionProtocol();

            string[] nodeList = await protocol.GetAllNode();

            if (nodeList[0] != "")
            {
                RadioButton originalRadioButton = new RadioButton()
                {
                    Content   = XmlManager.GetHttp(),
                    IsChecked = true,
                };

                originalRadioButton.Checked += OnSelect;

                spNodeList.Children.Add(originalRadioButton);

                for (int index = 0; index < nodeList.Length; index++)
                {
                    RadioButton radioButton = new RadioButton();
                    radioButton.Content  = $"{nodeList[index]}/";
                    radioButton.Checked += OnSelect;
                    spNodeList.Children.Add(radioButton);
                }
            }
            else
            {
                MessageBox.Show("Timeout", "Error");
            }
        }
Exemple #2
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            TransactionProtocol protocol = new TransactionProtocol();

            TransactionJSON[] transactionJSONs = await protocol.GetAllTransaction();

            TransactionDetailsWindow transactionDetails = new TransactionDetailsWindow(transactionJSONs);

            transactionDetails.Show();
        }
Exemple #3
0
        private async void Check(object sender, RoutedEventArgs e)
        {
            TransactionProtocol protocol = new TransactionProtocol();
            bool result = await protocol.CheckServer(txtHostname.Text);

            if (result)
            {
                MessageBox.Show("Server confirm");
            }
            else
            {
                MessageBox.Show("Timeout", "Error");
            }
        }
Exemple #4
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (XmlManager.IsExist())
            {
                List <string> adviceList = new List <string>()
                {
                    "You should remove spend address so that the program may run faster",
                    "You should only use each address once",
                    "Your private key is in the UserInfo.xml file"
                };

                Random r    = new Random();
                int    rInt = r.Next(0, 3); //for ints

                txtResult.Text = adviceList[rInt];

                await Task.Delay(2000);

                WalletWindow wallet = new WalletWindow();
                wallet.Show();
                this.Close();
            }
            else
            {
                XmlManager.NewXmlFile();
                txtResult.Text = "Welcome new user!\n Currently generate your first address!\nPlease don't close window";
                Transaction transaction = new Transaction();

                TransactionProtocol protocol = new TransactionProtocol();
                TransactionResponse result   = await protocol.MakeTransaction(transaction);


                if (result.Status == "invalid")
                {
                    txtResult.Text = "Cannot send key to host";
                }
                else
                {
                    txtResult.Text = "You create your first transaction";
                }

                await Task.Delay(2000);

                WalletWindow wallet = new WalletWindow();
                wallet.Show();
                this.Close();
            }
        }
Exemple #5
0
        private async void MakeTransaction(object sender, RoutedEventArgs e)
        {
            if (Outputs.Count == 0)
            {
                MessageBox.Show("You don't have Output");
                return;
            }

            await GetTotalBalance();

            float spend      = 0;
            float total      = XmlManager.GetCurrentTotal();
            var   stringCoin = $": {total.ToString()} KCoin";

            txtTotal.Text = stringCoin;

            foreach (Output output in Outputs)
            {
                spend += output.Amount;
            }

            if (total < spend)
            {
                MessageBox.Show("You don't have enough money");
                return;
            }

            Transaction transaction = new Transaction(Outputs);

            TransactionProtocol protocol = new TransactionProtocol();
            TransactionResponse response = await protocol.MakeTransaction(transaction);

            if (response.Status == "invalid")
            {
                MessageBox.Show(response.Message, "Error");
            }

            Outputs.Clear();
            lvOutput.ItemsSource = null;
            lvOutput.ItemsSource = Outputs;
        }
Exemple #6
0
 private async Task GetTotalBalance()
 {
     TransactionProtocol protocol = new TransactionProtocol();
     await protocol.GetCurrentTotal();
 }