public async Task <ActionResult> CreateWallet() { try { BlockchainHttpClient httpClient = new BlockchainHttpClient(apicode, ApiURL); using (BlockchainApiHelper apiHelper = new BlockchainApiHelper(apicode, httpClient, "ApiURL", httpClient)) { var emailaddress = Session["Email_Address"] == null ? null : Session["Email_Address"].ToString(); var password = Session["Password"] == null ? null : Session["Password"].ToString(); if (string.IsNullOrEmpty(emailaddress) && string.IsNullOrEmpty(password)) { return(RedirectToAction("Login", "Account")); } else { WalletDetail ObjWalletViewModel = new WalletDetail(); var userid = db.AspNetUsers.Where(w => w.Email == emailaddress).Select(s => s.Id).FirstOrDefault(); CreateWalletResponse walletResponse = await apiHelper.walletCreator.CreateAsync(password, null, null, emailaddress); //apiHelper.walletCreator.CreateAsync("Kindle@123"); ObjWalletViewModel.GuidIdentifier = walletResponse.Identifier; ObjWalletViewModel.UserId = userid; ObjWalletViewModel.Address = walletResponse.Address; db.WalletDetails.Add(ObjWalletViewModel); db.SaveChanges(); return(RedirectToAction("Index")); } } } catch (Exception ex) { throw; } }
public async Task <CreateWalletResponse> CreateWalletAsync() { var response = new CreateWalletResponse { Address = await _walletService.CreateWalletAsync() }; return(response); }
public Task <TResponse> PostAsync <TPost, TResponse>(string route, TPost postObject, Func <string, TResponse> customDeserialization = null, bool multiPartContent = false) { CreateWalletResponse walletResponse = ReflectionUtil.DeserializeFile <CreateWalletResponse>("create_wallet_mock"); if (walletResponse is TResponse) { return(Task.FromResult((TResponse)(object)walletResponse)); } return(Task.FromResult(default(TResponse))); }
public async void CreateWallet_MockRequest_Valid() { using (BlockchainApiHelper apiHelper = new BlockchainApiHelper(baseHttpClient: new MockCreateWalletHttpClient())) { CreateWalletResponse walletResponse = await apiHelper.WalletCreator.Create("Password"); Assert.NotNull(walletResponse); Assert.Equal(walletResponse.Address, "12AaMuRnzw6vW6s2KPRAGeX53meTf8JbZS"); Assert.Equal(walletResponse.Identifier, "4b8cd8e9-9480-44cc-b7f2-527e98ee3287"); Assert.Equal(walletResponse.Label, "My Blockchain Wallet"); } }
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ public CreateWalletResponse CreateWallet(string passwordString, string walletLabel) { BlockchainApiSettings blockchainApiSettings = GetSettings(); using (BlockchainApiHelper apiHelper = new BlockchainApiHelper(apiCode: blockchainApiSettings.ApiKey, serviceUrl: blockchainApiSettings.ServiceUrl)) { try { WalletCreator walletCreator = apiHelper.CreateWalletCreator(); CreateWalletResponse newWallet = walletCreator.CreateAsync(passwordString, label: walletLabel).Result; return(newWallet); } catch (ClientApiException e) { throw new ArgumentException("Blockchain exception: " + e.Message); } } }
static void Main(string[] args) { try { var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("config.json"); Config = builder.Build(); var httpClient = new BlockchainHttpClient(Config["BlockChainInfo:ApiCode"], Config["BlockChainInfo:WalletServiceLink"]); var walletCreator = new WalletCreator(httpClient); CreateWalletResponse walletResponce = walletCreator.CreateAsync(Config["BlockChainInfo:MainPassword"], null, Config["BlockChainInfo:Label"]).Result; StreamWriter w = new StreamWriter(Config["WritePath"]); w.Write(JsonConvert.SerializeObject(walletResponce)); w.Close(); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.ReadKey(); } }