public async Task Post([FromBody] List <WallerChangeRequest> changeRequest) { var wallets = await GetWallets(); foreach (var cr in changeRequest) { if (string.IsNullOrEmpty(cr.WalletAddress)) { continue; } var w = wallets.FirstOrDefault(wa => cr.WalletAddress.Equals(wa.Item2.Address)); if (w == null) { continue; } w.Item2.Amount += cr.DeltaAmount; var encriptedData = EncryptData(JsonConvert.SerializeObject(w.Item2)); await _merchantWalletRepository.SaveNewAddressAsync(new MerchantWalletEntity { MerchantId = w.Item1, WalletAddress = w.Item2.Address, Data = encriptedData }); var ipAddress = Request.HttpContext.GetRealIp(); await _merchantWalletHistoryRepository.SaveNewChangeRequestAsync(cr.WalletAddress, cr.DeltaAmount, "NA", ipAddress); } }
public async Task <GenerateAddressModel> Post([FromBody] GenerateAddressRequest request) { if (string.IsNullOrEmpty(request?.MerchantId) || string.IsNullOrEmpty(request.AssertId)) { return(new GenerateAddressModel { Address = string.Empty }); } var keyInfo = await _bitcoinApi.ApiWalletLykkepayGeneratePostWithHttpMessagesAsync(); var publicKey = (GenerateWalletResponse)keyInfo.Body; var dateToStore = new AssertPrivKeyPair { AssertId = request.AssertId, PublicKey = publicKey.PubKey, Address = publicKey.Address }; var encriptedData = EncryptData(JsonConvert.SerializeObject(dateToStore)); await _merchantWalletRepository.SaveNewAddressAsync(new MerchantWalletEntity { MerchantId = request.MerchantId, WalletAddress = publicKey.Address, Data = encriptedData }); return(new GenerateAddressModel { Address = publicKey.Address }); //using (var rsa = RSA.Create()) //{ // rsa.KeySize = _settings.GenerateKeySize; // var pbl = rsa.ExportParameters(true); // var dateToStore = new AssertPrivKeyPair // { // AssertId = request.AssertId, // PrivateKey = pbl.GetPrivateKey() // }; // var encriptedData = SavePrimaryKey(JsonConvert.SerializeObject(dateToStore)); // await _merchantWalletRepository.SaveNewAddress(new MerchantWalletEntity // { // MerchantId = request.MerchantId, // Data = encriptedData // }); // return pbl.GetPublicKey(); //} }