public MainPage()
 {
     this.InitializeComponent();
     UARDB = new UserAccountRuntimeDB();
     UAR   = UARDB.Get();
     UADB  = new UserAccountsDB();
 }
        private async void RegisterSaveBtn_Click(object sender, RoutedEventArgs e)
        {
            if (RegisterConfirmPassword.Password != RegisterPassword.Password)
            {
                MessageDialog incorrectAlert = new MessageDialog("Passwords do not match");
                incorrectAlert.Title = "Incorrect";
                incorrectAlert.Commands.Add(new UICommand("Ok")
                {
                    Id = 0
                });
                incorrectAlert.DefaultCommandIndex = 0;
                var result = await incorrectAlert.ShowAsync();

                RegisterConfirmPassword.Password = "";
            }
            else
            {
                MessageDialog msgDialog = new MessageDialog("Are you Sure?");
                msgDialog.Title = "Confirmation";
                msgDialog.Commands.Add(new UICommand("Yes")
                {
                    Id = 0
                });
                msgDialog.Commands.Add(new UICommand("No")
                {
                    Id = 1
                });
                msgDialog.DefaultCommandIndex = 0;
                msgDialog.CancelCommandIndex  = 1;
                var result = await msgDialog.ShowAsync();

                if ((int)result.Id == 0)
                {
                    UARDB        = new UserAccountRuntimeDB();
                    UAR          = new UserAccountRuntime();
                    UAR.Username = RegisterUsername.Text;
                    UAR.Password = StringCipher.Encrypt(RegisterPassword.Password);
                    UARDB.Save(UAR);
                    Frame.Navigate(typeof(MainPage));
                }
                else
                {
                }
            }
        }
예제 #3
0
        private async void BtnAddWallet_Click(System.Object sender, RoutedEventArgs e)
        {
            BNWAPI = new BNWalletAPI();
            try
            {
                GetAccountIDResult gair = BNWAPI.getAccountID(Passphrase.Text, "");

                if (gair.success)
                {
                    GetAccountResult gar = BNWAPI.getAccount(gair.accountRS);
                    if (gar.success)
                    {
                        UADB = new UserAccountsDB();
                        UA   = UADB.Get(gar.name);
                        if (UA != null)
                        {
                            MessageDialog incorrectAlert = new MessageDialog("Wallet Already Exists" + UA.AccountName);
                            incorrectAlert.Title = "Error";
                            incorrectAlert.Commands.Add(new UICommand("Ok")
                            {
                                Id = 0
                            });
                            incorrectAlert.DefaultCommandIndex = 0;
                            var result = await incorrectAlert.ShowAsync();
                        }
                        else
                        {
                            UARDB = new UserAccountRuntimeDB();
                            UAR   = UARDB.Get();
                            string password = UAR.Password;
                            UA = new UserAccounts();
                            string plaintext       = Passphrase.Text;
                            string encryptedstring = StringCipher.Encrypt(plaintext);

                            if (gar.name == "")
                            {
                                UA.AccountName = "No Name Set";
                            }
                            else
                            {
                                UA.AccountName = gar.name;
                            }
                            UA.BurstAddress = gar.accountRS;
                            UA.PassPhrase   = encryptedstring;
                            UADB.Save(UA);



                            MessageDialog Success = new MessageDialog("Wallet Added Successfully :" + UA.BurstAddress);
                            Success.Title = "Success";
                            Success.Commands.Add(new UICommand("Ok")
                            {
                                Id = 0
                            });
                            Success.DefaultCommandIndex = 0;
                            var SuccessResult = await Success.ShowAsync();

                            PopulateWalletList();
                        }
                    }
                    else
                    {
                        UADB  = new UserAccountsDB();
                        UARDB = new UserAccountRuntimeDB();
                        UAR   = UARDB.Get();
                        string password = UAR.Password;
                        UA = new UserAccounts();
                        string plaintext       = Passphrase.Text;
                        string encryptedstring = StringCipher.Encrypt(plaintext);
                        UA.AccountName  = "Unknown Account";
                        UA.BurstAddress = gair.accountRS;
                        UA.PassPhrase   = encryptedstring;
                        UADB.Save(UA);

                        MessageDialog Success = new MessageDialog("Wallet Added Successfully :" + UA.BurstAddress);
                        Success.Title = "Success";
                        Success.Commands.Add(new UICommand("Ok")
                        {
                            Id = 0
                        });
                        Success.DefaultCommandIndex = 0;
                        var SuccessResult = await Success.ShowAsync();

                        PopulateWalletList();
                    }
                }
                else
                {
                    MessageDialog ErrorAlert = new MessageDialog("Received Error: Please enter a valid passphrase for an existing Burstcoin wallet or click the generate new passphrase button.");
                    ErrorAlert.Title = "Error";
                    ErrorAlert.Commands.Add(new UICommand("Ok")
                    {
                        Id = 0
                    });
                    ErrorAlert.DefaultCommandIndex = 0;
                    var result = await ErrorAlert.ShowAsync();
                }
            }
            catch
            {
                MessageDialog ConfirmationDetailsDialog = new MessageDialog("Received Error: Please enter a valid passphrase for an existing Burstcoin wallet or click the generate new passphrase button.");
                ConfirmationDetailsDialog.Title = "Error";
                ConfirmationDetailsDialog.Commands.Add(new UICommand("Ok")
                {
                    Id = 0
                });
                var ConfResult = await ConfirmationDetailsDialog.ShowAsync();
            }
        }
