public SetAccountInfo setAccountInfo(string name, string secretphrase) { SetAccountInfo SAI = new SetAccountInfo(); BNWalletAPIClasses.ErrorCodes er; HttpResponseMessage resp = new HttpResponseMessage(); string respStr; fp = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("requestType", "setAccountInfo"), new KeyValuePair <string, string>("account", name), new KeyValuePair <string, string>("secretPhrase", secretphrase), new KeyValuePair <string, string>("feeNQT", "100000000"), new KeyValuePair <string, string>("deadline", "60"), }); try { resp = client.PostAsync("burst", fp).Result; respStr = resp.Content.ReadAsStringAsync().Result; } catch { respStr = null; } if (!string.IsNullOrEmpty(respStr)) { if (respStr.Contains("\"errorCode\":")) { er = JsonConvert.DeserializeObject <BNWalletAPIClasses.ErrorCodes>(respStr); SAI.success = false; SAI.errorMsg = er.errorDescription; } else { BNWalletAPIClasses.SetAccountInfo sai = JsonConvert.DeserializeObject <BNWalletAPIClasses.SetAccountInfo>(respStr); SAI.success = true; } } else { SAI.success = false; SAI.errorMsg = "Receive blank response from API call"; } return(SAI); }
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 { } }