private async void Login_Button_Click(System.Object sender, RoutedEventArgs e) { if (UAR != null) { if (UAR.Username == LoginUsername.Text) { if (StringCipher.Decrypt(UAR.Password) == (LoginPassword.Password)) { Frame.Navigate(typeof(InfoScreen)); } else { MessageDialog incorrectAlert = new MessageDialog("Password is incorrect"); incorrectAlert.Title = "Incorrect"; incorrectAlert.Commands.Add(new UICommand("Ok") { Id = 0 }); incorrectAlert.DefaultCommandIndex = 0; var result = await incorrectAlert.ShowAsync(); LoginPassword.Password = ""; } } else { MessageDialog incorrectAlert = new MessageDialog("Username doesn't exist, please register"); incorrectAlert.Title = "Incorrect"; incorrectAlert.Commands.Add(new UICommand("Ok") { Id = 0 }); incorrectAlert.DefaultCommandIndex = 0; var result = await incorrectAlert.ShowAsync(); } } else { MessageDialog incorrectAlert = new MessageDialog("User doesn't exist, please register"); incorrectAlert.Title = "Incorrect"; incorrectAlert.Commands.Add(new UICommand("Ok") { Id = 0 }); incorrectAlert.DefaultCommandIndex = 0; var result = await incorrectAlert.ShowAsync(); } }
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(); } }
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 { } }
private async void WalletList_SelectionChanged(object sender, SelectionChangedEventArgs e) { UserAccountsDB userAccountDB = new UserAccountsDB(); UserAccounts[] userAccount = userAccountDB.GetAccountList(); if (WalletList.SelectedItems.Count > 0) { string Wallet = WalletList.SelectedItems[0].ToString(); Balance.Text = ""; BurstAddress.Text = userAccount[userAccountIndex[Wallet]].BurstAddress; string SecretPhrase = StringCipher.Decrypt(userAccount[userAccountIndex[Wallet]].PassPhrase); BNWAPI = new BNWalletAPI(); GetAccountIDResult gair = BNWAPI.getAccountID(SecretPhrase, ""); try { if (gair.success) { GetAccountResult gar = BNWAPI.getAccount(gair.accountRS); if (gar.success) { if (gar.name == null) { WalletName.Text = "Unknown Account"; } else { WalletName.Text = gar.name; } BurstAddress.Text = gar.accountRS; WalletName.Text = Wallet; string BB; BB = gar.balanceNQT; double burstdbl = Convert.ToDouble(BB); burstdbl = burstdbl / 100000000; Balance.Text = "Balance: " + burstdbl.ToString("#,0.00000000") + " BURST"; TransactionNumber.Text = "100"; GetTransactionListResult gtlr = BNWAPI.getTransactionList(gair.accountRS, TransactionNumber.Text); if (gtlr.success) { TransactionList_ListView.Items.Clear(); //TransactionList_ListView.Items.Add("Date & Time" + " " + "Amount + Fee" + " "+"Account" + " " + "Confirmations"); for (int i = 0; i < gtlr.transactions.Length; i++) { DateTime date = UnixTimeStampToDateTime(gtlr.transactions[i].timestamp); string transactionlist = gtlr.transactions[i].transaction; string amount = gtlr.transactions[i].amountNQT; double amnt = Convert.ToDouble(amount); amnt = amnt / 100000000; string newamnt = amnt.ToString("#,0.00000000"); string Fee = gtlr.transactions[i].feeNQT; double feeamnt = Convert.ToDouble(Fee); feeamnt = feeamnt / 100000000; string newFeeAmnt = feeamnt.ToString("#,0"); string SenderAccount = gtlr.transactions[i].senderRS; string Confirmations = gtlr.transactions[i].confirmations; double Conf = Convert.ToDouble(Confirmations); string Recipient = gtlr.transactions[i].recipientRS; if (Recipient == BurstAddress.Text) { newamnt = "+" + newamnt; } else { newamnt = "-" + newamnt; SenderAccount = Recipient; if (SenderAccount == "") { SenderAccount = "/ "; } } if (Conf > 9) { Conf = 10; string newConf = Conf.ToString() + "+"; TransactionList_ListView.Items.Add(date + " " + newamnt + "+" + newFeeAmnt + " " + SenderAccount + " " + newConf); } else { string newConf = Conf.ToString(); TransactionList_ListView.Items.Add(date + " " + newamnt + "+" + newFeeAmnt + " " + SenderAccount + " " + newConf); } } } } else { MessageDialog ConfirmationDetailsDialog = new MessageDialog("Received Error: " + gar.errorMsg); ConfirmationDetailsDialog.Title = "API Error"; ConfirmationDetailsDialog.Commands.Add(new UICommand("Ok") { Id = 0 }); var ConfResult = await ConfirmationDetailsDialog.ShowAsync(); TransactionList_ListView.Items.Clear(); Balance.Text = "Balance: 0.00000000 BURST"; } CreateQRCode(); } else { MessageDialog ConfirmationDetailsDialog = new MessageDialog("Received Error: " + gair.errorMsg); ConfirmationDetailsDialog.Title = "API Error"; ConfirmationDetailsDialog.Commands.Add(new UICommand("Ok") { Id = 0 }); var ConfResult = await ConfirmationDetailsDialog.ShowAsync(); } } catch { MessageDialog ConfirmationDetailsDialog = new MessageDialog("Received Error: " + gair.errorMsg); ConfirmationDetailsDialog.Title = "API Error"; ConfirmationDetailsDialog.Commands.Add(new UICommand("Ok") { Id = 0 }); var ConfResult = await ConfirmationDetailsDialog.ShowAsync(); } } }