diff --git a/BTCPayServer.Client/App/IBTCPayAppHubClient.cs b/BTCPayServer.Client/App/IBTCPayAppHubClient.cs new file mode 100644 index 000000000..78e0c17a8 --- /dev/null +++ b/BTCPayServer.Client/App/IBTCPayAppHubClient.cs @@ -0,0 +1,139 @@ +#nullable enable +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using BTCPayServer.Client.Models; +using BTCPayServer.Lightning; +using NBitcoin; + +namespace BTCPayServer.Client.App; + +//methods available on the hub in the client +public interface IBTCPayAppHubClient +{ + Task NotifyServerEvent(ServerEvent ev); + Task NotifyNetwork(string network); + Task NotifyServerNode(string nodeInfo); + Task TransactionDetected(TransactionDetectedRequest request); + Task NewBlock(string block); + Task StartListen(string key); + + Task CreateInvoice(string key, CreateLightningInvoiceRequest createLightningInvoiceRequest); + Task GetLightningInvoice(string key, uint256 paymentHash); + Task GetLightningPayment(string key, uint256 paymentHash); + Task CancelInvoice(string key, uint256 paymentHash); + Task> GetLightningPayments(string key, ListPaymentsParams request); + Task> GetLightningInvoices(string key, ListInvoicesParams request); + Task PayInvoice(string key, string bolt11, long? amountMilliSatoshi); + Task MasterUpdated(long? deviceIdentifier); + Task GetLightningNodeInfo(string key); + Task GetLightningBalance(string key); +} + +//methods available on the hub in the server +public interface IBTCPayAppHubServer +{ + Task DeviceMasterSignal(long deviceIdentifier, bool active); + + Task> Pair(PairRequest request); + Task Handshake(AppHandshake request); + Task BroadcastTransaction(string tx); + Task GetFeeRate(int blockTarget); + Task GetBestBlock(); + Task FetchTxsAndTheirBlockHeads(string identifier, string[] txIds, string[] outpoints); + Task DeriveScript(string identifier); + Task TrackScripts(string identifier, string[] scripts); + Task UpdatePsbt(string[] identifiers, string psbt); + Task GetUTXOs(string[] identifiers); + Task> GetTransactions(string[] identifiers); + Task SendInvoiceUpdate(LightningInvoice lightningInvoice); + Task GetCurrentMaster(); +} + +public class ServerEvent +{ + public string? Type { get; set; } + public string? StoreId { get; set; } + public string? UserId { get; set; } + public string? AppId { get; set; } + public string? InvoiceId { get; set; } + public string? Detail { get; set; } +} + +public record TxResp +{ + public TxResp(long confirmations, long? height, decimal balanceChange, DateTimeOffset timestamp, string transactionId) + { + Confirmations = confirmations; + Height = height; + BalanceChange = balanceChange; + Timestamp = timestamp; + TransactionId = transactionId; + } + + public long Confirmations { get; set; } + public long? Height { get; set; } + public decimal BalanceChange { get; set; } + public DateTimeOffset Timestamp { get; set; } + public string TransactionId { get; set; } + + public override string ToString() + { + return $"{{ Confirmations = {Confirmations}, Height = {Height}, BalanceChange = {BalanceChange}, Timestamp = {Timestamp}, TransactionId = {TransactionId} }}"; + } +} + +public class TransactionDetectedRequest +{ + public string? Identifier { get; set; } + public string? TxId { get; set; } + public string[]? SpentScripts { get; set; } + public string[]? ReceivedScripts { get; set; } + public bool Confirmed { get; set; } +} + +public class CoinResponse +{ + public string? Identifier{ get; set; } + public bool Confirmed { get; set; } + public string? Script { get; set; } + public string? Outpoint { get; set; } + public decimal Value { get; set; } + public string? Path { get; set; } +} + +public class TxInfoResponse +{ + public Dictionary? Txs { get; set; } + public Dictionary? BlockHeaders { get; set; } + public Dictionary? BlockHeghts { get; set; } +} + +public class TransactionResponse +{ + public string? BlockHash { get; set; } + public string? Transaction { get; set; } +} + +public class BestBlockResponse +{ + public string? BlockHash { get; set; } + public int BlockHeight { get; set; } + public string? BlockHeader { get; set; } +} + +public class AppHandshake +{ + public string[]? Identifiers { get; set; } +} + +public class AppHandshakeResponse +{ + //response about identifiers being tracked successfully + public string[]? IdentifiersAcknowledged { get; set; } +} + +public class PairRequest +{ + public Dictionary Derivations { get; set; } = new(); +} diff --git a/BTCPayServer.Client/App/Models/AcceptInviteRequest.cs b/BTCPayServer.Client/App/Models/AcceptInviteRequest.cs new file mode 100644 index 000000000..6f0b21b04 --- /dev/null +++ b/BTCPayServer.Client/App/Models/AcceptInviteRequest.cs @@ -0,0 +1,8 @@ +#nullable enable +namespace BTCPayServer.Client.App.Models; + +public class AcceptInviteRequest +{ + public string? UserId { get; set; } + public string? Code { get; set; } +} diff --git a/BTCPayServer.Client/App/Models/AcceptInviteResult.cs b/BTCPayServer.Client/App/Models/AcceptInviteResult.cs new file mode 100644 index 000000000..deaee0171 --- /dev/null +++ b/BTCPayServer.Client/App/Models/AcceptInviteResult.cs @@ -0,0 +1,10 @@ +#nullable enable +namespace BTCPayServer.Client.App.Models; + +public class AcceptInviteResult +{ + public string? Email { get; set; } + public bool? RequiresUserApproval { get; set; } + public bool? EmailHasBeenConfirmed { get; set; } + public string? PasswordSetCode { get; set; } +} diff --git a/BTCPayServer.Client/App/Models/AccessTokenResult.cs b/BTCPayServer.Client/App/Models/AccessTokenResult.cs new file mode 100644 index 000000000..63d134397 --- /dev/null +++ b/BTCPayServer.Client/App/Models/AccessTokenResult.cs @@ -0,0 +1,10 @@ +using System; + +namespace BTCPayServer.Client.App.Models; + +public class AccessTokenResult +{ + public string AccessToken { get; set; } + public string RefreshToken { get; set; } + public DateTimeOffset Expiry { get; set; } +} diff --git a/BTCPayServer.Client/App/Models/AppInstanceInfo.cs b/BTCPayServer.Client/App/Models/AppInstanceInfo.cs new file mode 100644 index 000000000..08d76f9ed --- /dev/null +++ b/BTCPayServer.Client/App/Models/AppInstanceInfo.cs @@ -0,0 +1,13 @@ +#nullable enable +namespace BTCPayServer.Client.App.Models; + +public class AppInstanceInfo +{ + public string BaseUrl { get; set; } = null!; + public string ServerName { get; set; } = null!; + public string? ContactUrl { get; set; } + public string? LogoUrl { get; set; } + public string? CustomThemeCssUrl { get; set; } + public string? CustomThemeExtension { get; set; } + public bool RegistrationEnabled { get; set; } +} diff --git a/BTCPayServer.Client/App/Models/AppUserInfo.cs b/BTCPayServer.Client/App/Models/AppUserInfo.cs new file mode 100644 index 000000000..bb32049d9 --- /dev/null +++ b/BTCPayServer.Client/App/Models/AppUserInfo.cs @@ -0,0 +1,44 @@ +#nullable enable +using System.Collections.Generic; + +namespace BTCPayServer.Client.App.Models; + +public class AppUserInfo +{ + public string? UserId { get; set; } + public string? Email { get; set; } + public string? Name { get; set; } + public string? ImageUrl { get; set; } + public IEnumerable? Roles { get; set; } + public IEnumerable? Stores { get; set; } + + public void SetInfo(string email, string? name, string? imageUrl) + { + Email = email; + Name = name; + ImageUrl = imageUrl; + } + + public static bool Equals(AppUserInfo? x, AppUserInfo? y) + { + if (ReferenceEquals(x, y)) return true; + if (ReferenceEquals(x, null)) return false; + if (ReferenceEquals(y, null)) return false; + if (x.GetType() != y.GetType()) return false; + return x.UserId == y.UserId && x.Email == y.Email && + x.Name == y.Name && x.ImageUrl == y.ImageUrl && + Equals(x.Roles, y.Roles) && Equals(x.Stores, y.Stores); + } +} + +public class AppUserStoreInfo +{ + public string Id { get; set; } = null!; + public string? Name { get; set; } + public string? LogoUrl { get; set; } + public string? RoleId { get; set; } + public string? PosAppId { get; set; } + public string? DefaultCurrency { get; set; } + public bool Archived { get; set; } + public IEnumerable? Permissions { get; set; } +} diff --git a/BTCPayServer.Client/App/Models/CreateStoreData.cs b/BTCPayServer.Client/App/Models/CreateStoreData.cs new file mode 100644 index 000000000..4040c8ec1 --- /dev/null +++ b/BTCPayServer.Client/App/Models/CreateStoreData.cs @@ -0,0 +1,11 @@ +#nullable enable +using System.Collections.Generic; + +namespace BTCPayServer.Client.App.Models; + +public class CreateStoreData +{ + public string? DefaultCurrency { get; set; } + public string? RecommendedExchangeId { get; set; } + public Dictionary? Exchanges { get; set; } +} diff --git a/BTCPayServer.Client/Models/AppCartItem.cs b/BTCPayServer.Client/Models/AppCartItem.cs new file mode 100644 index 000000000..43732e1da --- /dev/null +++ b/BTCPayServer.Client/Models/AppCartItem.cs @@ -0,0 +1,13 @@ +using BTCPayServer.JsonConverters; +using Newtonsoft.Json; + +namespace BTCPayServer.Client.Models; + +public class AppCartItem +{ + public string Id { get; set; } + public string Title { get; set; } + public int Count { get; set; } + [JsonConverter(typeof(NumericStringJsonConverter))] + public decimal Price { get; set; } +} diff --git a/BTCPayServer.Client/Models/CreatePosInvoiceRequest.cs b/BTCPayServer.Client/Models/CreatePosInvoiceRequest.cs new file mode 100644 index 000000000..bf8f68c90 --- /dev/null +++ b/BTCPayServer.Client/Models/CreatePosInvoiceRequest.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; +using BTCPayServer.JsonConverters; +using Newtonsoft.Json; + +namespace BTCPayServer.Client.Models; + +public class CreatePosInvoiceRequest +{ + public string AppId { get; set; } + public List Cart { get; set; } + [JsonProperty(ItemConverterType = typeof(NumericStringJsonConverter))] + public List Amounts { get; set; } + public int? DiscountPercent { get; set; } + public int? TipPercent { get; set; } + [JsonConverter(typeof(NumericStringJsonConverter))] + public decimal? DiscountAmount { get; set; } + [JsonConverter(typeof(NumericStringJsonConverter))] + public decimal? Tip { get; set; } + [JsonConverter(typeof(NumericStringJsonConverter))] + public decimal? Subtotal { get; set; } + [JsonConverter(typeof(NumericStringJsonConverter))] + public decimal? Total { get; set; } + public string PosData { get; set; } +} + diff --git a/BTCPayServer.Client/Models/PermissionMetadata.cs b/BTCPayServer.Client/Models/PermissionMetadata.cs index cf02a6270..b4156c71a 100644 --- a/BTCPayServer.Client/Models/PermissionMetadata.cs +++ b/BTCPayServer.Client/Models/PermissionMetadata.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; using Newtonsoft.Json; namespace BTCPayServer.Client.Models @@ -11,17 +10,17 @@ namespace BTCPayServer.Client.Models static PermissionMetadata() { Dictionary nodes = new Dictionary(); - foreach (var policy in Client.Policies.AllPolicies) + foreach (var policy in Policies.AllPolicies) { nodes.Add(policy, new PermissionMetadata() { PermissionName = policy }); } foreach (var n in nodes) { - foreach (var policy in Client.Policies.AllPolicies) + foreach (var policy in Policies.AllPolicies) { if (policy.Equals(n.Key, StringComparison.OrdinalIgnoreCase)) continue; - if (Client.Permission.Create(n.Key).Contains(Client.Permission.Create(policy))) + if (Permission.Create(n.Key).Contains(Permission.Create(policy))) n.Value.SubPermissions.Add(policy); } } diff --git a/BTCPayServer.Client/Permissions.cs b/BTCPayServer.Client/Permissions.cs index d8faa3bd7..d538207ec 100644 --- a/BTCPayServer.Client/Permissions.cs +++ b/BTCPayServer.Client/Permissions.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Globalization; using System.Linq; -using System.Linq.Expressions; using System.Text.RegularExpressions; namespace BTCPayServer.Client diff --git a/BTCPayServer.Client/PosDataParser.cs b/BTCPayServer.Client/PosDataParser.cs new file mode 100644 index 000000000..9ca6aa109 --- /dev/null +++ b/BTCPayServer.Client/PosDataParser.cs @@ -0,0 +1,50 @@ +#nullable enable +using System.Collections.Generic; +using System.Linq; +using Newtonsoft.Json.Linq; + +namespace BTCPayServer.Client; + +public static class PosDataParser +{ + public static Dictionary ParsePosData(JToken? posData) + { + var result = new Dictionary(); + if (posData is JObject jobj) + { + foreach (var item in jobj) + { + ParsePosDataItem(item, ref result); + } + } + return result; + } + + static void ParsePosDataItem(KeyValuePair item, ref Dictionary result) + { + switch (item.Value?.Type) + { + case JTokenType.Array: + var items = item.Value.AsEnumerable().ToList(); + var arrayResult = new List(); + for (var i = 0; i < items.Count; i++) + { + arrayResult.Add(items[i] is JObject + ? ParsePosData(items[i]) + : items[i].ToString()); + } + + result.TryAdd(item.Key, arrayResult); + + break; + case JTokenType.Object: + result.TryAdd(item.Key, ParsePosData(item.Value)); + break; + case null: + break; + default: + result.TryAdd(item.Key, item.Value.ToString()); + break; + } + } +} diff --git a/BTCPayServer.Common/BTCPayNetwork.cs b/BTCPayServer.Common/BTCPayNetwork.cs index c8e0ccc99..68b0fc770 100644 --- a/BTCPayServer.Common/BTCPayNetwork.cs +++ b/BTCPayServer.Common/BTCPayNetwork.cs @@ -4,8 +4,6 @@ using System.Globalization; using System.IO; using System.Linq; using BTCPayServer.Common; -using Microsoft.AspNetCore.HttpOverrides; -using Microsoft.Extensions.DependencyInjection; using NBitcoin; using NBXplorer; using NBXplorer.Models; diff --git a/BTCPayServer.Common/BTCPayNetworkProvider.cs b/BTCPayServer.Common/BTCPayNetworkProvider.cs index dfa3c028b..15cb9ba27 100644 --- a/BTCPayServer.Common/BTCPayNetworkProvider.cs +++ b/BTCPayServer.Common/BTCPayNetworkProvider.cs @@ -3,13 +3,9 @@ using System.Collections.Generic; using System.Linq; using BTCPayServer.Configuration; using BTCPayServer.Logging; -using Microsoft.AspNetCore.DataProtection.KeyManagement; -using Microsoft.AspNetCore.HttpOverrides; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using NBitcoin; using NBXplorer; -using StandardConfiguration; namespace BTCPayServer { diff --git a/BTCPayServer.Common/BTCPayServer.Common.csproj b/BTCPayServer.Common/BTCPayServer.Common.csproj index 07560f6fb..023f30477 100644 --- a/BTCPayServer.Common/BTCPayServer.Common.csproj +++ b/BTCPayServer.Common/BTCPayServer.Common.csproj @@ -1,9 +1,7 @@ - - diff --git a/BTCPayServer.Common/MultiProcessingQueue.cs b/BTCPayServer.Common/MultiProcessingQueue.cs index 93674eab8..481e252a8 100644 --- a/BTCPayServer.Common/MultiProcessingQueue.cs +++ b/BTCPayServer.Common/MultiProcessingQueue.cs @@ -1,7 +1,5 @@ -using System; using System.Collections.Generic; using System.Linq; -using System.Text; using System.Threading; using System.Threading.Channels; using System.Threading.Tasks; diff --git a/BTCPayServer.Common/SelectedChains.cs b/BTCPayServer.Common/SelectedChains.cs index 7232b5014..3867a1ab3 100644 --- a/BTCPayServer.Common/SelectedChains.cs +++ b/BTCPayServer.Common/SelectedChains.cs @@ -4,7 +4,6 @@ using System.Linq; using BTCPayServer.Logging; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; -using Newtonsoft.Json.Bson; namespace BTCPayServer { diff --git a/BTCPayServer.Tests/BTCPayServerTester.cs b/BTCPayServer.Tests/BTCPayServerTester.cs index 05eccbdb1..d6036ae31 100644 --- a/BTCPayServer.Tests/BTCPayServerTester.cs +++ b/BTCPayServer.Tests/BTCPayServerTester.cs @@ -7,6 +7,7 @@ using System.Security.Claims; using System.Text; using System.Threading; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Constants; using BTCPayServer.Configuration; using BTCPayServer.HostedServices; using BTCPayServer.Hosting; @@ -27,7 +28,6 @@ using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Logging; using NBitcoin; using NBXplorer; -using AuthenticationSchemes = BTCPayServer.Abstractions.Constants.AuthenticationSchemes; namespace BTCPayServer.Tests { diff --git a/BTCPayServer.Tests/FastTests.cs b/BTCPayServer.Tests/FastTests.cs index 07c1a5676..36505cf63 100644 --- a/BTCPayServer.Tests/FastTests.cs +++ b/BTCPayServer.Tests/FastTests.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; -using System.Reflection.Metadata; using System.Runtime.CompilerServices; using System.Security; using System.Text; @@ -11,7 +10,6 @@ using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using BTCPayServer.Abstractions.Extensions; -using BTCPayServer.Abstractions.Models; using BTCPayServer.Client; using BTCPayServer.Client.Models; using BTCPayServer.Configuration; @@ -20,40 +18,28 @@ using BTCPayServer.Data; using BTCPayServer.HostedServices; using BTCPayServer.Hosting; using BTCPayServer.JsonConverters; -using BTCPayServer.Lightning; -using BTCPayServer.Logging; using BTCPayServer.Payments; -using BTCPayServer.Payments.Bitcoin; -using BTCPayServer.Payments.Lightning; -using BTCPayServer.Plugins; -using BTCPayServer.Plugins.Bitcoin; using BTCPayServer.Rating; using BTCPayServer.Services; using BTCPayServer.Services.Apps; using BTCPayServer.Services.Fees; using BTCPayServer.Services.Invoices; -using BTCPayServer.Services.Labels; using BTCPayServer.Services.Rates; using BTCPayServer.Services.Stores; using BTCPayServer.Validation; -using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration.Memory; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using NBitcoin; -using NBitcoin.DataEncoders; using NBitcoin.Scripting.Parser; -using NBXplorer; using NBXplorer.DerivationStrategy; using NBXplorer.Models; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using Newtonsoft.Json.Serialization; using Xunit; using Xunit.Abstractions; -using StoreData = BTCPayServer.Data.StoreData; namespace BTCPayServer.Tests { @@ -1671,7 +1657,7 @@ bc1qfzu57kgu5jthl934f9xrdzzx8mmemx7gn07tf0grnvz504j6kzusu2v0ku testCases.ForEach(tuple => { - Assert.Equal(tuple.expectedOutput, UIInvoiceController.PosDataParser.ParsePosData(string.IsNullOrEmpty(tuple.input) ? null : JToken.Parse(tuple.input))); + Assert.Equal(tuple.expectedOutput, PosDataParser.ParsePosData(string.IsNullOrEmpty(tuple.input) ? null : JToken.Parse(tuple.input))); }); } [Fact] diff --git a/BTCPayServer.Tests/POSTests.cs b/BTCPayServer.Tests/POSTests.cs index 732dc6380..f1e1bd5f5 100644 --- a/BTCPayServer.Tests/POSTests.cs +++ b/BTCPayServer.Tests/POSTests.cs @@ -6,7 +6,6 @@ using BTCPayServer.Controllers; using BTCPayServer.Data; using BTCPayServer.Hosting; using BTCPayServer.Models.AppViewModels; -using BTCPayServer.Plugins.Crowdfund.Models; using BTCPayServer.Plugins.PointOfSale; using BTCPayServer.Plugins.PointOfSale.Controllers; using BTCPayServer.Plugins.PointOfSale.Models; diff --git a/BTCPayServer.Tests/TestAccount.cs b/BTCPayServer.Tests/TestAccount.cs index b143c441c..6fe1fe1b3 100644 --- a/BTCPayServer.Tests/TestAccount.cs +++ b/BTCPayServer.Tests/TestAccount.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Diagnostics.Metrics; using System.IO; using System.Linq; using System.Net.Http; @@ -15,8 +14,6 @@ using BTCPayServer.Client.Models; using BTCPayServer.Controllers; using BTCPayServer.Data; using BTCPayServer.Events; -using BTCPayServer.Lightning; -using BTCPayServer.Lightning.CLightning; using BTCPayServer.Models.AccountViewModels; using BTCPayServer.Models.StoreViewModels; using BTCPayServer.Payments; @@ -26,10 +23,8 @@ using BTCPayServer.Services; using BTCPayServer.Services.Invoices; using BTCPayServer.Services.Stores; using BTCPayServer.Services.Wallets; -using BTCPayServer.Tests.Logging; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; -using Microsoft.CodeAnalysis.Operations; using Microsoft.EntityFrameworkCore; using NBitcoin; using NBitcoin.DataEncoders; diff --git a/BTCPayServer.Tests/UnitTest1.cs b/BTCPayServer.Tests/UnitTest1.cs index 3c924a9dd..6fbe898be 100644 --- a/BTCPayServer.Tests/UnitTest1.cs +++ b/BTCPayServer.Tests/UnitTest1.cs @@ -38,10 +38,8 @@ using BTCPayServer.Payments; using BTCPayServer.Payments.Bitcoin; using BTCPayServer.Payments.Lightning; using BTCPayServer.Payments.PayJoin.Sender; -using BTCPayServer.Plugins.PayButton; using BTCPayServer.Plugins.PointOfSale; using BTCPayServer.Plugins.PointOfSale.Controllers; -using BTCPayServer.Rating; using BTCPayServer.Security.Bitpay; using BTCPayServer.Security.Greenfield; using BTCPayServer.Services; @@ -70,7 +68,6 @@ using NBXplorer.Models; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Newtonsoft.Json.Schema; -using Npgsql; using Xunit; using Xunit.Abstractions; using Xunit.Sdk; diff --git a/BTCPayServer/Controllers/BitpayRateController.cs b/BTCPayServer/Controllers/BitpayRateController.cs index 0b5ffb871..97bc98eeb 100644 --- a/BTCPayServer/Controllers/BitpayRateController.cs +++ b/BTCPayServer/Controllers/BitpayRateController.cs @@ -10,10 +10,8 @@ using BTCPayServer.Data; using BTCPayServer.Filters; using BTCPayServer.Models; using BTCPayServer.Payments; -using BTCPayServer.Payments.Bitcoin; using BTCPayServer.Rating; using BTCPayServer.Security; -using BTCPayServer.Security.Bitpay; using BTCPayServer.Services.Invoices; using BTCPayServer.Services.Rates; using BTCPayServer.Services.Stores; diff --git a/BTCPayServer/Controllers/GreenField/GreenfieldApiKeysController.cs b/BTCPayServer/Controllers/GreenField/GreenfieldApiKeysController.cs index c6e2f80be..fc75d3938 100644 --- a/BTCPayServer/Controllers/GreenField/GreenfieldApiKeysController.cs +++ b/BTCPayServer/Controllers/GreenField/GreenfieldApiKeysController.cs @@ -5,13 +5,11 @@ using BTCPayServer.Abstractions.Extensions; using BTCPayServer.Client; using BTCPayServer.Client.Models; using BTCPayServer.Data; -using BTCPayServer.Security; using BTCPayServer.Security.Greenfield; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; -using Microsoft.EntityFrameworkCore; using NBitcoin; using NBitcoin.DataEncoders; diff --git a/BTCPayServer/Controllers/GreenField/GreenfieldLightningNodeApiController.cs b/BTCPayServer/Controllers/GreenField/GreenfieldLightningNodeApiController.cs index af08a92e0..2a48e809b 100644 --- a/BTCPayServer/Controllers/GreenField/GreenfieldLightningNodeApiController.cs +++ b/BTCPayServer/Controllers/GreenField/GreenfieldLightningNodeApiController.cs @@ -11,7 +11,6 @@ using BTCPayServer.Payments.Bitcoin; using BTCPayServer.Security; using BTCPayServer.Services; using BTCPayServer.Services.Invoices; -using BTCPayServer.Services.Wallets; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; diff --git a/BTCPayServer/Controllers/GreenField/GreenfieldPaymentRequestsController.cs b/BTCPayServer/Controllers/GreenField/GreenfieldPaymentRequestsController.cs index 2c649ce9b..2f9fe9e8c 100644 --- a/BTCPayServer/Controllers/GreenField/GreenfieldPaymentRequestsController.cs +++ b/BTCPayServer/Controllers/GreenField/GreenfieldPaymentRequestsController.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Reflection.Metadata; using System.Threading; using System.Threading.Tasks; using BTCPayServer.Abstractions.Constants; @@ -10,7 +9,6 @@ using BTCPayServer.Client; using BTCPayServer.Client.Models; using BTCPayServer.Data; using BTCPayServer.PaymentRequest; -using BTCPayServer.Security; using BTCPayServer.Services.Invoices; using BTCPayServer.Services.PaymentRequests; using BTCPayServer.Services.Rates; diff --git a/BTCPayServer/Controllers/GreenField/GreenfieldPayoutProcessorsController.cs b/BTCPayServer/Controllers/GreenField/GreenfieldPayoutProcessorsController.cs index e37ae7faf..594a70615 100644 --- a/BTCPayServer/Controllers/GreenField/GreenfieldPayoutProcessorsController.cs +++ b/BTCPayServer/Controllers/GreenField/GreenfieldPayoutProcessorsController.cs @@ -1,18 +1,12 @@ #nullable enable using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; using BTCPayServer.Abstractions.Constants; -using BTCPayServer.Client; -using BTCPayServer.Client.Models; -using BTCPayServer.Data; using BTCPayServer.PayoutProcessors; -using BTCPayServer.Security; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.Mvc; using PayoutProcessorData = BTCPayServer.Client.Models.PayoutProcessorData; -using StoreData = BTCPayServer.Data.StoreData; namespace BTCPayServer.Controllers.Greenfield { diff --git a/BTCPayServer/Controllers/GreenField/GreenfieldPullPaymentController.cs b/BTCPayServer/Controllers/GreenField/GreenfieldPullPaymentController.cs index 1472eff52..04232d320 100644 --- a/BTCPayServer/Controllers/GreenField/GreenfieldPullPaymentController.cs +++ b/BTCPayServer/Controllers/GreenField/GreenfieldPullPaymentController.cs @@ -1,9 +1,5 @@ #nullable enable using System; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.Diagnostics.CodeAnalysis; -using System.IO.IsolatedStorage; using System.Linq; using System.Text.RegularExpressions; using System.Threading; @@ -15,7 +11,6 @@ using BTCPayServer.Client.Models; using BTCPayServer.Data; using BTCPayServer.HostedServices; using BTCPayServer.NTag424; -using BTCPayServer.Payments; using BTCPayServer.Payouts; using BTCPayServer.Security; using BTCPayServer.Services; @@ -25,9 +20,7 @@ using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Routing; using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Logging; using NBitcoin.DataEncoders; -using Newtonsoft.Json; using Newtonsoft.Json.Linq; using MarkPayoutRequest = BTCPayServer.HostedServices.MarkPayoutRequest; diff --git a/BTCPayServer/Controllers/GreenField/GreenfieldReportsController.cs b/BTCPayServer/Controllers/GreenField/GreenfieldReportsController.cs index 38fd4d14c..0fd8384b9 100644 --- a/BTCPayServer/Controllers/GreenField/GreenfieldReportsController.cs +++ b/BTCPayServer/Controllers/GreenField/GreenfieldReportsController.cs @@ -7,13 +7,13 @@ using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json.Linq; using BTCPayServer.Data; using Microsoft.AspNetCore.Authorization; -using BTCPayServer.Abstractions.Constants; -using BTCPayServer.Client; using BTCPayServer.Abstractions.Extensions; +using BTCPayServer.Client; using BTCPayServer.Client.Models; using BTCPayServer.Services; using System.Linq; using System.Threading; +using BTCPayServer.Abstractions.Constants; namespace BTCPayServer.Controllers.GreenField; diff --git a/BTCPayServer/Controllers/GreenField/GreenfieldServerInfoController.cs b/BTCPayServer/Controllers/GreenField/GreenfieldServerInfoController.cs index 1e3bb8391..762bd8ad1 100644 --- a/BTCPayServer/Controllers/GreenField/GreenfieldServerInfoController.cs +++ b/BTCPayServer/Controllers/GreenField/GreenfieldServerInfoController.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; using BTCPayServer.Abstractions.Constants; using BTCPayServer.Abstractions.Contracts; using BTCPayServer.Client.Models; diff --git a/BTCPayServer/Controllers/GreenField/GreenfieldStoreAutomatedLightningPayoutProcessorsController.cs b/BTCPayServer/Controllers/GreenField/GreenfieldStoreAutomatedLightningPayoutProcessorsController.cs index 393de97e0..af7a12d44 100644 --- a/BTCPayServer/Controllers/GreenField/GreenfieldStoreAutomatedLightningPayoutProcessorsController.cs +++ b/BTCPayServer/Controllers/GreenField/GreenfieldStoreAutomatedLightningPayoutProcessorsController.cs @@ -6,11 +6,9 @@ using BTCPayServer.Abstractions.Extensions; using BTCPayServer.Client; using BTCPayServer.Client.Models; using BTCPayServer.Data; -using BTCPayServer.Payments; using BTCPayServer.PayoutProcessors; using BTCPayServer.PayoutProcessors.Lightning; using BTCPayServer.Payouts; -using BTCPayServer.Services.Invoices; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.Mvc; diff --git a/BTCPayServer/Controllers/GreenField/GreenfieldStoreAutomatedOnChainPayoutProcessorsController.cs b/BTCPayServer/Controllers/GreenField/GreenfieldStoreAutomatedOnChainPayoutProcessorsController.cs index 2298e8a5c..55b7c218c 100644 --- a/BTCPayServer/Controllers/GreenField/GreenfieldStoreAutomatedOnChainPayoutProcessorsController.cs +++ b/BTCPayServer/Controllers/GreenField/GreenfieldStoreAutomatedOnChainPayoutProcessorsController.cs @@ -1,5 +1,4 @@ #nullable enable -using System; using System.Linq; using System.Threading.Tasks; using BTCPayServer.Abstractions.Constants; @@ -7,11 +6,9 @@ using BTCPayServer.Abstractions.Extensions; using BTCPayServer.Client; using BTCPayServer.Client.Models; using BTCPayServer.Data; -using BTCPayServer.Payments; using BTCPayServer.PayoutProcessors; using BTCPayServer.PayoutProcessors.OnChain; using BTCPayServer.Payouts; -using BTCPayServer.Services.Invoices; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.Mvc; diff --git a/BTCPayServer/Controllers/GreenField/GreenfieldStoreEmailController.cs b/BTCPayServer/Controllers/GreenField/GreenfieldStoreEmailController.cs index 666a2130a..663888ec6 100644 --- a/BTCPayServer/Controllers/GreenField/GreenfieldStoreEmailController.cs +++ b/BTCPayServer/Controllers/GreenField/GreenfieldStoreEmailController.cs @@ -7,11 +7,9 @@ using BTCPayServer.Client.Models; using BTCPayServer.Data; using BTCPayServer.Services.Mails; using BTCPayServer.Services.Stores; -using BTCPayServer.Validation; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.Mvc; -using MimeKit; namespace BTCPayServer.Controllers.GreenField { diff --git a/BTCPayServer/Controllers/GreenField/GreenfieldStoreOnChainPaymentMethodsController.WalletGeneration.cs b/BTCPayServer/Controllers/GreenField/GreenfieldStoreOnChainPaymentMethodsController.WalletGeneration.cs index 2b12b8be1..743583c14 100644 --- a/BTCPayServer/Controllers/GreenField/GreenfieldStoreOnChainPaymentMethodsController.WalletGeneration.cs +++ b/BTCPayServer/Controllers/GreenField/GreenfieldStoreOnChainPaymentMethodsController.WalletGeneration.cs @@ -3,7 +3,6 @@ using System.Threading.Tasks; using BTCPayServer.Abstractions.Constants; using BTCPayServer.Abstractions.Extensions; using BTCPayServer.Client; -using BTCPayServer.Client.Models; using BTCPayServer.Data; using BTCPayServer.Events; using BTCPayServer.ModelBinders; diff --git a/BTCPayServer/Controllers/GreenField/GreenfieldStoreOnChainPaymentMethodsController.cs b/BTCPayServer/Controllers/GreenField/GreenfieldStoreOnChainPaymentMethodsController.cs index 3cc52d5f0..72eec56ba 100644 --- a/BTCPayServer/Controllers/GreenField/GreenfieldStoreOnChainPaymentMethodsController.cs +++ b/BTCPayServer/Controllers/GreenField/GreenfieldStoreOnChainPaymentMethodsController.cs @@ -1,15 +1,10 @@ -using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -using System.Linq; using System.Threading.Tasks; using BTCPayServer.Abstractions.Constants; -using BTCPayServer.Abstractions.Contracts; using BTCPayServer.Abstractions.Extensions; using BTCPayServer.Client; using BTCPayServer.Client.Models; using BTCPayServer.Data; -using BTCPayServer.Events; -using BTCPayServer.HostedServices; using BTCPayServer.ModelBinders; using BTCPayServer.Payments; using BTCPayServer.Payments.Bitcoin; @@ -20,12 +15,8 @@ using BTCPayServer.Services.Wallets; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.Mvc; -using NBitcoin; using NBXplorer.DerivationStrategy; -using NBXplorer.Models; using Newtonsoft.Json.Linq; -using Org.BouncyCastle.Asn1.X509.Qualified; -using static Org.BouncyCastle.Math.EC.ECCurve; using StoreData = BTCPayServer.Data.StoreData; namespace BTCPayServer.Controllers.Greenfield diff --git a/BTCPayServer/Controllers/GreenField/GreenfieldStorePaymentMethodsController.cs b/BTCPayServer/Controllers/GreenField/GreenfieldStorePaymentMethodsController.cs index cc02455d0..c075fa663 100644 --- a/BTCPayServer/Controllers/GreenField/GreenfieldStorePaymentMethodsController.cs +++ b/BTCPayServer/Controllers/GreenField/GreenfieldStorePaymentMethodsController.cs @@ -1,13 +1,10 @@ #nullable enable -using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using BTCPayServer.Abstractions.Constants; using BTCPayServer.Client; using BTCPayServer.Client.Models; using BTCPayServer.Data; -using BTCPayServer.Payments.Bitcoin; -using BTCPayServer.Security; using BTCPayServer.Services.Invoices; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Cors; diff --git a/BTCPayServer/Controllers/GreenField/GreenfieldStorePayoutProcessorsController.cs b/BTCPayServer/Controllers/GreenField/GreenfieldStorePayoutProcessorsController.cs index be9b0e6e6..ee10ce3ad 100644 --- a/BTCPayServer/Controllers/GreenField/GreenfieldStorePayoutProcessorsController.cs +++ b/BTCPayServer/Controllers/GreenField/GreenfieldStorePayoutProcessorsController.cs @@ -5,7 +5,6 @@ using System.Threading.Tasks; using BTCPayServer.Abstractions.Constants; using BTCPayServer.Client; using BTCPayServer.Client.Models; -using BTCPayServer.Payments; using BTCPayServer.PayoutProcessors; using BTCPayServer.Payouts; using Microsoft.AspNetCore.Authorization; diff --git a/BTCPayServer/Controllers/GreenField/GreenfieldStoreRatesConfigurationController.cs b/BTCPayServer/Controllers/GreenField/GreenfieldStoreRatesConfigurationController.cs index eb1b32011..ece330e2b 100644 --- a/BTCPayServer/Controllers/GreenField/GreenfieldStoreRatesConfigurationController.cs +++ b/BTCPayServer/Controllers/GreenField/GreenfieldStoreRatesConfigurationController.cs @@ -10,7 +10,6 @@ using BTCPayServer.Client; using BTCPayServer.Client.Models; using BTCPayServer.Data; using BTCPayServer.Rating; -using BTCPayServer.Services.Invoices; using BTCPayServer.Services.Rates; using BTCPayServer.Services.Stores; using Microsoft.AspNetCore.Authorization; diff --git a/BTCPayServer/Controllers/GreenField/GreenfieldStoreRatesController.cs b/BTCPayServer/Controllers/GreenField/GreenfieldStoreRatesController.cs index 707c855d6..198de6244 100644 --- a/BTCPayServer/Controllers/GreenField/GreenfieldStoreRatesController.cs +++ b/BTCPayServer/Controllers/GreenField/GreenfieldStoreRatesController.cs @@ -1,5 +1,4 @@ #nullable enable -using System; using System.Collections.Generic; using System.Linq; using System.Threading; @@ -9,7 +8,6 @@ using BTCPayServer.Client; using BTCPayServer.Client.Models; using BTCPayServer.Data; using BTCPayServer.Rating; -using BTCPayServer.Services.Invoices; using BTCPayServer.Services.Rates; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Cors; diff --git a/BTCPayServer/Controllers/GreenField/GreenfieldStoreWebhooksController.cs b/BTCPayServer/Controllers/GreenField/GreenfieldStoreWebhooksController.cs index f5d7f15fa..7d7d793bf 100644 --- a/BTCPayServer/Controllers/GreenField/GreenfieldStoreWebhooksController.cs +++ b/BTCPayServer/Controllers/GreenField/GreenfieldStoreWebhooksController.cs @@ -1,22 +1,15 @@ using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; using System.Threading.Tasks; -using Amazon.Runtime; using BTCPayServer.Abstractions.Constants; using BTCPayServer.Abstractions.Extensions; using BTCPayServer.Client; using BTCPayServer.Client.Models; using BTCPayServer.Data; -using BTCPayServer.HostedServices; using BTCPayServer.HostedServices.Webhooks; -using BTCPayServer.Security; using BTCPayServer.Services.Stores; -using Google.Apis.Auth.OAuth2; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Cors; -using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json.Linq; diff --git a/BTCPayServer/Controllers/GreenField/GreenfieldUsersController.cs b/BTCPayServer/Controllers/GreenField/GreenfieldUsersController.cs index 6097d020b..e8a104c23 100644 --- a/BTCPayServer/Controllers/GreenField/GreenfieldUsersController.cs +++ b/BTCPayServer/Controllers/GreenField/GreenfieldUsersController.cs @@ -3,7 +3,6 @@ using System; using System.Linq; using System.Threading; using System.Threading.Tasks; -using System.Xml.Linq; using BTCPayServer.Abstractions.Constants; using BTCPayServer.Abstractions.Contracts; using BTCPayServer.Abstractions.Extensions; diff --git a/BTCPayServer/Controllers/UIAccountController.cs b/BTCPayServer/Controllers/UIAccountController.cs index 623652b0b..5e43e201a 100644 --- a/BTCPayServer/Controllers/UIAccountController.cs +++ b/BTCPayServer/Controllers/UIAccountController.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Net.Http; diff --git a/BTCPayServer/Controllers/UIAppsController.Dashboard.cs b/BTCPayServer/Controllers/UIAppsController.Dashboard.cs index 3f3d5d9a4..8bb70b742 100644 --- a/BTCPayServer/Controllers/UIAppsController.Dashboard.cs +++ b/BTCPayServer/Controllers/UIAppsController.Dashboard.cs @@ -3,7 +3,6 @@ using System.Threading.Tasks; using BTCPayServer.Abstractions.Constants; using BTCPayServer.Client; using BTCPayServer.Components.AppSales; -using BTCPayServer.Components.AppTopItems; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; diff --git a/BTCPayServer/Controllers/UIInvoiceController.UI.cs b/BTCPayServer/Controllers/UIInvoiceController.UI.cs index d1a369ffc..39d2ef238 100644 --- a/BTCPayServer/Controllers/UIInvoiceController.UI.cs +++ b/BTCPayServer/Controllers/UIInvoiceController.UI.cs @@ -18,7 +18,6 @@ using BTCPayServer.Models.AppViewModels; using BTCPayServer.Models.InvoicingModels; using BTCPayServer.Models.PaymentRequestViewModels; using BTCPayServer.Payments; -using BTCPayServer.Payments.Bitcoin; using BTCPayServer.Payments.Lightning; using BTCPayServer.Payouts; using BTCPayServer.Rating; @@ -1288,50 +1287,6 @@ namespace BTCPayServer.Controllers private string GetUserId() => _UserManager.GetUserId(User)!; - public class PosDataParser - { - public static Dictionary ParsePosData(JToken? posData) - { - var result = new Dictionary(); - if (posData is JObject jobj) - { - foreach (var item in jobj) - { - ParsePosDataItem(item, ref result); - } - } - return result; - } - - static void ParsePosDataItem(KeyValuePair item, ref Dictionary result) - { - switch (item.Value?.Type) - { - case JTokenType.Array: - var items = item.Value.AsEnumerable().ToList(); - var arrayResult = new List(); - for (var i = 0; i < items.Count; i++) - { - arrayResult.Add(items[i] is JObject - ? ParsePosData(items[i]) - : items[i].ToString()); - } - - result.TryAdd(item.Key, arrayResult); - - break; - case JTokenType.Object: - result.TryAdd(item.Key, ParsePosData(item.Value)); - break; - case null: - break; - default: - result.TryAdd(item.Key, item.Value.ToString()); - break; - } - } - } - private SelectList GetPaymentMethodsSelectList(StoreData store) { return new SelectList(store.GetPaymentMethodConfigs(_handlers, true) diff --git a/BTCPayServer/Controllers/UIReportsController.CheatMode.cs b/BTCPayServer/Controllers/UIReportsController.CheatMode.cs index 42abac848..4da2082af 100644 --- a/BTCPayServer/Controllers/UIReportsController.CheatMode.cs +++ b/BTCPayServer/Controllers/UIReportsController.CheatMode.cs @@ -1,26 +1,9 @@ #nullable enable using System; -using Dapper; -using System.Linq; -using System.Threading.Tasks; -using BTCPayServer.Abstractions.Constants; -using BTCPayServer.Client; using BTCPayServer.Client.Models; -using BTCPayServer.Controllers.GreenField; -using BTCPayServer.Data; -using BTCPayServer.Filters; -using BTCPayServer.Models.StoreReportsViewModels; -using BTCPayServer.Models.StoreViewModels; -using BTCPayServer.Services; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Internal; -using System.Threading; using System.Collections.Generic; using Newtonsoft.Json.Linq; using NBitcoin.DataEncoders; -using System.Net; namespace BTCPayServer.Controllers; diff --git a/BTCPayServer/Controllers/UIReportsController.cs b/BTCPayServer/Controllers/UIReportsController.cs index a5a2ffac6..6486fd423 100644 --- a/BTCPayServer/Controllers/UIReportsController.cs +++ b/BTCPayServer/Controllers/UIReportsController.cs @@ -11,8 +11,6 @@ using BTCPayServer.Models.StoreReportsViewModels; using BTCPayServer.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Internal; using System.Threading; using Newtonsoft.Json.Linq; diff --git a/BTCPayServer/Controllers/UIServerController.cs b/BTCPayServer/Controllers/UIServerController.cs index 5e59208db..76cfee14d 100644 --- a/BTCPayServer/Controllers/UIServerController.cs +++ b/BTCPayServer/Controllers/UIServerController.cs @@ -19,7 +19,6 @@ using BTCPayServer.HostedServices; using BTCPayServer.Logging; using BTCPayServer.Models.ServerViewModels; using BTCPayServer.Models.StoreViewModels; -using BTCPayServer.Payments; using BTCPayServer.Services; using BTCPayServer.Services.Apps; using BTCPayServer.Services.Mails; @@ -44,7 +43,7 @@ using AuthenticationSchemes = BTCPayServer.Abstractions.Constants.Authentication namespace BTCPayServer.Controllers { - [Authorize(Policy = BTCPayServer.Client.Policies.CanModifyServerSettings, + [Authorize(Policy = Client.Policies.CanModifyServerSettings, AuthenticationSchemes = AuthenticationSchemes.Cookie)] public partial class UIServerController : Controller { diff --git a/BTCPayServer/Controllers/UIStorePullPaymentsController.PullPayments.cs b/BTCPayServer/Controllers/UIStorePullPaymentsController.PullPayments.cs index 715af8f2e..760fadbeb 100644 --- a/BTCPayServer/Controllers/UIStorePullPaymentsController.PullPayments.cs +++ b/BTCPayServer/Controllers/UIStorePullPaymentsController.PullPayments.cs @@ -11,14 +11,12 @@ using BTCPayServer.Client.Models; using BTCPayServer.Data; using BTCPayServer.HostedServices; using BTCPayServer.Models.WalletViewModels; -using BTCPayServer.Payments; using BTCPayServer.PayoutProcessors; using BTCPayServer.Payouts; using BTCPayServer.Services; using BTCPayServer.Services.Rates; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.ModelBinding; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Localization; diff --git a/BTCPayServer/Controllers/UIStoresController.LightningLike.cs b/BTCPayServer/Controllers/UIStoresController.LightningLike.cs index 8642fbef3..fa6ca9e93 100644 --- a/BTCPayServer/Controllers/UIStoresController.LightningLike.cs +++ b/BTCPayServer/Controllers/UIStoresController.LightningLike.cs @@ -7,7 +7,6 @@ using BTCPayServer.Abstractions.Constants; using BTCPayServer.Abstractions.Extensions; using BTCPayServer.Client; using BTCPayServer.Client.Models; -using BTCPayServer.Components.StoreLightningBalance; using BTCPayServer.Configuration; using BTCPayServer.Data; using BTCPayServer.Lightning; diff --git a/BTCPayServer/Controllers/UIStoresController.Rates.cs b/BTCPayServer/Controllers/UIStoresController.Rates.cs index f99fb87ba..ab2372b89 100644 --- a/BTCPayServer/Controllers/UIStoresController.Rates.cs +++ b/BTCPayServer/Controllers/UIStoresController.Rates.cs @@ -14,7 +14,6 @@ using BTCPayServer.Rating; using BTCPayServer.Services.Rates; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using static BTCPayServer.Lightning.Eclair.Models.ChannelResponse; namespace BTCPayServer.Controllers; diff --git a/BTCPayServer/Controllers/UIVaultController.cs b/BTCPayServer/Controllers/UIVaultController.cs index a39839a69..1d65c8ffd 100644 --- a/BTCPayServer/Controllers/UIVaultController.cs +++ b/BTCPayServer/Controllers/UIVaultController.cs @@ -13,7 +13,6 @@ using BTCPayServer.Payments; using BTCPayServer.Payments.Bitcoin; using BTCPayServer.Services.Invoices; using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using NBitcoin; using NBXplorer.DerivationStrategy; diff --git a/BTCPayServer/Controllers/UIWalletsController.PSBT.cs b/BTCPayServer/Controllers/UIWalletsController.PSBT.cs index f5405d172..d1d868c1b 100644 --- a/BTCPayServer/Controllers/UIWalletsController.PSBT.cs +++ b/BTCPayServer/Controllers/UIWalletsController.PSBT.cs @@ -8,7 +8,6 @@ using BTCPayServer.Abstractions.Extensions; using BTCPayServer.Abstractions.Models; using BTCPayServer.BIP78.Sender; using BTCPayServer.Data; -using BTCPayServer.HostedServices; using BTCPayServer.ModelBinders; using BTCPayServer.Models; using BTCPayServer.Models.WalletViewModels; diff --git a/BTCPayServer/Data/Payouts/LightningLike/UILightningLikePayoutController.cs b/BTCPayServer/Data/Payouts/LightningLike/UILightningLikePayoutController.cs index 90d24d194..a8e5b9cd7 100644 --- a/BTCPayServer/Data/Payouts/LightningLike/UILightningLikePayoutController.cs +++ b/BTCPayServer/Data/Payouts/LightningLike/UILightningLikePayoutController.cs @@ -7,10 +7,7 @@ using BTCPayServer.Abstractions.Constants; using BTCPayServer.Client; using BTCPayServer.Client.Models; using BTCPayServer.Configuration; -using BTCPayServer.HostedServices; -using BTCPayServer.Lightning; using BTCPayServer.Payments; -using BTCPayServer.Payments.Bitcoin; using BTCPayServer.Payments.Lightning; using BTCPayServer.PayoutProcessors.Lightning; using BTCPayServer.Payouts; @@ -18,13 +15,11 @@ using BTCPayServer.Security; using BTCPayServer.Services; using BTCPayServer.Services.Invoices; using BTCPayServer.Services.Stores; -using LNURL; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Options; -using NBitcoin; namespace BTCPayServer.Data.Payouts.LightningLike { diff --git a/BTCPayServer/Extensions/AuthorizationExtensions.cs b/BTCPayServer/Extensions/AuthorizationExtensions.cs index b3ac9108e..a1eb4a8ae 100644 --- a/BTCPayServer/Extensions/AuthorizationExtensions.cs +++ b/BTCPayServer/Extensions/AuthorizationExtensions.cs @@ -3,10 +3,8 @@ using System.Threading.Tasks; using BTCPayServer.Abstractions.Constants; using BTCPayServer.Client; using BTCPayServer.Security; -using BTCPayServer.Security.Bitpay; using BTCPayServer.Security.Greenfield; using BTCPayServer.Services; -using CsvHelper.Configuration.Attributes; using Microsoft.AspNetCore.Authorization; namespace BTCPayServer diff --git a/BTCPayServer/Extensions/StoreExtensions.cs b/BTCPayServer/Extensions/StoreExtensions.cs index e191c21ce..4ece38876 100644 --- a/BTCPayServer/Extensions/StoreExtensions.cs +++ b/BTCPayServer/Extensions/StoreExtensions.cs @@ -1,9 +1,7 @@ #nullable enable -using System.Collections.Generic; using System.Linq; using BTCPayServer.Client; using BTCPayServer.Data; -using BTCPayServer.Payments; using BTCPayServer.Services.Invoices; namespace BTCPayServer diff --git a/BTCPayServer/Fido2/UIFido2Controller.cs b/BTCPayServer/Fido2/UIFido2Controller.cs index d6c0b5190..876208056 100644 --- a/BTCPayServer/Fido2/UIFido2Controller.cs +++ b/BTCPayServer/Fido2/UIFido2Controller.cs @@ -5,13 +5,10 @@ using BTCPayServer.Abstractions.Models; using BTCPayServer.Client; using BTCPayServer.Data; using BTCPayServer.Fido2.Models; -using BTCPayServer.Models; -using Fido2NetLib; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Localization; -using Newtonsoft.Json.Linq; namespace BTCPayServer.Fido2 { diff --git a/BTCPayServer/Forms/UIFormsController.cs b/BTCPayServer/Forms/UIFormsController.cs index b94270192..6b5b719a4 100644 --- a/BTCPayServer/Forms/UIFormsController.cs +++ b/BTCPayServer/Forms/UIFormsController.cs @@ -1,7 +1,5 @@ #nullable enable using System; -using System.Globalization; -using System.Linq; using System.Threading.Tasks; using BTCPayServer.Abstractions.Constants; using BTCPayServer.Abstractions.Extensions; @@ -17,10 +15,8 @@ using BTCPayServer.Models; using BTCPayServer.Services; using BTCPayServer.Services.Stores; using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Localization; -using Newtonsoft.Json.Linq; namespace BTCPayServer.Forms; diff --git a/BTCPayServer/HostedServices/AppInventoryUpdaterHostedService.cs b/BTCPayServer/HostedServices/AppInventoryUpdaterHostedService.cs index 18f9a0053..2488f68ef 100644 --- a/BTCPayServer/HostedServices/AppInventoryUpdaterHostedService.cs +++ b/BTCPayServer/HostedServices/AppInventoryUpdaterHostedService.cs @@ -1,13 +1,10 @@ -using System; -using System.Collections; using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; +using BTCPayServer.Client.Models; using BTCPayServer.Events; using BTCPayServer.Logging; -using BTCPayServer.Plugins.Crowdfund; -using BTCPayServer.Plugins.PointOfSale; using BTCPayServer.Services.Apps; namespace BTCPayServer.HostedServices @@ -32,7 +29,7 @@ namespace BTCPayServer.HostedServices { if (evt is InvoiceEvent invoiceEvent) { - List cartItems = null; + List cartItems = null; int deduct; switch (invoiceEvent.Name) { @@ -52,10 +49,10 @@ namespace BTCPayServer.HostedServices { var appIds = AppService.GetAppInternalTags(invoiceEvent.Invoice); - var items = cartItems?.ToList() ?? new List(); + var items = cartItems?.ToList() ?? new List(); if (!string.IsNullOrEmpty(invoiceEvent.Invoice.Metadata.ItemCode)) { - items.Add(new PosCartItem + items.Add(new AppCartItem { Id = invoiceEvent.Invoice.Metadata.ItemCode, Count = 1, diff --git a/BTCPayServer/PayoutProcessors/Lightning/UILightningAutomatedPayoutProcessorsController.cs b/BTCPayServer/PayoutProcessors/Lightning/UILightningAutomatedPayoutProcessorsController.cs index 6a5109b13..82d176f5b 100644 --- a/BTCPayServer/PayoutProcessors/Lightning/UILightningAutomatedPayoutProcessorsController.cs +++ b/BTCPayServer/PayoutProcessors/Lightning/UILightningAutomatedPayoutProcessorsController.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Threading.Tasks; @@ -8,10 +7,7 @@ using BTCPayServer.Abstractions.Extensions; using BTCPayServer.Abstractions.Models; using BTCPayServer.Client; using BTCPayServer.Data; -using BTCPayServer.Payments; -using BTCPayServer.PayoutProcessors.OnChain; using BTCPayServer.Payouts; -using BTCPayServer.Services.Invoices; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Localization; diff --git a/BTCPayServer/PayoutProcessors/OnChain/UIOnChainAutomatedPayoutProcessorsController.cs b/BTCPayServer/PayoutProcessors/OnChain/UIOnChainAutomatedPayoutProcessorsController.cs index f37e78907..93906ed17 100644 --- a/BTCPayServer/PayoutProcessors/OnChain/UIOnChainAutomatedPayoutProcessorsController.cs +++ b/BTCPayServer/PayoutProcessors/OnChain/UIOnChainAutomatedPayoutProcessorsController.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Threading.Tasks; @@ -8,7 +7,6 @@ using BTCPayServer.Abstractions.Extensions; using BTCPayServer.Abstractions.Models; using BTCPayServer.Client; using BTCPayServer.Data; -using BTCPayServer.Payments; using BTCPayServer.Payouts; using BTCPayServer.Services.Invoices; using Microsoft.AspNetCore.Authorization; diff --git a/BTCPayServer/PayoutProcessors/UIPayoutProcessorsController.cs b/BTCPayServer/PayoutProcessors/UIPayoutProcessorsController.cs index 7ea21b85c..87010ece7 100644 --- a/BTCPayServer/PayoutProcessors/UIPayoutProcessorsController.cs +++ b/BTCPayServer/PayoutProcessors/UIPayoutProcessorsController.cs @@ -6,7 +6,6 @@ using BTCPayServer.Abstractions.Extensions; using BTCPayServer.Abstractions.Models; using BTCPayServer.Client; using BTCPayServer.Data; -using BTCPayServer.Payments; using BTCPayServer.Payouts; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; diff --git a/BTCPayServer/Plugins/PointOfSale/Controllers/UIPointOfSaleController.cs b/BTCPayServer/Plugins/PointOfSale/Controllers/UIPointOfSaleController.cs index 2e02a6d22..939c909f7 100644 --- a/BTCPayServer/Plugins/PointOfSale/Controllers/UIPointOfSaleController.cs +++ b/BTCPayServer/Plugins/PointOfSale/Controllers/UIPointOfSaleController.cs @@ -177,7 +177,7 @@ namespace BTCPayServer.Plugins.PointOfSale.Controllers decimal? price; Dictionary paymentMethods = null; AppItem choice = null; - List cartItems = null; + List cartItems = null; AppItem[] choices = null; if (!string.IsNullOrEmpty(choiceKey)) { @@ -361,7 +361,7 @@ namespace BTCPayServer.Plugins.PointOfSale.Controllers .Where(item => posCartItems.Any(cartItem => cartItem.Id == item.Id)) .ToDictionary(item => item.Id); var cartData = new JObject(); - foreach (PosCartItem cartItem in posCartItems) + foreach (AppCartItem cartItem in posCartItems) { if (!selectedChoices.TryGetValue(cartItem.Id, out var selectedChoice)) continue; var singlePrice = _displayFormatter.Currency(cartItem.Price, settings.Currency, DisplayFormatter.CurrencyFormat.Symbol); diff --git a/BTCPayServer/Roles.cs b/BTCPayServer/Roles.cs index f76bf18ee..e0c94a3cb 100644 --- a/BTCPayServer/Roles.cs +++ b/BTCPayServer/Roles.cs @@ -2,14 +2,13 @@ using System; using System.Collections.Generic; using System.Linq; -namespace BTCPayServer +namespace BTCPayServer; + +public class Roles { - public class Roles + public const string ServerAdmin = "ServerAdmin"; + public static bool HasServerAdmin(IList roles) { - public const string ServerAdmin = "ServerAdmin"; - public static bool HasServerAdmin(IList roles) - { - return roles.Contains(Roles.ServerAdmin, StringComparer.Ordinal); - } + return roles.Contains(ServerAdmin, StringComparer.Ordinal); } } diff --git a/BTCPayServer/Security/CookieAuthorizationHandler.cs b/BTCPayServer/Security/CookieAuthorizationHandler.cs index 8f6ce4edd..3ed69b96a 100644 --- a/BTCPayServer/Security/CookieAuthorizationHandler.cs +++ b/BTCPayServer/Security/CookieAuthorizationHandler.cs @@ -1,5 +1,3 @@ -using System; -using System.Collections.Generic; using System.Threading.Tasks; using BTCPayServer.Abstractions.Constants; using BTCPayServer.Abstractions.Contracts; diff --git a/BTCPayServer/Services/Apps/AppService.cs b/BTCPayServer/Services/Apps/AppService.cs index 755c3170f..71640e37c 100644 --- a/BTCPayServer/Services/Apps/AppService.cs +++ b/BTCPayServer/Services/Apps/AppService.cs @@ -478,7 +478,7 @@ retry: } #nullable enable - public static bool TryParsePosCartItems(JObject? posData, [MaybeNullWhen(false)] out List cartItems) + public static bool TryParsePosCartItems(JObject? posData, [MaybeNullWhen(false)] out List cartItems) { cartItems = null; if (posData is null) @@ -487,12 +487,13 @@ retry: return false; try { - cartItems = new List(); + cartItems = []; foreach (var o in cartObject.OfType()) { var id = o.GetValue("id", StringComparison.InvariantCulture)?.ToString(); if (id == null) continue; + var title = o.GetValue("title", StringComparison.InvariantCulture)?.ToString(); var countStr = o.GetValue("count", StringComparison.InvariantCulture)?.ToString() ?? string.Empty; var price = o.GetValue("price") switch { @@ -503,7 +504,7 @@ retry: }; if (int.TryParse(countStr, out var count)) { - cartItems.Add(new PosCartItem { Id = id, Count = count, Price = price }); + cartItems.Add(new AppCartItem { Id = id, Title = title, Count = count, Price = price }); } } return true; @@ -532,13 +533,5 @@ retry: var appType = GetAppType(app.AppType); return await appType?.ViewLink(app)!; } -#nullable restore - } - - public class PosCartItem - { - public string Id { get; set; } - public int Count { get; set; } - public decimal Price { get; set; } } } diff --git a/BTCPayServer/Services/ServerSettings.cs b/BTCPayServer/Services/ServerSettings.cs index 9ca61a539..4afe2f1bc 100644 --- a/BTCPayServer/Services/ServerSettings.cs +++ b/BTCPayServer/Services/ServerSettings.cs @@ -1,6 +1,4 @@ using System.ComponentModel.DataAnnotations; -using Microsoft.AspNetCore.Http; -using Newtonsoft.Json; namespace BTCPayServer.Services;