Diff cleanups

This commit is contained in:
Dennis Reimann 2024-11-26 11:12:09 +01:00
parent 8d133d6ffc
commit 360037c6cc
No known key found for this signature in database
GPG Key ID: 5009E1797F03F8D0
7 changed files with 16 additions and 47 deletions

View File

@ -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;

View File

@ -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<BTCPayServer.Services.Apps.CrowdfundResetEvery>(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<PointOfSaleSettings>();
Enum.TryParse<PosViewType>(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");

View File

@ -99,13 +99,14 @@ namespace BTCPayServer.Controllers.Greenfield
[HttpGet("~/api/v1/stores/{storeId}/payment-methods/{paymentMethodId}/wallet")]
public async Task<IActionResult> 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<IActionResult> 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";

View File

@ -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<ApplicationUser> 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;

View File

@ -109,6 +109,7 @@ else
</div>
@if (Model.Network is BTCPayNetwork)
{
@if (!Model.WalletEnabled)
{
<a asp-controller="UIStores" asp-action="SetupWallet" asp-route-storeId="@Model.StoreId" asp-route-cryptoCode="@Model.CryptoCode" id="SetupGuide-Wallet" class="list-group-item list-group-item-action d-flex align-items-center order-1">
@ -153,4 +154,3 @@ else
}
</div>
}

View File

@ -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 @@
<div id="LightningNodeTypeTablist" class="nav btcpay-pills align-items-center justify-content-center mb-3" role="tablist">
<input asp-for="LightningNodeType" value="@LightningNodeType.Internal" type="radio" id="LightningNodeType-@LightningNodeType.Internal" data-bs-toggle="pill" data-bs-target="#InternalSetup" role="tab" aria-controls="InternalSetup" aria-selected="@(Model.LightningNodeType == LightningNodeType.Internal ? "true" : "false")" class="@(Model.LightningNodeType == LightningNodeType.Internal ? "active" : "")" disabled="@(!Model.CanUseInternalNode)">
<label asp-for="LightningNodeType" for="@($"LightningNodeType-{LightningNodeType.Internal}")" text-translate="true">Use internal node</label>
<input asp-for="LightningNodeType" value="@LightningNodeType.Custom" type="radio" id="LightningNodeType-@LightningNodeType.Custom" data-bs-toggle="pill" data-bs-target="#CustomSetup" role="tab" aria-controls="CustomSetup" aria-selected="@(Model.LightningNodeType == LightningNodeType.Custom ? "true" : "false")" class="@(Model.LightningNodeType == LightningNodeType.Custom ? "active" : "")">
<label asp-for="LightningNodeType" for="@($"LightningNodeType-{LightningNodeType.Custom}")" text-translate="true">Use custom node</label>
<vc:ui-extension-point location="ln-payment-method-setup-tabhead" model="@Model"/>
</div>
<div id="LightningNodeTypeTabs" class="tab-content text-start">
<div id="InternalSetup" class="pt-3 tab-pane fade @(Model.LightningNodeType == LightningNodeType.Internal ? "show active" : "")" role="tabpanel" aria-labelledby="LightningNodeType-@LightningNodeType.Internal">
@if (Model.CanUseInternalNode)

View File

@ -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