예제 #4
0
        private async void Send_Burst_btn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                UARDB = new UserAccountRuntimeDB();
                UAR   = UARDB.Get();
                UserAccountsDB userAccountDB = new UserAccountsDB();
                UserAccounts[] userAccount   = userAccountDB.GetAccountList();
                string         SecretPhrase  = StringCipher.Decrypt(userAccount[userAccountIndex[WalletName.Text]].PassPhrase);

                MessageDialog alertDialog = new MessageDialog("Are you sure all the details are correct?");
                alertDialog.Title = "Confirmation";
                alertDialog.Commands.Add(new UICommand("Yes")
                {
                    Id = 0
                });
                alertDialog.Commands.Add(new UICommand("No")
                {
                    Id = 1
                });
                alertDialog.DefaultCommandIndex = 0;
                alertDialog.CancelCommandIndex  = 1;
                var result = await alertDialog.ShowAsync();

                if ((int)result.Id == 0)
                {
                    double amntdbl = Convert.ToDouble(Amount.Text);
                    amntdbl = amntdbl * 100000000;
                    string amount = amntdbl.ToString();

                    double amntdblconf = Convert.ToDouble(amount);
                    amntdblconf = amntdblconf / 100000000;
                    Amount.Text = amntdblconf.ToString("#,0.00000000");

                    if (Fee.Text == "")
                    {
                        Fee.Text = "0";
                    }
                    double feeamnt = Convert.ToDouble(Fee.Text);
                    feeamnt = feeamnt * 100000000;
                    string fee = feeamnt.ToString();

                    double feeamntconf = Convert.ToDouble(fee);
                    feeamntconf = feeamntconf / 100000000;
                    Fee.Text    = feeamntconf.ToString("#,0.00000000");


                    BNWAPI = new BNWalletAPI();
                    GetsendMoneyResult gsmr = BNWAPI.sendMoney(Recepient_Address.Text, amount, fee, SecretPhrase, Message.Text, cbEncrypt.IsChecked.HasValue);
                    if (gsmr.success)
                    {
                        GetTransactionResult gtr = BNWAPI.getTransaction(gsmr.transaction);
                        if (gtr.success)
                        {
                            GetMiningInfo gmi = BNWAPI.getMiningInfo();
                            if (gmi.success)
                            {
                                MessageDialog ConfirmationDetailsDialog = new MessageDialog("Sender Address: " + gtr.senderRS + "\n" + "Amount of Burst sent: " + Amount.Text + "\n" + "Fee: " + Fee.Text + "\n" + "Recipient Address: " + gtr.recipientRS + "\n" + "Signature Hash: " + gsmr.signatureHash
                                                                                            + "\n" + "Transaction ID: " + gsmr.transaction + "\n" + "Block Height: " + gmi.height);
                                ConfirmationDetailsDialog.Title = "Confirmation Details";
                                ConfirmationDetailsDialog.Commands.Add(new UICommand("Ok")
                                {
                                    Id = 0
                                });
                                var ConfResult = await ConfirmationDetailsDialog.ShowAsync();

                                if ((int)result.Id == 0)
                                {
                                    Recepient_Address.Text = "";
                                    Amount.Text            = "";
                                    Fee.Text     = "";
                                    Message.Text = "";
                                    PopulateWalletList();
                                }
                            }
                        }
                    }
                    else
                    {
                        MessageDialog ConfirmationDetailsDialog = new MessageDialog("Received Error: " + gsmr.errorMsg);
                        ConfirmationDetailsDialog.Title = "API Error";
                        ConfirmationDetailsDialog.Commands.Add(new UICommand("Ok")
                        {
                            Id = 0
                        });
                        var ConfResult = await ConfirmationDetailsDialog.ShowAsync();
                    }
                }
                else
                {
                }
            }
            catch
            {
                MessageDialog ConfirmationDetailsDialog = new MessageDialog("Received Error: A valid Burst Wallet needs to be selected before any funds can be sent");
                ConfirmationDetailsDialog.Title = "Error";
                ConfirmationDetailsDialog.Commands.Add(new UICommand("Ok")
                {
                    Id = 0
                });
                var ConfResult = await ConfirmationDetailsDialog.ShowAsync();
            }
        }