protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.AddNewUser); Username = FindViewById <EditText>(Resource.Id.NewUserUsername); etPassword = FindViewById <EditText>(Resource.Id.NewUsernamePassword); etConfPassword = FindViewById <EditText>(Resource.Id.NewUsernameConfirmPassword); Button btnSave = FindViewById <Button>(Resource.Id.btnSaveNewUser); btnSave.Click += delegate { // Create your application here if (etConfPassword.Text != etPassword.Text) { toast = Toast.MakeText(this, "Passwords do not match", ToastLength.Long); etConfPassword.Text = ""; toast.Show(); } else { UARDB = new UserAccountRuntimeDB(); UAR = new UserAccountRuntime(); UAR.Username = Username.Text; UAR.Password = HashPassword.Hash(etPassword.Text); UARDB.Save(UAR); Intent intent = new Intent(this, typeof(MainActivity)); intent.SetFlags(ActivityFlags.SingleTop); StartActivity(intent); Finish(); } }; }
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 }; }
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.SendBurstScreen); MobileBarcodeScanner.Initialize(Application); scanner = new MobileBarcodeScanner(); RuntimeVar RT = new RuntimeVar(); RuntimeVarDB RTDB = new RuntimeVarDB(); RT = RTDB.Get(); burstAddress = Intent.GetStringExtra("BurstAddress"); RecipientBurstAddress = FindViewById <EditText>(Resource.Id.sendBurstAddress); Message = FindViewById <EditText>(Resource.Id.sendMessage); Amount = FindViewById <EditText>(Resource.Id.sendAmount); Fee = FindViewById <EditText>(Resource.Id.sendFee); cbEncrypt = FindViewById <CheckBox>(Resource.Id.cbEncryptMessage); CreateQRCode = FindViewById <Button>(Resource.Id.btnViewQRCode); UARDB = new UserAccountRuntimeDB(); UAR = UARDB.Get(); string password = UAR.Password; string SecretPhrase = StringCipher.Decrypt(RT.CurrentPassphrase, password); CreateQRCode.Click += delegate { Intent intent = new Intent(this, typeof(QRCodeView)); intent.SetFlags(ActivityFlags.SingleTop); StartActivity(intent); }; Button btnsend = FindViewById <Button>(Resource.Id.btnSend); btnsend.Click += delegate { AlertDialog.Builder alertDialog = new AlertDialog.Builder(this); alertDialog.SetTitle("Confirmation"); alertDialog.SetMessage("Are you sure all the details are correct?"); alertDialog.SetPositiveButton("Yes", delegate { double amntdbl = Convert.ToDouble(Amount.Text); amntdbl = amntdbl * 100000000; amount = amntdbl.ToString(); double amntdblconf = Convert.ToDouble(amount); amntdblconf = amntdblconf / 100000000; Amount.Text = amntdblconf.ToString("#,0.00000000"); double feeamnt = Convert.ToDouble(Fee.Text); feeamnt = feeamnt * 100000000; fee = feeamnt.ToString(); double feeamntconf = Convert.ToDouble(fee); feeamntconf = feeamntconf / 100000000; Fee.Text = feeamntconf.ToString("#,0.00000000"); BNWAPI = new BNWalletAPI(); GetsendMoneyResult gsmr = BNWAPI.sendMoney(RecipientBurstAddress.Text, amount, fee, SecretPhrase, Message.Text, cbEncrypt.Checked); if (gsmr.success) { GetTransactionResult gtr = BNWAPI.getTransaction(gsmr.transaction); if (gtr.success) { AlertDialog.Builder ConfirmationDetailsDialog = new AlertDialog.Builder(this); ConfirmationDetailsDialog.SetTitle("Confirmation Details"); ConfirmationDetailsDialog.SetMessage("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: " + gtr.ecBlockHeight); ConfirmationDetailsDialog.SetPositiveButton("OK", delegate { GetAccountResult gar = BNWAPI.getAccount(gtr.senderRS); 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); Finish(); } }); ConfirmationDetailsDialog.Show(); } } else { toast = Toast.MakeText(this, "Received API Error: " + gsmr.errorMsg, ToastLength.Long); toast.Show(); } }); alertDialog.SetNegativeButton("No", delegate { alertDialog.Dispose(); }); alertDialog.Show(); }; Button ScanQRCode = FindViewById <Button>(Resource.Id.btnSendQRCode); ScanQRCode.Click += async delegate { await ScanFunction(); }; // Create your application here }
public void Save(UserAccountRuntime RT) { db.InsertOrReplace(RT); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); Login = FindViewById <Button>(Resource.Id.btnNULogin); Register = FindViewById <Button>(Resource.Id.btnNURegister); Username = FindViewById <EditText>(Resource.Id.NewUserUsername); Password = FindViewById <EditText>(Resource.Id.NewUserPassword); UARDB = new UserAccountRuntimeDB(); UAR = UARDB.Get(); UADB = new UserAccountsDB(); Register.Click += delegate { AlertDialog.Builder alertDialog = new AlertDialog.Builder(this); alertDialog.SetTitle("Confirmation"); alertDialog.SetMessage("Registering a new user clears the database. \nAre you sure?"); alertDialog.SetPositiveButton("Yes", delegate { UADB.ClearDB(); Intent Intent = new Intent(this, typeof(AddNewUser)); Intent.SetFlags(ActivityFlags.SingleTop); StartActivity(Intent); Finish(); }); alertDialog.SetNegativeButton("No", delegate { alertDialog.Dispose(); }); alertDialog.Show(); }; Login.Click += delegate { if (UAR != null) { if (UAR.Username == Username.Text) { if (HashPassword.VerifyHashedPassword(UAR.Password, Password.Text)) { Intent intent = new Intent(this, typeof(WalletSelector)); intent.SetFlags(ActivityFlags.SingleTop); StartActivity(intent); Finish(); } else { toast = Toast.MakeText(this, "Password is incorrect", ToastLength.Long); toast.Show(); Password.Text = ""; } } else { toast = Toast.MakeText(this, "Username doesn't exist, please register", ToastLength.Long); toast.Show(); } } else { toast = Toast.MakeText(this, "User doesn't exist, please register", ToastLength.Long); toast.Show(); } }; // Set our view from the "main" layout resource }
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 }