protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.AddNewPassphrase); etPassphrase = FindViewById <EditText>(Resource.Id.NewGenWalletPassPhrase); Button GenNewPassphrase = FindViewById <Button>(Resource.Id.btnNewPassphraseGenerator); GenNewPassphrase.Click += delegate { etPassphrase.Text = CreatePassword(200); }; Button Save = FindViewById <Button>(Resource.Id.btnSaveNewPassphraseWallet); Save.Click += delegate { BNWAPI = new BNWalletAPI(); GetAccountIDResult gair = BNWAPI.getAccountID(etPassphrase.Text, ""); if (gair.success) { UADB = new UserAccountsDB(); UARDB = new UserAccountRuntimeDB(); UAR = UARDB.Get(); string password = UAR.Password; UA = new UserAccounts(); string plaintext = etPassphrase.Text; string encryptedstring = StringCipher.Encrypt(plaintext, password); UA.AccountName = "Unknown Account"; UA.BurstAddress = gair.accountRS; UA.PassPhrase = encryptedstring; UADB.Save(UA); Intent intent = new Intent(this, typeof(WalletSelector)); intent.SetFlags(ActivityFlags.SingleTop); StartActivity(intent); Finish(); } ; // Create your application here }; }
public GetAccountIDResult getAccountID(string secretPhrase, string publicKey) { GetAccountIDResult GAIR = new GetAccountIDResult(); BNWalletAPIClasses.ErrorCodes er; fp = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("requestType", "getAccountId"), new KeyValuePair <string, string>("secretPhrase", secretPhrase), new KeyValuePair <string, string>("publicKey", publicKey) }); HttpResponseMessage resp = client.PostAsync("burst", fp).Result; string respStr = resp.Content.ReadAsStringAsync().Result; if (!string.IsNullOrEmpty(respStr)) { if (respStr.Contains("\"errorCode\":")) { er = JsonConvert.DeserializeObject <BNWalletAPIClasses.ErrorCodes>(respStr); GAIR.success = false; GAIR.errorMsg = er.errorDescription; //GAIR.errorMsg = fp; } else { BNWalletAPIClasses.GetAccountIDResponse gair = JsonConvert.DeserializeObject <BNWalletAPIClasses.GetAccountIDResponse>(respStr); GAIR.success = true; GAIR.accountRS = gair.accountRS; GAIR.account = gair.account; } } else { GAIR.success = false; GAIR.errorMsg = "Receive blank response from API call"; } return(GAIR); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.LoginScreen); RuntimeVar RT = new RuntimeVar(); RuntimeVarDB RTDB = new RuntimeVarDB(); RT = RTDB.Get(); UARDB = new UserAccountRuntimeDB(); UAR = UARDB.Get(); string password = UAR.Password; string SecretPhrase = StringCipher.Decrypt(RT.CurrentPassphrase, password); Button btnLogin = FindViewById <Button>(Resource.Id.btnLogin); btnLogin.Click += delegate { BNWAPI = new BNWalletAPI(); GetAccountIDResult gair = BNWAPI.getAccountID(SecretPhrase, ""); if (gair.success) { GetAccountResult gar = BNWAPI.getAccount(gair.accountRS); if (gar.success) { Intent intent = new Intent(this, typeof(InfoScreen)); intent.PutExtra("WalletAddress", gar.accountRS); intent.PutExtra("WalletName", gar.name); intent.PutExtra("WalletBalance", gar.balanceNQT); intent.SetFlags(ActivityFlags.SingleTop); StartActivity(intent); } else { UADB = new UserAccountsDB(); UA = UADB.Get(RT.CurrentWalletName); Intent intent = new Intent(this, typeof(InfoScreen)); intent.PutExtra("WalletAddress", UA.BurstAddress); intent.PutExtra("WalletName", UA.AccountName); intent.PutExtra("WalletBalance", "0.00000000"); intent.SetFlags(ActivityFlags.SingleTop); StartActivity(intent); } } else { UADB = new UserAccountsDB(); UA = UADB.Get(RT.CurrentWalletName); Intent intent = new Intent(this, typeof(InfoScreen)); intent.PutExtra("WalletAddress", UA.BurstAddress); intent.PutExtra("WalletName", UA.AccountName); intent.PutExtra("WalletBalance", "0.00000000"); intent.SetFlags(ActivityFlags.SingleTop); StartActivity(intent); } }; Button btnLoadWallet = FindViewById <Button>(Resource.Id.btnLoadWallet); btnLoadWallet.Click += delegate { Intent intent = new Intent(this, typeof(WalletSelector)); intent.SetFlags(ActivityFlags.SingleTop); StartActivity(intent); Finish(); }; // Create your application here }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.AddNewWallet); etPassphrase = FindViewById <EditText>(Resource.Id.NewWalletPassPhrase); Button Save = FindViewById <Button>(Resource.Id.btnSaveNewWallet); Save.Click += delegate { BNWAPI = new BNWalletAPI(); GetAccountIDResult gair = BNWAPI.getAccountID(etPassphrase.Text, ""); if (gair.success) { GetAccountResult gar = BNWAPI.getAccount(gair.accountRS); if (gar.success) { UADB = new UserAccountsDB(); UA = UADB.Get(gar.name); if (UA != null) { toast = Toast.MakeText(this, "Wallet Already Exists: " + UA.AccountName, ToastLength.Long); toast.Show(); } else { UARDB = new UserAccountRuntimeDB(); UAR = UARDB.Get(); string password = UAR.Password; UA = new UserAccounts(); string plaintext = etPassphrase.Text; string encryptedstring = StringCipher.Encrypt(plaintext, password); UA.AccountName = gar.name; UA.BurstAddress = gar.accountRS; UA.PassPhrase = encryptedstring; UADB.Save(UA); Intent intent = new Intent(this, typeof(WalletSelector)); intent.SetFlags(ActivityFlags.SingleTop); StartActivity(intent); Finish(); } } else { UADB = new UserAccountsDB(); UARDB = new UserAccountRuntimeDB(); UAR = UARDB.Get(); string password = UAR.Password; UA = new UserAccounts(); string plaintext = etPassphrase.Text; string encryptedstring = StringCipher.Encrypt(plaintext, password); UA.AccountName = "Unknown Account"; UA.BurstAddress = gair.accountRS; UA.PassPhrase = encryptedstring; UADB.Save(UA); Intent intent = new Intent(this, typeof(WalletSelector)); intent.SetFlags(ActivityFlags.SingleTop); StartActivity(intent); Finish(); } } else { toast = Toast.MakeText(this, "Received API Error: " + gair.errorMsg, ToastLength.Long); toast.Show(); } }; // Create your application here }