public async Task GetWalletFilesWhenNoFilesArePresent() { using (NodeBuilder builder = NodeBuilder.Create(this)) { // Arrange. CoreNode node = builder.CreateStratisPosNode(this.network).Start(); // Act. WalletFileModel walletFileModel = await $"http://localhost:{node.ApiPort}/api" .AppendPathSegment("wallet/files") .GetJsonAsync <WalletFileModel>(); // Assert. walletFileModel.WalletsPath.Should().Be(node.FullNode.DataFolder.WalletPath); walletFileModel.WalletsFiles.Should().BeEmpty(); } }
public IActionResult ListWalletsFiles() { try { (string folderPath, IEnumerable <string> filesNames)result = this.walletManager.GetWalletsFiles(); WalletFileModel model = new WalletFileModel { WalletsPath = result.folderPath, WalletsFiles = result.filesNames }; return(this.Json(model)); } catch (Exception e) { return(ErrorHelpers.BuildErrorResponse(HttpStatusCode.BadRequest, e.Message, e.ToString())); } }
public IActionResult ListWalletsFiles() { try { DirectoryInfo walletsFolder = GetWalletFolder(); WalletFileModel model = new WalletFileModel { WalletsPath = walletsFolder.FullName, WalletsFiles = Directory.EnumerateFiles(walletsFolder.FullName, "*.json", SearchOption.TopDirectoryOnly).Select(p => Path.GetFileName(p)) }; return(this.Json(model)); } catch (Exception e) { return(ErrorHelpers.BuildErrorResponse(HttpStatusCode.BadRequest, e.Message, e.ToString())); } }
/// <summary> /// Lists all the wallet files found under the default folder. /// </summary> /// <returns>A list of the wallets files found.</returns> public WalletFileModel ListWalletsFiles() { try { (string folderPath, IEnumerable <string> filesNames)result = this.walletManager.GetWalletsFiles(); WalletFileModel model = new WalletFileModel { WalletsPath = result.folderPath, WalletsFiles = result.filesNames }; return(model); } catch (Exception e) { this.logger.LogError("Exception occurred: {0}", e.ToString()); //return ErrorHelpers.BuildErrorResponse(HttpStatusCode.BadRequest, e.Message, e.ToString()); throw; } }