public long Insert(UserWallet model) { using (var con = WriteConnection()) { return(con.ExecuteScalar <long>(@"INSERT INTO UserWallets(UserAccountId,CryptoId,Balance,FrozenBalance,Address,Tag,ShowInHomePage,HomePageRank,PayRank,CryptoCode) VALUES(@UserAccountId,@CryptoId,@Balance,@FrozenBalance,@Address,@Tag,@ShowInHomePage,@HomePageRank,@PayRank,@CryptoCode); SELECT SCOPE_IDENTITY()", model)); } }
public void CreateWallet(string path, string password, bool createDefaultAccount = true) { switch (Path.GetExtension(path)) { case ".db3": CurrentWallet = UserWallet.Create(path, password, NeoSystem.Settings); break; case ".json": CurrentWallet = new NEP6Wallet(path, NeoSystem.Settings); ((NEP6Wallet)CurrentWallet).Unlock(password); break; default: ConsoleHelper.Warning("Wallet files in that format are not supported, please use a .json or .db3 file extension."); return; } if (createDefaultAccount) { WalletAccount account = CurrentWallet.CreateAccount(); ConsoleHelper.Info(" Address: ", account.Address); ConsoleHelper.Info(" Pubkey: ", account.GetKey().PublicKey.EncodePoint(true).ToHexString()); ConsoleHelper.Info("ScriptHash: ", $"{account.ScriptHash}"); } if (CurrentWallet is NEP6Wallet wallet) { wallet.Save(); } }
private void ProcessResult(string result, Order order) { logger.Info("ProcessResult Method Start" + " at " + DateTime.UtcNow); logger.Info("Result parameter" + result + " at " + DateTime.UtcNow); MembershipUser membershipUser = System.Web.Security.Membership.GetUser(); order.UserProfileId = Convert.ToInt32(membershipUser.ProviderUserKey); var userWallet = db.UserWallets.ToList(); UserWallet userwallet = db.UserWallets.FirstOrDefault(x => x.UserProfileId == order.UserProfileId); string[] resultParams = result.Split(','); logger.Info("Result parameter" + resultParams.Count() + " at " + DateTime.UtcNow); if (resultParams.Count() > 1) { order.Remarks = order.Remarks + "," + resultParams[0];// "AZ" + order.OrderId.ToString() + GetUniqueKey(); if (resultParams[1].ToString().ToLower().Equals("success")) { order.Status = (int)OrderStatus.Success; logger.Info("Order status" + order.Status + " at " + DateTime.UtcNow); } else if (resultParams[1].ToString().ToLower().Equals("failed")) { order.Status = (int)OrderStatus.Failed; logger.Info("Order status" + order.Status + " at " + DateTime.UtcNow); if (userwallet != null) { userwallet.Balance += order.Amount; logger.Info("Order Failed, Update User Wallet Balance" + userwallet.Balance + " at " + DateTime.UtcNow); } } } logger.Info("ProcessResult Method End" + " at " + DateTime.UtcNow); }
public static void SaveUserWallet(QuiGigAPIEntities context, string userId, long userPaymentId, string description, int creditAmount, int debitAmount, long packgId, string paymentStatus, string paymentFrom, decimal payAmount, int bonusCoin, string paymentGateway) { try { UserWallet entity = new UserWallet(); entity.UserID = userId; entity.UserPaymentId = userPaymentId; entity.Description = description; entity.CreditAmount = creditAmount; entity.DebitAmount = debitAmount; entity.CreatedDate = DateTime.UtcNow; entity.PaymentFrom = paymentFrom; entity.PaymentStatus = paymentStatus; entity.PayAmount = payAmount; entity.BonusCoin = bonusCoin; if (packgId > 0) { entity.PackageId = packgId; } entity.PaymentGateway = paymentGateway; context.UserWallets.Add(entity); context.SaveChanges(); } catch (Exception ex) { } }
public void Init(string walletpath, string password, string wif) { Walletpath = walletpath; switch (Path.GetExtension(walletpath)) { case ".db3": { Wallet = UserWallet.Create(walletpath, password); WalletAccount account = Wallet.CreateAccount(Wallet.GetPrivateKeyFromWIF(wif)); } break; case ".json": { NEP6Wallet wallet = new NEP6Wallet(walletpath); wallet.Unlock(password); WalletAccount account = wallet.CreateAccount(Wallet.GetPrivateKeyFromWIF(wif)); wallet.Save(); Wallet = wallet; } break; default: Console.WriteLine("未知的钱包文件类型"); break; } foreach (WalletAccount account in wallet.GetAccounts()) { Address = account.Address; } Password = password; }
public async Task <bool> CreateUserWithGoogle(User user) { if (CheckExistingLogin(user.Email)) { return(false); } user.UserCoinsNumber = Constants.DefaultUserCoinsNmber; var userWallet = new UserWallet() { UnusedCoinsNumber = Constants.DefaultUserCoinsNmber }; user.UserWallet = userWallet; AddImage(user); user.IsActive = AccountVerificationEnum.Verified; if (user.UserType == UserTypeEnum.Particulier) { var walletId = await _mangoPayService.CreateUser(user); user.WalletId = walletId; } _context.Users.Add(user); _context.SaveChanges(); _emailService.SendUserCreationEmail(user); return(true); }
private Task CommitTransaction(UserWallet wallet, WalletTransaction transaction) { wallet.MoneyAmmount += transaction.MoneyInvolved; _unitOfWork.Add(transaction); _unitOfWork.Update(wallet); return(_unitOfWork.SaveChanges()); }
private void ChangeWallet(UserWallet wallet) { if (Program.CurrentWallet != null) { Program.CurrentWallet.BalanceChanged -= CurrentWallet_BalanceChanged; Program.CurrentWallet.Dispose(); } Program.CurrentWallet = wallet; if (Program.CurrentWallet != null) { Program.CurrentWallet.BalanceChanged += CurrentWallet_BalanceChanged; } 修改密码CToolStripMenuItem.Enabled = Program.CurrentWallet != null; 交易TToolStripMenuItem.Enabled = Program.CurrentWallet != null; 高级AToolStripMenuItem.Enabled = Program.CurrentWallet != null; 创建新地址NToolStripMenuItem.Enabled = Program.CurrentWallet != null; 导入私钥IToolStripMenuItem.Enabled = Program.CurrentWallet != null; 创建智能合约SToolStripMenuItem.Enabled = Program.CurrentWallet != null; ContractListView.Items.Clear(); if (Program.CurrentWallet != null) { foreach (Contract contract in Program.CurrentWallet.GetContracts()) { AddContractToListView(contract); } } balance_changed = true; }
public JObject OpenWallet(string path, string password) { if (!File.Exists(path)) { throw new FileNotFoundException(); } switch (GetExtension(path)) { case ".db3": { wallet = UserWallet.Open(path, password); break; } case ".json": { NEP6Wallet nep6wallet = new NEP6Wallet(path); nep6wallet.Unlock(password); wallet = nep6wallet; break; } default: throw new NotSupportedException(); } return(true); }
public void InterestTestCase1() { // arrange var userWallet1 = new UserWallet { CreditCards = new List <CreditCard> { VisaCard, MasterCard, DiscoverCard } }; var user1 = new User { UserWallets = new List <UserWallet> { userWallet1 } }; //act var TotalInterest = user1.CalculateTotalInterest(); //assert Assert.AreEqual(TotalInterest, 16); }
public ActionResult GetResponse(string DR) { logger.Info("GetResponse Method Start" + " at " + DateTime.UtcNow); UserWalletLog userWalletLog = (UserWalletLog)TempData["UserWalletLog"]; RequestParams parameters = new RequestParams(); db.Entry(userWalletLog).State = EntityState.Modified; parameters.GetResponse(DR, userWalletLog.UserProfileId, userWalletLog.Amount, ref userWalletLog); logger.Info("GetResponse Method userWallet log status " + userWalletLog.Status1 + " at " + DateTime.UtcNow); if (userWalletLog.Status1 == (int)OrderStatus.PaymentSuceess) { UserWallet wallet = db.UserWallets.Where(p => p.UserProfileId == userWalletLog.UserProfileId).FirstOrDefault(); logger.Info("GetResponse Method wallet " + wallet.UserWalletId + " at " + DateTime.UtcNow); if (wallet == null) { wallet = new UserWallet(); wallet.UserProfileId = userWalletLog.UserProfileId; wallet.Balance += userWalletLog.Amount; logger.Info("GetResponse Method user " + wallet.UserProfileId + " at " + DateTime.UtcNow); logger.Info("GetResponse Method wallet balance " + wallet.Balance + " at " + DateTime.UtcNow); db.UserWallets.Add(wallet); } else { wallet.Balance += userWalletLog.Amount; logger.Info("GetResponse Method wallet balance " + wallet.Balance + " at " + DateTime.UtcNow); db.Entry(wallet).State = EntityState.Modified; } } db.SaveChanges(); TempData["WalletStatus"] = userWalletLog.Status1; logger.Info("GetResponse Method End" + " at " + DateTime.UtcNow); return(RedirectToAction("Wallet", "UserWallet"));; }
public async Task <UserWallet> Add(UserWallet wallet) { await Context.AddEntity(wallet); Context.SaveChanges(); return(wallet); }
private void Event_WalletOpened(object sender, EventArgs e) { UserWallet wallet; try { wallet = UserWallet.Open(overviewPan1.GetWalletPath(), overviewPan1.GetWalletPassword()); } catch (CryptographicException ex) { //lbl_warning.Text = "Password is not correct"; //lbl_warning.Show(); return; } catch (FormatException ex) { //lbl_warning.Text = ex.Message; //lbl_warning.Show(); return; } overviewPan1.ResetWallet(); sendcoinsPan1.ResetSendCoin(); transactionRightSidePan1.Reset(); transactionsPan1.Reset(); ChangeWallet(wallet); }
private void btn_continue_Click(object sender, EventArgs e) { if (!CheckStatus()) { return; } UserWallet wallet; try { wallet = UserWallet.Open(passwordItem1.GetWalletPath(), passwordItem1.GetPassword()); } catch (CryptographicException ex) { lbl_warning.Text = StringTable.DATA[iLang, 21]; lbl_warning.Show(); return; } catch (FormatException ex) { lbl_warning.Text = ex.Message; lbl_warning.Show(); return; } Settings.Default.LastWalletPath = passwordItem1.GetWalletPath(); Settings.Default.Save(); this.Hide(); mainWalletForm = new MainWalletForm(wallet); if (mainWalletForm.ShowDialog() == DialogResult.OK) { } }
public override void ExecuteValidCommand(MessageEventArgs messageEvent, string token) { var messageSender = new MessageSender(); var chatId = messageEvent.Message.Chat.Id; var keyboard = messageSender.CreateMenuKeyboard(); ApiDataAccess apiDataAccess = new ApiDataAccess(); UserWallet wallet = apiDataAccess.GetWallet(token); string message = ""; if (wallet.coinWallets.Count > 0) { foreach (var coinWallet in wallet.coinWallets) { message = message + coinWallet.NombreMoneda + ": " + coinWallet.Balance + " \n"; } } else { message = "You have no coins in your wallet"; } messageSender.SendMessage(chatId, message, keyboard); }
public IActionResult OpenWallet(string path, string password) { if (!SystemFile.Exists(path)) { return(NotFound()); } switch (GetExtension(path)) { case ".db3": { wallet = UserWallet.Open(path, password); break; } case ".json": { NEP6Wallet nep6wallet = new NEP6Wallet(path); nep6wallet.Unlock(password); wallet = nep6wallet; break; } default: throw new NotSupportedException(); } return(FormatJson("Success")); }
private Result ArchiveOnlyUserWallet(UserWallet userWallet) { userWallet.Archived = true; var result = _walletRepository.Update(userWallet); return(result == 0 ? Result.Failure() : Result.Success()); }
private bool OnCreateWalletCommand(string[] args) { if (args.Length < 3) { Console.WriteLine("error"); return(true); } using (SecureString password = ReadSecureString("password")) using (SecureString password2 = ReadSecureString("password")) { if (!password.CompareTo(password2)) { Console.WriteLine("error"); return(true); } Program.Wallet = UserWallet.Create(args[2], password); } VerificationContract contract = Program.Wallet.GetContracts().First(p => p.IsStandard); KeyPair key = (KeyPair)Program.Wallet.GetKey(contract.PublicKeyHash); Console.WriteLine($"address: {contract.Address}"); Console.WriteLine($" pubkey: {key.PublicKey.EncodePoint(true).ToHexString()}"); Console.WriteLine($" Type: {key.nVersion}"); return(true); }
public IHttpActionResult PutUserWallet(long id, UserWallet userWallet) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != userWallet.Id) { return(BadRequest()); } db.Entry(userWallet).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!UserWalletExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <bool> CreateUser(User user) { user.ActivationToken = Guid.NewGuid().ToString(); //generate a unique random token to verify user CheckParameters(user); if (CheckExistingLogin(user.Login)) { return(false); } user.UserCoinsNumber = Constants.DefaultUserCoinsNmber; var userWallet = new UserWallet() { UnusedCoinsNumber = Constants.DefaultUserCoinsNmber }; user.UserWallet = userWallet; AddImage(user); if (user.UserType == UserTypeEnum.Particulier) { var walletId = await _mangoPayService.CreateUser(user); user.WalletId = walletId; } _context.Users.Add(user); _context.SaveChanges(); _emailService.SendUserCreationEmail(user); return(true); }
protected override void Seed(DBContext db) { var tea = new Menu { Name = "Tea", Cost = 13, Count = 10 }; var coffee = new Menu { Name = "Coffee", Cost = 18, Count = 20 }; var coffeeWithMilk = new Menu { Name = "Coffee with milk", Cost = 21, Count = 20 }; var juice = new Menu { Name = "Juice", Cost = 35, Count = 15 }; db.Menus.Add(tea); db.Menus.Add(coffee); db.Menus.Add(coffeeWithMilk); db.Menus.Add(juice); var vm = new VMWallet(); var uw = new UserWallet(); db.VMWallets.Add(vm); db.UserWallets.Add(uw); db.SaveChanges(); }
private void ChangeWallet(UserWallet wallet) { if (Program.CurrentWallet != null) { Program.CurrentWallet.BalanceChanged -= CurrentWallet_BalanceChanged; Program.CurrentWallet.TransactionsChanged -= CurrentWallet_TransactionsChanged; Program.CurrentWallet.Dispose(); } Program.CurrentWallet = wallet; listView3.Items.Clear(); if (Program.CurrentWallet != null) { CurrentWallet_TransactionsChanged(null, Program.CurrentWallet.LoadTransactions()); Program.CurrentWallet.BalanceChanged += CurrentWallet_BalanceChanged; Program.CurrentWallet.TransactionsChanged += CurrentWallet_TransactionsChanged; } 修改密码CToolStripMenuItem.Enabled = Program.CurrentWallet != null; 重建钱包数据库RToolStripMenuItem.Enabled = Program.CurrentWallet != null; 交易TToolStripMenuItem.Enabled = Program.CurrentWallet != null; 高级AToolStripMenuItem.Enabled = Program.CurrentWallet != null; 创建新地址NToolStripMenuItem.Enabled = Program.CurrentWallet != null; 导入私钥IToolStripMenuItem.Enabled = Program.CurrentWallet != null; 创建智能合约SToolStripMenuItem.Enabled = Program.CurrentWallet != null; listView1.Items.Clear(); if (Program.CurrentWallet != null) { foreach (Contract contract in Program.CurrentWallet.GetContracts()) { AddContractToListView(contract); } } balance_changed = true; }
private void btn_confirm_Click(object sender, EventArgs e) { if (!CheckParameters()) { return; } UserWallet wallet; try { wallet = UserWallet.CheckPassword(txb_wallet_path.Text, txb_password.Text); } catch (CryptographicException ex) { lbl_warning.Text = "Password is not correct"; lbl_warning.Show(); return; } catch (FormatException ex) { lbl_warning.Text = ex.Message; lbl_warning.Show(); return; } this.DialogResult = DialogResult.OK; return; }
//TODO: 目前没有想到其它安全的方法来保存密码 //所以只能暂时手动输入,但如此一来就不能以服务的方式启动了 //未来再想想其它办法,比如采用智能卡之类的 private bool OnOpenWalletCommand(string[] args) { if (args.Length < 3) { Console.WriteLine("error"); return(true); } using (SecureString password = ReadSecureString("password")) { if (password.Length == 0) { Console.WriteLine("cancelled"); return(true); } try { wallet = UserWallet.Open(args[2], password); } catch { Console.WriteLine($"failed to open file \"{args[2]}\""); return(true); } } StartMine(); return(true); }
private void 打开钱包数据库OToolStripMenuItem_Click(object sender, EventArgs e) { using (OpenWalletDialog dialog = new OpenWalletDialog()) { if (dialog.ShowDialog() != DialogResult.OK) { return; } if (UserWallet.GetVersion(dialog.WalletPath) < Version.Parse("0.6.6043.32131")) { if (MessageBox.Show("正在打开旧版本的钱包文件,是否尝试将文件升级为新版格式?\n注意,升级后将无法用旧版本的客户端打开该文件!", "钱包文件升级", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) != DialogResult.Yes) { return; } string path_old = Path.ChangeExtension(dialog.WalletPath, ".old.db3"); string path_new = Path.ChangeExtension(dialog.WalletPath, ".new.db3"); UserWallet.Migrate(dialog.WalletPath, path_new); File.Move(dialog.WalletPath, path_old); File.Move(path_new, dialog.WalletPath); MessageBox.Show($"钱包文件迁移成功,旧的文件已经自动保存到以下位置:\n{path_old}"); } UserWallet wallet; try { wallet = UserWallet.Open(dialog.WalletPath, dialog.Password); } catch (CryptographicException) { MessageBox.Show("密码错误!"); return; } ChangeWallet(wallet); } }
public void OpenWallet(string path, string password) { if (!File.Exists(path)) { throw new FileNotFoundException(); } switch (Path.GetExtension(path).ToLowerInvariant()) { case ".db3": { CurrentWallet = UserWallet.Open(path, password); break; } case ".json": { NEP6Wallet nep6wallet = new NEP6Wallet(path); nep6wallet.Unlock(password); CurrentWallet = nep6wallet; break; } default: throw new NotSupportedException(); } }
//TODO: 目前没有想到其它安全的方法来保存密码 //所以只能暂时手动输入,但如此一来就不能以服务的方式启动了 //未来再想想其它办法,比如采用智能卡之类的 private bool OnOpenWalletCommand(string[] args) { if (args.Length < 3) { Console.WriteLine("error"); return(true); } if (!File.Exists(args[2])) { Console.WriteLine($"File does not exist"); return(true); } using (SecureString password = ReadSecureString("password")) { if (password.Length == 0) { Console.WriteLine("cancelled"); return(true); } try { Program.Wallet = UserWallet.Open(args[2], password); } catch { Console.WriteLine($"failed to open file \"{args[2]}\""); return(true); } } return(true); }
public void CreateWallet(string path, string password) { switch (Path.GetExtension(path)) { case ".db3": { UserWallet wallet = UserWallet.Create(path, password); WalletAccount account = wallet.CreateAccount(); Console.WriteLine($" Address: {account.Address}"); Console.WriteLine($" Pubkey: {account.GetKey().PublicKey.EncodePoint(true).ToHexString()}"); Console.WriteLine($"ScriptHash: {account.ScriptHash}"); CurrentWallet = wallet; } break; case ".json": { NEP6Wallet wallet = new NEP6Wallet(path); wallet.Unlock(password); WalletAccount account = wallet.CreateAccount(); wallet.Save(); Console.WriteLine($" Address: {account.Address}"); Console.WriteLine($" Pubkey: {account.GetKey().PublicKey.EncodePoint(true).ToHexString()}"); Console.WriteLine($"ScriptHash: {account.ScriptHash}"); CurrentWallet = wallet; } break; default: Console.WriteLine("Wallet files in that format are not supported, please use a .json or .db3 file extension."); break; } }
private JObject OpenWallet(JArray _params) { string path = _params[0].AsString(); string password = _params[1].AsString(); if (!File.Exists(path)) { throw new FileNotFoundException(); } switch (GetExtension(path)) { case ".db3": { wallet = UserWallet.Open(path, password); break; } case ".json": { NEP6Wallet nep6wallet = new NEP6Wallet(path); nep6wallet.Unlock(password); wallet = nep6wallet; break; } default: throw new NotSupportedException(); } return(true); }
private void 打开钱包数据库OToolStripMenuItem_Click(object sender, EventArgs e) { using (OpenWalletDialog dialog = new OpenWalletDialog()) { if (dialog.ShowDialog() != DialogResult.OK) { return; } if (UserWallet.GetVersion(dialog.WalletPath) < Version.Parse("0.6.6043.32131")) { if (MessageBox.Show(Strings.MigrateWalletMessage, Strings.MigrateWalletCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) != DialogResult.Yes) { return; } string path_old = Path.ChangeExtension(dialog.WalletPath, ".old.db3"); string path_new = Path.ChangeExtension(dialog.WalletPath, ".new.db3"); UserWallet.Migrate(dialog.WalletPath, path_new); File.Move(dialog.WalletPath, path_old); File.Move(path_new, dialog.WalletPath); MessageBox.Show($"{Strings.MigrateWalletSucceedMessage}\n{path_old}"); } UserWallet wallet; try { wallet = UserWallet.Open(dialog.WalletPath, dialog.Password); } catch (CryptographicException) { MessageBox.Show(Strings.PasswordIncorrect); return; } ChangeWallet(wallet); } }
private bool OnCreateWalletCommand(string[] args) { if (args.Length < 3) { Console.WriteLine("error"); return(true); } string path = args[2]; string password = ReadUserInput("password", true); if (password.Length == 0) { Console.WriteLine("cancelled"); return(true); } string password2 = ReadUserInput("password", true); if (password != password2) { Console.WriteLine("error"); return(true); } switch (Path.GetExtension(path)) { case ".db3": { Program.Wallet = UserWallet.Create(GetIndexer(), path, password); WalletAccount account = Program.Wallet.CreateAccount(); Console.WriteLine($"address: {account.Address}"); Console.WriteLine($" pubkey: {account.GetKey().PublicKey.EncodePoint(true).ToHexString()}"); if (system.RpcServer != null) { system.RpcServer.Wallet = Program.Wallet; } } break; case ".json": { NEP6Wallet wallet = new NEP6Wallet(GetIndexer(), path); wallet.Unlock(password); WalletAccount account = wallet.CreateAccount(); wallet.Save(); Program.Wallet = wallet; Console.WriteLine($"address: {account.Address}"); Console.WriteLine($" pubkey: {account.GetKey().PublicKey.EncodePoint(true).ToHexString()}"); if (system.RpcServer != null) { system.RpcServer.Wallet = Program.Wallet; } } break; default: Console.WriteLine("Wallet files in that format are not supported, please use a .json or .db3 file extension."); break; } return(true); }
public static UserWallet Create(string path, string password) { UserWallet wallet = new UserWallet(path, password, true); wallet.CreateAccount(); return wallet; }