From 360037c6cc3fadc6b4ae64c7e891ae7c1f679a7b Mon Sep 17 00:00:00 2001 From: Dennis Reimann Date: Tue, 26 Nov 2024 11:12:09 +0100 Subject: [PATCH] Diff cleanups --- .../StoreLightningBalanceViewModel.cs | 1 - .../GreenField/GreenfieldAppsController.cs | 14 +++++----- ...GreenfieldStoreOnChainWalletsController.cs | 9 ++++--- .../StoreWalletsNavMoneroExtension.cshtml | 3 +-- BTCPayServer/Views/UIStores/Dashboard.cshtml | 2 +- .../Views/UIStores/SetupLightningNode.cshtml | 8 ++---- btcpayserver.sln | 26 ------------------- 7 files changed, 16 insertions(+), 47 deletions(-) diff --git a/BTCPayServer/Components/StoreLightningBalance/StoreLightningBalanceViewModel.cs b/BTCPayServer/Components/StoreLightningBalance/StoreLightningBalanceViewModel.cs index 95bdd089c..d4d2a1d85 100644 --- a/BTCPayServer/Components/StoreLightningBalance/StoreLightningBalanceViewModel.cs +++ b/BTCPayServer/Components/StoreLightningBalance/StoreLightningBalanceViewModel.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using BTCPayServer.Client.Models; using BTCPayServer.Lightning; using BTCPayServer.Services.Rates; -using BTCPayServer.Services.Wallets; using NBitcoin; namespace BTCPayServer.Components.StoreLightningBalance; diff --git a/BTCPayServer/Controllers/GreenField/GreenfieldAppsController.cs b/BTCPayServer/Controllers/GreenField/GreenfieldAppsController.cs index 57ea76eb8..f148cd281 100644 --- a/BTCPayServer/Controllers/GreenField/GreenfieldAppsController.cs +++ b/BTCPayServer/Controllers/GreenField/GreenfieldAppsController.cs @@ -20,6 +20,7 @@ using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; using CrowdfundResetEvery = BTCPayServer.Client.Models.CrowdfundResetEvery; using PosViewType = BTCPayServer.Client.Models.PosViewType; @@ -251,7 +252,7 @@ namespace BTCPayServer.Controllers.Greenfield if (app == null) return AppNotFound(); var stats = (await _appService.GetItemStats(app)).ToList(); - var max = Math.Min(count, stats.Count - offset); + var max = Math.Min(count, stats.Count - offset); var items = stats.GetRange(offset, max); return Ok(items); } @@ -275,7 +276,7 @@ namespace BTCPayServer.Controllers.Greenfield } if (!ModelState.IsValid) return this.CreateValidationError(ModelState); - + try { var storedFile = upload!.StoredFile!; @@ -283,7 +284,6 @@ namespace BTCPayServer.Controllers.Greenfield { Id = storedFile.Id, UserId = storedFile.ApplicationUserId, - Uri = new UnresolvedUri.FileIdUri(storedFile.Id).ToString(), Url = await _fileService.GetFileUrl(Request.GetAbsoluteRootUri(), storedFile.Id), OriginalName = storedFile.FileName, StorageName = storedFile.StorageFileName, @@ -307,7 +307,7 @@ namespace BTCPayServer.Controllers.Greenfield if (!string.IsNullOrEmpty(fileId)) await _fileService.RemoveFile(fileId, userId); return Ok(); } - + private IActionResult AppNotFound() { return this.CreateAPIError(404, "app-not-found", "The app with specified ID was not found"); @@ -318,7 +318,7 @@ namespace BTCPayServer.Controllers.Greenfield var parsedSounds = ValidateStringArray(request.Sounds); var parsedColors = ValidateStringArray(request.AnimationColors); Enum.TryParse(request.ResetEvery.ToString(), true, out var resetEvery); - + return new CrowdfundSettings { Title = request.Title?.Trim() ?? request.AppName, @@ -409,7 +409,7 @@ namespace BTCPayServer.Controllers.Greenfield var settings = appData.GetSettings(); Enum.TryParse(settings.DefaultView.ToString(), true, out var defaultView); var items = AppService.Parse(settings.Template); - + return new PointOfSaleAppData { Id = appData.Id, @@ -548,7 +548,7 @@ namespace BTCPayServer.Controllers.Greenfield ModelState.AddModelError(nameof(request.ResetEveryAmount), "You must reset the goal at a minimum of 1"); } } - + if (request.Sounds != null && ValidateStringArray(request.Sounds) == null) { ModelState.AddModelError(nameof(request.Sounds), "Sounds must be a non-empty array of non-empty strings"); diff --git a/BTCPayServer/Controllers/GreenField/GreenfieldStoreOnChainWalletsController.cs b/BTCPayServer/Controllers/GreenField/GreenfieldStoreOnChainWalletsController.cs index bd1ef0d24..9f2b6bcfd 100644 --- a/BTCPayServer/Controllers/GreenField/GreenfieldStoreOnChainWalletsController.cs +++ b/BTCPayServer/Controllers/GreenField/GreenfieldStoreOnChainWalletsController.cs @@ -99,13 +99,14 @@ namespace BTCPayServer.Controllers.Greenfield [HttpGet("~/api/v1/stores/{storeId}/payment-methods/{paymentMethodId}/wallet")] public async Task ShowOnChainWalletOverview(string storeId, string paymentMethodId) { - if (IsInvalidWalletRequest(paymentMethodId, out var network, out var derivationScheme, out var actionResult)) + if (IsInvalidWalletRequest(paymentMethodId, out var network, + out var derivationScheme, out var actionResult)) return actionResult; var wallet = _btcPayWalletProvider.GetWallet(network); var balance = await wallet.GetBalance(derivationScheme.AccountDerivation); - return Ok(new OnChainWalletOverviewData + return Ok(new OnChainWalletOverviewData() { Label = derivationScheme.ToPrettyString(), Balance = balance.Total.GetValue(network), @@ -134,7 +135,7 @@ namespace BTCPayServer.Controllers.Greenfield Labels = data.Labels }); } - + [Authorize(Policy = Policies.CanViewStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Greenfield)] [HttpGet("~/api/v1/stores/{storeId}/payment-methods/{paymentMethodId}/wallet/feerate")] public async Task GetOnChainFeeRate(string storeId, string paymentMethodId, int? blockTarget = null) @@ -572,7 +573,7 @@ namespace BTCPayServer.Controllers.Greenfield WellknownMetadataKeys.MasterHDKey); if (!derivationScheme.IsHotWallet || signingKeyStr is null) { - var reason = !derivationScheme.IsHotWallet ? + var reason = !derivationScheme.IsHotWallet ? "You cannot send from a cold wallet" : "NBXplorer doesn't have the seed of the wallet"; diff --git a/BTCPayServer/Views/Shared/Monero/StoreWalletsNavMoneroExtension.cshtml b/BTCPayServer/Views/Shared/Monero/StoreWalletsNavMoneroExtension.cshtml index aff432703..ee595ea71 100644 --- a/BTCPayServer/Views/Shared/Monero/StoreWalletsNavMoneroExtension.cshtml +++ b/BTCPayServer/Views/Shared/Monero/StoreWalletsNavMoneroExtension.cshtml @@ -1,7 +1,6 @@ @using BTCPayServer.Services.Altcoins.Monero.Configuration @using BTCPayServer.Services.Altcoins.Monero.UI @using BTCPayServer.Abstractions.Contracts -@using Microsoft.AspNetCore.Mvc.TagHelpers @inject SignInManager SignInManager; @inject MoneroLikeConfiguration MoneroLikeConfiguration; @inject IScopeProvider ScopeProvider @@ -17,7 +16,7 @@ foreach (var item in result.Items) { - + var isActive = !string.IsNullOrEmpty(storeId) && ViewContext.RouteData.Values.TryGetValue("Controller", out var controller) && controller is not null && nameof(UIMoneroLikeStoreController).StartsWith(controller.ToString() ?? string.Empty, StringComparison.InvariantCultureIgnoreCase) && ViewContext.RouteData.Values.TryGetValue("cryptoCode", out var cryptoCode) && cryptoCode is not null && cryptoCode.ToString() == item.CryptoCode; diff --git a/BTCPayServer/Views/UIStores/Dashboard.cshtml b/BTCPayServer/Views/UIStores/Dashboard.cshtml index 80392e926..2cddd7a19 100644 --- a/BTCPayServer/Views/UIStores/Dashboard.cshtml +++ b/BTCPayServer/Views/UIStores/Dashboard.cshtml @@ -109,6 +109,7 @@ else @if (Model.Network is BTCPayNetwork) { + @if (!Model.WalletEnabled) { @@ -153,4 +154,3 @@ else } } - diff --git a/BTCPayServer/Views/UIStores/SetupLightningNode.cshtml b/BTCPayServer/Views/UIStores/SetupLightningNode.cshtml index 09555c74e..3a28d77d6 100644 --- a/BTCPayServer/Views/UIStores/SetupLightningNode.cshtml +++ b/BTCPayServer/Views/UIStores/SetupLightningNode.cshtml @@ -1,7 +1,3 @@ -@using BTCPayServer.Controllers -@using Microsoft.AspNetCore.Mvc.TagHelpers -@using BTCPayServer.Components.UIExtensionPoint -@using BTCPayServer.Components.QRCode @model LightningNodeViewModel @{ Layout = "_LayoutWalletSetup.cshtml"; @@ -33,13 +29,13 @@ - +
@if (Model.CanUseInternalNode) diff --git a/btcpayserver.sln b/btcpayserver.sln index 8f43347f6..b7d014ad6 100644 --- a/btcpayserver.sln +++ b/btcpayserver.sln @@ -32,8 +32,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BTCPayServer.Abstractions", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BTCPayServer.PluginPacker", "BTCPayServer.PluginPacker\BTCPayServer.PluginPacker.csproj", "{7DC94B25-1CFC-4170-AA41-7BA983E4C0B8}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BTCPayApp.CommonServer", "BTCPayApp.CommonServer\BTCPayApp.CommonServer.csproj", "{F204A9E1-52D8-4B67-BE53-5C6B589B64A0}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -140,30 +138,6 @@ Global {7DC94B25-1CFC-4170-AA41-7BA983E4C0B8}.Release|x64.Build.0 = Release|Any CPU {7DC94B25-1CFC-4170-AA41-7BA983E4C0B8}.Release|x86.ActiveCfg = Release|Any CPU {7DC94B25-1CFC-4170-AA41-7BA983E4C0B8}.Release|x86.Build.0 = Release|Any CPU - {F204A9E1-52D8-4B67-BE53-5C6B589B64A0}.Altcoins-Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F204A9E1-52D8-4B67-BE53-5C6B589B64A0}.Altcoins-Debug|Any CPU.Build.0 = Debug|Any CPU - {F204A9E1-52D8-4B67-BE53-5C6B589B64A0}.Altcoins-Debug|x64.ActiveCfg = Debug|Any CPU - {F204A9E1-52D8-4B67-BE53-5C6B589B64A0}.Altcoins-Debug|x64.Build.0 = Debug|Any CPU - {F204A9E1-52D8-4B67-BE53-5C6B589B64A0}.Altcoins-Debug|x86.ActiveCfg = Debug|Any CPU - {F204A9E1-52D8-4B67-BE53-5C6B589B64A0}.Altcoins-Debug|x86.Build.0 = Debug|Any CPU - {F204A9E1-52D8-4B67-BE53-5C6B589B64A0}.Altcoins-Release|Any CPU.ActiveCfg = Debug|Any CPU - {F204A9E1-52D8-4B67-BE53-5C6B589B64A0}.Altcoins-Release|Any CPU.Build.0 = Debug|Any CPU - {F204A9E1-52D8-4B67-BE53-5C6B589B64A0}.Altcoins-Release|x64.ActiveCfg = Debug|Any CPU - {F204A9E1-52D8-4B67-BE53-5C6B589B64A0}.Altcoins-Release|x64.Build.0 = Debug|Any CPU - {F204A9E1-52D8-4B67-BE53-5C6B589B64A0}.Altcoins-Release|x86.ActiveCfg = Debug|Any CPU - {F204A9E1-52D8-4B67-BE53-5C6B589B64A0}.Altcoins-Release|x86.Build.0 = Debug|Any CPU - {F204A9E1-52D8-4B67-BE53-5C6B589B64A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F204A9E1-52D8-4B67-BE53-5C6B589B64A0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F204A9E1-52D8-4B67-BE53-5C6B589B64A0}.Debug|x64.ActiveCfg = Debug|Any CPU - {F204A9E1-52D8-4B67-BE53-5C6B589B64A0}.Debug|x64.Build.0 = Debug|Any CPU - {F204A9E1-52D8-4B67-BE53-5C6B589B64A0}.Debug|x86.ActiveCfg = Debug|Any CPU - {F204A9E1-52D8-4B67-BE53-5C6B589B64A0}.Debug|x86.Build.0 = Debug|Any CPU - {F204A9E1-52D8-4B67-BE53-5C6B589B64A0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F204A9E1-52D8-4B67-BE53-5C6B589B64A0}.Release|Any CPU.Build.0 = Release|Any CPU - {F204A9E1-52D8-4B67-BE53-5C6B589B64A0}.Release|x64.ActiveCfg = Release|Any CPU - {F204A9E1-52D8-4B67-BE53-5C6B589B64A0}.Release|x64.Build.0 = Release|Any CPU - {F204A9E1-52D8-4B67-BE53-5C6B589B64A0}.Release|x86.ActiveCfg = Release|Any CPU - {F204A9E1-52D8-4B67-BE53-5C6B589B64A0}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE