Esempio n. 1
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();
            }
        }
 public void RemoveWallet(UserAccounts accountname)
 {
     db.Delete(accountname);
 }
Esempio n. 3
0
        private async void BtnChangeWalletName_Click(object sender, RoutedEventArgs e)
        {
            MessageDialog alertDialog = new MessageDialog("Changing your Wallet Name costs 1 Burst as a fee, continue?");

            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)
            {
                UserAccountsDB userAccountDB = new UserAccountsDB();
                try
                {
                    UserAccounts[] userAccount = userAccountDB.GetAccountList();
                    UADB = new UserAccountsDB();
                    UA   = UADB.Get(WalletName.Text);

                    string         SecretPhrase = StringCipher.Decrypt(UA.PassPhrase);
                    SetAccountInfo sai          = BNWAPI.setAccountInfo(New_WalletName.Text, SecretPhrase);

                    if (sai.success)
                    {
                        UserAccounts NU = new UserAccounts();
                        NU.AccountName  = New_WalletName.Text;
                        NU.BurstAddress = BurstAddress.Text;
                        NU.PassPhrase   = StringCipher.Encrypt(SecretPhrase);
                        UADB.Save(NU);
                        UADB.RemoveWallet(UA);
                        WalletName.Text = NU.AccountName;
                        MessageDialog ConfirmationDetailsDialog = new MessageDialog("Wallets Name has been changed");
                        ConfirmationDetailsDialog.Title = "Confirmation";
                        ConfirmationDetailsDialog.Commands.Add(new UICommand("Ok")
                        {
                            Id = 0
                        });
                        var ConfResult = await ConfirmationDetailsDialog.ShowAsync();

                        PopulateWalletList();
                    }
                    else
                    {
                        MessageDialog ConfirmationDetailsDialog = new MessageDialog("Received Error:" + sai.errorMsg);
                        ConfirmationDetailsDialog.Title = "Error";
                        ConfirmationDetailsDialog.Commands.Add(new UICommand("Ok")
                        {
                            Id = 0
                        });
                        var ConfResult = await ConfirmationDetailsDialog.ShowAsync();
                    }
                }
                catch
                {
                    MessageDialog ConfirmationDetailsDialog = new MessageDialog("Received Error: A valid Burstcoin wallet needs to be present before attempting to change the name. Please create a new Burstcoin wallet first.");
                    ConfirmationDetailsDialog.Title = "Error";
                    ConfirmationDetailsDialog.Commands.Add(new UICommand("Ok")
                    {
                        Id = 0
                    });
                    var ConfResult = await ConfirmationDetailsDialog.ShowAsync();
                }
            }
            else
            {
            }
        }
 public void Save(UserAccounts accountname)
 {
     db.InsertOrReplace(accountname);
 }