From 376067324b4a2368b4074640f6a9cb57c8bf68bd Mon Sep 17 00:00:00 2001 From: Nicolas Dorier Date: Thu, 18 Jan 2024 09:47:39 +0900 Subject: [PATCH] Remove unused variables (#5669) --- BTCPayServer.Common/Logging/ConsoleLogger.cs | 1 - .../BackgroundFetcherRateProvider.cs | 2 +- .../Providers/KrakenExchangeRateProvider.cs | 1 - BTCPayServer.Rating/Services/RateFetcher.cs | 1 - BTCPayServer.Tests/FastTests.cs | 9 +--- BTCPayServer.Tests/GreenfieldAPITests.cs | 19 ++++---- BTCPayServer.Tests/PSBTTests.cs | 2 +- BTCPayServer.Tests/PayJoinTests.cs | 29 +++++------- BTCPayServer.Tests/SeleniumTests.cs | 4 +- BTCPayServer.Tests/TestAccount.cs | 7 ++- BTCPayServer.Tests/ThirdPartyTests.cs | 1 - BTCPayServer.Tests/UnitTest1.cs | 16 +++---- BTCPayServer.Tests/UtilitiesTests.cs | 2 +- BTCPayServer/Components/AppSales/AppSales.cs | 2 +- ...ymentMethodsController.WalletGeneration.cs | 2 +- ...GreenfieldStoreOnChainWalletsController.cs | 6 +-- .../GreenfieldStoreWebhooksController.cs | 2 +- .../GreenField/GreenfieldStoresController.cs | 2 +- .../Controllers/UIAccountController.cs | 2 +- .../UICustodianAccountsController.cs | 6 +-- .../Controllers/UIInvoiceController.cs | 1 - .../Controllers/UIServerController.cs | 46 ++++++++----------- .../Controllers/UIStoresController.Onchain.cs | 4 +- .../Controllers/UIStoresController.cs | 6 +-- .../Controllers/UIWalletsController.cs | 2 - BTCPayServer/Extensions.cs | 4 +- BTCPayServer/Hosting/MigrationStartupTask.cs | 3 -- BTCPayServer/Hosting/Startup.cs | 2 +- .../Hosting/ToPostgresMigrationStartupTask.cs | 1 - .../PaymentRequest/PaymentRequestHub.cs | 2 +- .../Payments/Bitcoin/NBXplorerListener.cs | 1 - .../LNURLPay/LNURLPayPaymentHandler.cs | 3 +- .../Payments/Lightning/LightningListener.cs | 2 +- .../UIPayoutProcessorsController.cs | 3 -- .../Plugins/Altcoins/AltcoinsPlugin.cs | 1 - BTCPayServer/Plugins/Bitcoin/BitcoinPlugin.cs | 1 - .../Plugins/Shopify/ShopifyApiClient.cs | 2 +- .../Services/Invoices/InvoiceRepository.cs | 3 -- .../Views/Shared/CreateOrEditRole.cshtml | 1 - 39 files changed, 78 insertions(+), 126 deletions(-) diff --git a/BTCPayServer.Common/Logging/ConsoleLogger.cs b/BTCPayServer.Common/Logging/ConsoleLogger.cs index ece125968..47c4ee4ef 100644 --- a/BTCPayServer.Common/Logging/ConsoleLogger.cs +++ b/BTCPayServer.Common/Logging/ConsoleLogger.cs @@ -174,7 +174,6 @@ namespace BTCPayServer.Logging logLevelColors = GetLogLevelConsoleColors(logLevel); logLevelString = GetLogLevelString(logLevel); // category and event id - var lenBefore = logBuilder.ToString().Length; logBuilder.Append(_loglevelPadding); logBuilder.Append(logName); logBuilder.Append(": "); diff --git a/BTCPayServer.Rating/Providers/BackgroundFetcherRateProvider.cs b/BTCPayServer.Rating/Providers/BackgroundFetcherRateProvider.cs index 662b0f655..cba9865b2 100644 --- a/BTCPayServer.Rating/Providers/BackgroundFetcherRateProvider.cs +++ b/BTCPayServer.Rating/Providers/BackgroundFetcherRateProvider.cs @@ -110,7 +110,7 @@ namespace BTCPayServer.Services.Rates public void LoadState(BackgroundFetcherState state) { - if (state.LastRequested is DateTimeOffset lastRequested) + if (state.LastRequested is DateTimeOffset) this.LastRequested = state.LastRequested; if (state.LastUpdated is DateTimeOffset updated && state.Rates is List rates) { diff --git a/BTCPayServer.Rating/Providers/KrakenExchangeRateProvider.cs b/BTCPayServer.Rating/Providers/KrakenExchangeRateProvider.cs index 7ca1bd0bd..274013e48 100644 --- a/BTCPayServer.Rating/Providers/KrakenExchangeRateProvider.cs +++ b/BTCPayServer.Rating/Providers/KrakenExchangeRateProvider.cs @@ -87,7 +87,6 @@ namespace BTCPayServer.Services.Rates var normalizedPairsList = symbols.Where(s => !notFoundSymbols.ContainsKey(s)).Select(s => helper.NormalizeMarketSymbol(s)).ToList(); var csvPairsList = string.Join(",", normalizedPairsList); JToken apiTickers = await MakeJsonRequestAsync("/0/public/Ticker", null, new Dictionary { { "pair", csvPairsList } }, cancellationToken: cancellationToken); - var tickers = new List>(); foreach (string symbol in symbols) { var ticker = ConvertToExchangeTicker(symbol, apiTickers[symbol]); diff --git a/BTCPayServer.Rating/Services/RateFetcher.cs b/BTCPayServer.Rating/Services/RateFetcher.cs index 897b841a8..df57cba08 100644 --- a/BTCPayServer.Rating/Services/RateFetcher.cs +++ b/BTCPayServer.Rating/Services/RateFetcher.cs @@ -45,7 +45,6 @@ namespace BTCPayServer.Services.Rates var fetchingRates = new Dictionary>(); var fetchingExchanges = new Dictionary>(); - var consolidatedRates = new ExchangeRates(); foreach (var i in pairs.Select(p => (Pair: p, RateRule: rules.GetRuleFor(p)))) { diff --git a/BTCPayServer.Tests/FastTests.cs b/BTCPayServer.Tests/FastTests.cs index 8392b7f66..9ec8fb862 100644 --- a/BTCPayServer.Tests/FastTests.cs +++ b/BTCPayServer.Tests/FastTests.cs @@ -649,11 +649,6 @@ namespace BTCPayServer.Tests public void CanAcceptInvoiceWithTolerance() { var networkProvider = CreateNetworkProvider(ChainName.Regtest); - var paymentMethodHandlerDictionary = new PaymentMethodHandlerDictionary(new IPaymentMethodHandler[] - { - new BitcoinLikePaymentHandler(null, networkProvider, null, null, null, null), - new LightningLikePaymentHandler(null, null, networkProvider, null, null, null), - }); var entity = new InvoiceEntity(); entity.Networks = networkProvider; #pragma warning disable CS0618 @@ -1620,7 +1615,7 @@ bc1qfzu57kgu5jthl934f9xrdzzx8mmemx7gn07tf0grnvz504j6kzusu2v0ku { var b = JsonConvert.DeserializeObject("{}"); Assert.Equal(TimeSpan.FromDays(30.0), b.BOLT11Expiration); - var aaa = JsonConvert.SerializeObject(b); + JsonConvert.SerializeObject(b); } [Fact] @@ -2129,7 +2124,7 @@ bc1qfzu57kgu5jthl934f9xrdzzx8mmemx7gn07tf0grnvz504j6kzusu2v0ku [Fact] public void AllPoliciesShowInUI() { - var a = new BitpayRateProvider(new System.Net.Http.HttpClient()).GetRatesAsync(default).Result; + new BitpayRateProvider(new System.Net.Http.HttpClient()).GetRatesAsync(default).GetAwaiter().GetResult(); foreach (var policy in Policies.AllPolicies) { Assert.True(UIManageController.AddApiKeyViewModel.PermissionValueItem.PermissionDescriptions.ContainsKey(policy)); diff --git a/BTCPayServer.Tests/GreenfieldAPITests.cs b/BTCPayServer.Tests/GreenfieldAPITests.cs index 65c415773..52c6bef3f 100644 --- a/BTCPayServer.Tests/GreenfieldAPITests.cs +++ b/BTCPayServer.Tests/GreenfieldAPITests.cs @@ -58,8 +58,8 @@ namespace BTCPayServer.Tests var factory = tester.PayTester.GetService(); Assert.NotNull(factory); var client = await factory.Create(user.UserId, user.StoreId); - var u = await client.GetCurrentUser(); - var s = await client.GetStores(); + await client.GetCurrentUser(); + await client.GetStores(); var store = await client.GetStore(user.StoreId); Assert.NotNull(store); var addr = await client.GetLightningDepositAddress(user.StoreId, "BTC"); @@ -1138,7 +1138,7 @@ namespace BTCPayServer.Tests var approved = await acc.CreateClient(Policies.CanCreatePullPayments); await AssertPermissionError(Policies.CanCreatePullPayments, async () => { - var pullPayment = await nonApproved.CreatePullPayment(acc.StoreId, new CreatePullPaymentRequest() + await nonApproved.CreatePullPayment(acc.StoreId, new CreatePullPaymentRequest() { Amount = 100, Currency = "USD", @@ -1149,7 +1149,7 @@ namespace BTCPayServer.Tests }); await AssertPermissionError(Policies.CanCreatePullPayments, async () => { - var pullPayment = await nonApproved.CreatePayout(acc.StoreId, new CreatePayoutThroughStoreRequest() + await nonApproved.CreatePayout(acc.StoreId, new CreatePayoutThroughStoreRequest() { Amount = 100, PaymentMethod = "BTC", @@ -1158,7 +1158,7 @@ namespace BTCPayServer.Tests }); }); - var pullPayment = await approved.CreatePullPayment(acc.StoreId, new CreatePullPaymentRequest() + await approved.CreatePullPayment(acc.StoreId, new CreatePullPaymentRequest() { Amount = 100, Currency = "USD", @@ -1167,7 +1167,7 @@ namespace BTCPayServer.Tests AutoApproveClaims = true }); - var p = await approved.CreatePayout(acc.StoreId, new CreatePayoutThroughStoreRequest() + await approved.CreatePayout(acc.StoreId, new CreatePayoutThroughStoreRequest() { Amount = 100, PaymentMethod = "BTC", @@ -2537,7 +2537,6 @@ namespace BTCPayServer.Tests Expiry = TimeSpan.FromSeconds(400), PrivateRouteHints = false }); - var chargeInvoice = invoiceData; Assert.NotNull(await client.GetLightningInvoice("BTC", invoiceData.Id)); // check list for internal node @@ -3679,7 +3678,7 @@ namespace BTCPayServer.Tests SavePrivateKeys = true }); - var preApprovedPayoutWithoutPullPayment = await adminClient.CreatePayout(admin.StoreId, new CreatePayoutThroughStoreRequest() + await adminClient.CreatePayout(admin.StoreId, new CreatePayoutThroughStoreRequest() { Amount = 0.0001m, Approved = true, @@ -3911,7 +3910,7 @@ namespace BTCPayServer.Tests beforeHookTcs = new TaskCompletionSource(); afterHookTcs = new TaskCompletionSource(); - var payoutThatShouldNotBeProcessedStraightAway3 = await adminClient.CreatePayout(admin.StoreId, new CreatePayoutThroughStoreRequest() + await adminClient.CreatePayout(admin.StoreId, new CreatePayoutThroughStoreRequest() { Amount = 0.3m, Approved = true, @@ -4331,7 +4330,7 @@ clientBasic.PreviewUpdateStoreRateConfiguration(user.StoreId, new StoreRateConfi await admin.GrantAccessAsync(true); var unauthClient = new BTCPayServerClient(tester.PayTester.ServerUri); - var authClientNoPermissions = await admin.CreateClient(Policies.CanViewInvoices); + await admin.CreateClient(Policies.CanViewInvoices); var adminClient = await admin.CreateClient(Policies.Unrestricted); var managerClient = await admin.CreateClient(Policies.CanManageCustodianAccounts); var withdrawalClient = await admin.CreateClient(Policies.CanWithdrawFromCustodianAccounts); diff --git a/BTCPayServer.Tests/PSBTTests.cs b/BTCPayServer.Tests/PSBTTests.cs index 67c9a2164..10b7693d3 100644 --- a/BTCPayServer.Tests/PSBTTests.cs +++ b/BTCPayServer.Tests/PSBTTests.cs @@ -29,7 +29,7 @@ namespace BTCPayServer.Tests using var s = CreateSeleniumTester(newDb: true); await s.StartAsync(); - var u1 = s.RegisterNewUser(true); + s.RegisterNewUser(true); var hot = s.CreateNewStore(); var seed = s.GenerateWallet(isHotWallet: true); var cold = s.CreateNewStore(); diff --git a/BTCPayServer.Tests/PayJoinTests.cs b/BTCPayServer.Tests/PayJoinTests.cs index 9b889ea03..c6c017062 100644 --- a/BTCPayServer.Tests/PayJoinTests.cs +++ b/BTCPayServer.Tests/PayJoinTests.cs @@ -68,7 +68,7 @@ namespace BTCPayServer.Tests { using var tester = CreateServerTester(); await tester.StartAsync(); - var network = tester.NetworkProvider.GetNetwork("BTC"); + tester.NetworkProvider.GetNetwork("BTC"); var repo = tester.PayTester.GetService(); var outpoint = RandomOutpoint(); @@ -189,10 +189,10 @@ namespace BTCPayServer.Tests using var tester = CreateServerTester(); await tester.StartAsync(); var broadcaster = tester.PayTester.GetService(); - var payjoinRepository = tester.PayTester.GetService(); + tester.PayTester.GetService(); broadcaster.Disable(); var network = tester.NetworkProvider.GetNetwork("BTC"); - var btcPayWallet = tester.PayTester.GetService().GetWallet(network); + tester.PayTester.GetService().GetWallet(network); var cashCow = tester.ExplorerNode; cashCow.Generate(2); // get some money in case @@ -218,7 +218,7 @@ namespace BTCPayServer.Tests receiverUser.GrantAccess(true); receiverUser.RegisterDerivationScheme("BTC", receiverAddressType, true); await receiverUser.ModifyOnchainPaymentSettings(p => p.PayJoinEnabled = true); - var receiverCoin = await receiverUser.ReceiveUTXO(Money.Satoshis(810), network); + await receiverUser.ReceiveUTXO(Money.Satoshis(810), network); string errorCode = receiverAddressType == senderAddressType ? null : "unavailable|any UTXO available"; var invoice = receiverUser.BitPay.CreateInvoice(new Invoice() { Price = 50000, Currency = "SATS", FullNotifications = true }); @@ -236,7 +236,7 @@ namespace BTCPayServer.Tests txBuilder.SendEstimatedFees(new FeeRate(50m)); var psbt = txBuilder.BuildPSBT(false); psbt = await senderUser.Sign(psbt); - var pj = await senderUser.SubmitPayjoin(invoice, psbt, errorCode, false); + await senderUser.SubmitPayjoin(invoice, psbt, errorCode, false); } } } @@ -250,11 +250,11 @@ namespace BTCPayServer.Tests s.RegisterNewUser(true); var receiver = s.CreateNewStore(); s.EnableCheckout(CheckoutType.V1); - var receiverSeed = s.GenerateWallet("BTC", "", true, true, ScriptPubKeyType.Segwit); + s.GenerateWallet("BTC", "", true, true, ScriptPubKeyType.Segwit); var receiverWalletId = new WalletId(receiver.storeId, "BTC"); var sender = s.CreateNewStore(); - var senderSeed = s.GenerateWallet("BTC", "", true, true, ScriptPubKeyType.Segwit); + s.GenerateWallet("BTC", "", true, true, ScriptPubKeyType.Segwit); var senderWalletId = new WalletId(sender.storeId, "BTC"); await s.Server.ExplorerNode.GenerateAsync(1); @@ -305,7 +305,7 @@ namespace BTCPayServer.Tests var cryptoCode = "BTC"; var receiver = s.CreateNewStore(); s.EnableCheckout(CheckoutType.V1); - var receiverSeed = s.GenerateWallet(cryptoCode, "", true, true, format); + s.GenerateWallet(cryptoCode, "", true, true, format); var receiverWalletId = new WalletId(receiver.storeId, cryptoCode); //payjoin is enabled by default. @@ -320,7 +320,7 @@ namespace BTCPayServer.Tests Assert.True(s.Driver.FindElement(By.Id("PayJoinEnabled")).Selected); var sender = s.CreateNewStore(); - var senderSeed = s.GenerateWallet(cryptoCode, "", true, true, format); + s.GenerateWallet(cryptoCode, "", true, true, format); var senderWalletId = new WalletId(sender.storeId, cryptoCode); await s.Server.ExplorerNode.GenerateAsync(1); await s.FundStoreWallet(senderWalletId); @@ -374,7 +374,7 @@ namespace BTCPayServer.Tests s.Driver.FindElement(By.Id("FeeSatoshiPerByte")).Clear(); s.Driver.FindElement(By.Id("FeeSatoshiPerByte")).SendKeys("2"); s.Driver.FindElement(By.Id("SignTransaction")).Click(); - var txId = await s.Server.WaitForEvent(() => + await s.Server.WaitForEvent(() => { s.Driver.FindElement(By.CssSelector("button[value=payjoin]")).Click(); return Task.CompletedTask; @@ -406,7 +406,6 @@ namespace BTCPayServer.Tests await TestUtils.EventuallyAsync(async () => { var invoice = await s.Server.PayTester.GetService().GetInvoice(invoiceId); - var dto = invoice.EntityToDTO(); Assert.Equal(InvoiceStatusLegacy.Paid, invoice.Status); }); s.GoToInvoices(receiver.storeId); @@ -875,7 +874,6 @@ retry: new Invoice() { Price = 0.02m, Currency = "BTC", FullNotifications = true }); cashCow.SendToAddress(BitcoinAddress.Create(invoice.BitcoinAddress, cashCow.Network), Money.Coins(0.06m)); - var receiverWalletId = new WalletId(receiverUser.StoreId, "BTC"); //give the cow some cash await cashCow.GenerateAsync(1); @@ -963,8 +961,6 @@ retry: senderUser.GenerateWalletResponseV.MasterHDKey.Derive(signingKeySettings.GetRootedKeyPath() .KeyPath); - - var n = tester.ExplorerClient.Network.NBitcoinNetwork; var Invoice1Coin1 = tester.ExplorerClient.Network.NBitcoinNetwork.CreateTransactionBuilder() .SetChange(senderChange) .Send(parsedBip21.Address, parsedBip21.Amount) @@ -973,7 +969,7 @@ retry: .SendEstimatedFees(new FeeRate(100m)) .BuildTransaction(true); - var Invoice1Coin2 = tester.ExplorerClient.Network.NBitcoinNetwork.CreateTransactionBuilder() + tester.ExplorerClient.Network.NBitcoinNetwork.CreateTransactionBuilder() .SetChange(senderChange) .Send(parsedBip21.Address, parsedBip21.Amount) .AddCoins(coin2.Coin) @@ -1133,8 +1129,7 @@ retry: var invoice7Coin6Response1Tx = await senderUser.SubmitPayjoin(invoice7, invoice7Coin6Tx, btcPayNetwork); var Invoice7Coin6Response1TxSigned = invoice7Coin6TxBuilder.SignTransaction(invoice7Coin6Response1Tx); - var contributedInputsInvoice7Coin6Response1TxSigned = - Invoice7Coin6Response1TxSigned.Inputs.Single(txin => coin6.OutPoint != txin.PrevOut); + Invoice7Coin6Response1TxSigned.Inputs.Single(txin => coin6.OutPoint != txin.PrevOut); ////var receiverWalletPayJoinState = payJoinStateProvider.Get(receiverWalletId); diff --git a/BTCPayServer.Tests/SeleniumTests.cs b/BTCPayServer.Tests/SeleniumTests.cs index 459f358da..bd641793d 100644 --- a/BTCPayServer.Tests/SeleniumTests.cs +++ b/BTCPayServer.Tests/SeleniumTests.cs @@ -1633,7 +1633,6 @@ namespace BTCPayServer.Tests var mnemonic = s.GenerateWallet(cryptoCode, "", true, true); //lets import and save private keys - var root = mnemonic.DeriveExtKey(); invoiceId = s.CreateInvoice(storeId); invoice = await s.Server.PayTester.InvoiceRepository.GetInvoice(invoiceId); address = invoice.EntityToDTO().Addresses["BTC"]; @@ -2598,7 +2597,7 @@ namespace BTCPayServer.Tests // BOLT11 is also displayed for standard invoice (not LNURL, even if it is available) s.Driver.FindElement(By.Id("copy-tab")).Click(); var bolt11 = s.Driver.FindElement(By.CssSelector("input.checkoutTextbox")).GetAttribute("value"); - var bolt11Parsed = Lightning.BOLT11PaymentRequest.Parse(bolt11, s.Server.ExplorerNode.Network); + Lightning.BOLT11PaymentRequest.Parse(bolt11, s.Server.ExplorerNode.Network); var invoiceId = s.Driver.Url.Split('/').Last(); using (var resp = await s.Server.PayTester.HttpClient.GetAsync("BTC/lnurl/pay/i/" + invoiceId)) { @@ -2809,7 +2808,6 @@ namespace BTCPayServer.Tests } invoices = await repo.GetInvoices(new InvoiceQuery() { StoreId = new[] { s.StoreId } }); Assert.Equal(2, invoices.Length); - var emailSuffix = $"@{s.Server.PayTester.HostName}:{s.Server.PayTester.Port}"; foreach (var i in invoices) { var lightningPaymentMethod = i.GetPaymentMethod(new PaymentMethodId("BTC", PaymentTypes.LNURLPay)); diff --git a/BTCPayServer.Tests/TestAccount.cs b/BTCPayServer.Tests/TestAccount.cs index 98555bff0..b8b0ae187 100644 --- a/BTCPayServer.Tests/TestAccount.cs +++ b/BTCPayServer.Tests/TestAccount.cs @@ -73,7 +73,7 @@ namespace BTCPayServer.Tests public async Task CreateClient(params string[] permissions) { var manageController = parent.PayTester.GetController(UserId, StoreId, IsAdmin); - var x = Assert.IsType(await manageController.AddApiKey( + Assert.IsType(await manageController.AddApiKey( new UIManageController.AddApiKeyViewModel() { PermissionValues = permissions.Select(s => @@ -339,7 +339,6 @@ namespace BTCPayServer.Tests public async Task GetNewAddress(BTCPayNetwork network) { - var cashCow = parent.ExplorerNode; var btcPayWallet = parent.PayTester.GetService().GetWallet(network); var address = (await btcPayWallet.ReserveAddressAsync(this.DerivationScheme)).Address; return address; @@ -347,7 +346,7 @@ namespace BTCPayServer.Tests public async Task Sign(PSBT psbt) { - var btcPayWallet = parent.PayTester.GetService() + parent.PayTester.GetService() .GetWallet(psbt.Network.NetworkSet.CryptoCode); var explorerClient = parent.PayTester.GetService() .GetExplorerClient(psbt.Network.NetworkSet.CryptoCode); @@ -444,7 +443,7 @@ namespace BTCPayServer.Tests var parsedBip21 = new BitcoinUrlBuilder( invoice.CryptoInfo.First(c => c.CryptoCode == network.NetworkSet.CryptoCode).PaymentUrls.BIP21, network); - if (!parsedBip21.TryGetPayjoinEndpoint(out var endpoint)) + if (!parsedBip21.TryGetPayjoinEndpoint(out _)) return null; return parsedBip21; } diff --git a/BTCPayServer.Tests/ThirdPartyTests.cs b/BTCPayServer.Tests/ThirdPartyTests.cs index e711e845f..a98d55435 100644 --- a/BTCPayServer.Tests/ThirdPartyTests.cs +++ b/BTCPayServer.Tests/ThirdPartyTests.cs @@ -278,7 +278,6 @@ retry: } catch (Exception ex) when (ex is MatchesException) { - var details = ex.Message; TestLogs.LogInformation($"FAILED: {url} ({file}) – anchor not found: {uri.Fragment}"); throw; diff --git a/BTCPayServer.Tests/UnitTest1.cs b/BTCPayServer.Tests/UnitTest1.cs index c836946cb..8e1144ad6 100644 --- a/BTCPayServer.Tests/UnitTest1.cs +++ b/BTCPayServer.Tests/UnitTest1.cs @@ -267,7 +267,6 @@ namespace BTCPayServer.Tests } catch (Exception ex) when (ex is MatchesException) { - var details = ex.Message; TestLogs.LogInformation($"FAILED: {url} ({file}) – anchor not found: {uri.Fragment}"); throw; @@ -347,7 +346,7 @@ namespace BTCPayServer.Tests try { - var throwsBitpay404Error = user.BitPay.GetInvoice(invoice.Id + "123"); + user.BitPay.GetInvoice(invoice.Id + "123"); } catch (BitPayException ex) { @@ -885,7 +884,7 @@ namespace BTCPayServer.Tests Assert.Equal("LTC", GetCurrencyPairRateResult.Data.Code); // Should be OK because the request is signed, so we can know the store - var rates = acc.BitPay.GetRates(); + acc.BitPay.GetRates(); HttpClient client = new HttpClient(); // Unauthentified requests should also be ok var response = @@ -1072,7 +1071,7 @@ namespace BTCPayServer.Tests var invoice = await user.BitPay.CreateInvoiceAsync(new Invoice(0.01m, "BTC")); await tester.WaitForEvent(async () => { - var tx = await tester.ExplorerNode.SendToAddressAsync( + await tester.ExplorerNode.SendToAddressAsync( BitcoinAddress.Create(invoice.BitcoinAddress, Network.RegTest), Money.Coins(0.01m)); }); @@ -1457,7 +1456,7 @@ namespace BTCPayServer.Tests // via UI var controller = user.GetController(); - var model = await controller.CreateInvoice(); + await controller.CreateInvoice(); (await controller.CreateInvoice(new CreateInvoiceModel(), default)).AssertType(); invoice = await client.GetInvoice(user.StoreId, controller.CreatedInvoiceId); Assert.Equal("EUR", invoice.Currency); @@ -2139,8 +2138,7 @@ namespace BTCPayServer.Tests user.RegisterDerivationScheme("BTC"); var serverController = user.GetController(); - var vm = Assert.IsType( - Assert.IsType(await serverController.LogsView()).Model); + Assert.IsType(Assert.IsType(await serverController.LogsView()).Model); } [Fact(Timeout = LongRunningTestTimeout)] @@ -2394,7 +2392,7 @@ namespace BTCPayServer.Tests Assert.NotNull(lnMethod.GetExternalLightningUrl()); var url = lnMethod.GetExternalLightningUrl(); - var kv = LightningConnectionStringHelper.ExtractValues(url, out var connType); + LightningConnectionStringHelper.ExtractValues(url, out var connType); Assert.Equal(LightningConnectionType.Charge, connType); var client = Assert.IsType(tester.PayTester.GetService() .Create(url, tester.NetworkProvider.GetNetwork("BTC"))); @@ -2771,7 +2769,7 @@ namespace BTCPayServer.Tests Assert.Equal(fileContent, data); //create a temporary link to file - var tmpLinkGenerate = Assert.IsType(await controller.CreateTemporaryFileUrl(fileId, + Assert.IsType(await controller.CreateTemporaryFileUrl(fileId, new UIServerController.CreateTemporaryFileUrlViewModel { IsDownload = true, diff --git a/BTCPayServer.Tests/UtilitiesTests.cs b/BTCPayServer.Tests/UtilitiesTests.cs index 13f74760e..d668d72ed 100644 --- a/BTCPayServer.Tests/UtilitiesTests.cs +++ b/BTCPayServer.Tests/UtilitiesTests.cs @@ -409,7 +409,7 @@ retry: content.Headers.TryAddWithoutValidation("Content-Type", "application/vnd.api+json;profile=\"bulk\""); message.Content = content; using var response = await Client.SendAsync(message); - var str = await response.Content.ReadAsStringAsync(); + await response.Content.ReadAsStringAsync(); }).ToArray()); } diff --git a/BTCPayServer/Components/AppSales/AppSales.cs b/BTCPayServer/Components/AppSales/AppSales.cs index bfc8a9706..4e0d3dbe5 100644 --- a/BTCPayServer/Components/AppSales/AppSales.cs +++ b/BTCPayServer/Components/AppSales/AppSales.cs @@ -30,7 +30,7 @@ public class AppSales : ViewComponent public async Task InvokeAsync(string appId, string appType) { var type = _appService.GetAppType(appType); - if (type is not IHasSaleStatsAppType salesAppType || type is not AppBaseType appBaseType) + if (type is not IHasSaleStatsAppType || type is not AppBaseType appBaseType) return new HtmlContentViewComponentResult(new StringHtmlContent(string.Empty)); var vm = new AppSalesViewModel { diff --git a/BTCPayServer/Controllers/GreenField/GreenfieldStoreOnChainPaymentMethodsController.WalletGeneration.cs b/BTCPayServer/Controllers/GreenField/GreenfieldStoreOnChainPaymentMethodsController.WalletGeneration.cs index b19010384..de124832a 100644 --- a/BTCPayServer/Controllers/GreenField/GreenfieldStoreOnChainPaymentMethodsController.WalletGeneration.cs +++ b/BTCPayServer/Controllers/GreenField/GreenfieldStoreOnChainPaymentMethodsController.WalletGeneration.cs @@ -23,7 +23,7 @@ namespace BTCPayServer.Controllers.Greenfield GenerateWalletRequest request) { - AssertCryptoCodeWallet(cryptoCode, out var network, out var wallet); + AssertCryptoCodeWallet(cryptoCode, out var network, out _); if (!_walletProvider.IsAvailable(network)) { diff --git a/BTCPayServer/Controllers/GreenField/GreenfieldStoreOnChainWalletsController.cs b/BTCPayServer/Controllers/GreenField/GreenfieldStoreOnChainWalletsController.cs index ea0aa7125..f3e99162e 100644 --- a/BTCPayServer/Controllers/GreenField/GreenfieldStoreOnChainWalletsController.cs +++ b/BTCPayServer/Controllers/GreenField/GreenfieldStoreOnChainWalletsController.cs @@ -117,7 +117,7 @@ namespace BTCPayServer.Controllers.Greenfield public async Task GetOnChainFeeRate(string storeId, string cryptoCode, int? blockTarget = null) { if (IsInvalidWalletRequest(cryptoCode, out var network, - out var derivationScheme, out var actionResult)) + out _, out var actionResult)) return actionResult; var feeRateTarget = blockTarget ?? Store.GetStoreBlob().RecommendedFeeBlockTarget; @@ -164,8 +164,8 @@ namespace BTCPayServer.Controllers.Greenfield [HttpDelete("~/api/v1/stores/{storeId}/payment-methods/onchain/{cryptoCode}/wallet/address")] public async Task UnReserveOnChainWalletReceiveAddress(string storeId, string cryptoCode) { - if (IsInvalidWalletRequest(cryptoCode, out var network, - out var derivationScheme, out var actionResult)) + if (IsInvalidWalletRequest(cryptoCode, out _, + out _, out var actionResult)) return actionResult; var addr = await _walletReceiveService.UnReserveAddress(new WalletId(storeId, cryptoCode)); diff --git a/BTCPayServer/Controllers/GreenField/GreenfieldStoreWebhooksController.cs b/BTCPayServer/Controllers/GreenField/GreenfieldStoreWebhooksController.cs index f5f152f59..3d9387dd7 100644 --- a/BTCPayServer/Controllers/GreenField/GreenfieldStoreWebhooksController.cs +++ b/BTCPayServer/Controllers/GreenField/GreenfieldStoreWebhooksController.cs @@ -78,7 +78,7 @@ namespace BTCPayServer.Controllers.Greenfield private void ValidateWebhookRequest(StoreWebhookBaseData create) { - if (!Uri.TryCreate(create?.Url, UriKind.Absolute, out var uri)) + if (!Uri.TryCreate(create?.Url, UriKind.Absolute, out _)) ModelState.AddModelError(nameof(Url), "Invalid Url"); } diff --git a/BTCPayServer/Controllers/GreenField/GreenfieldStoresController.cs b/BTCPayServer/Controllers/GreenField/GreenfieldStoresController.cs index 8196a34b3..d0ad98343 100644 --- a/BTCPayServer/Controllers/GreenField/GreenfieldStoresController.cs +++ b/BTCPayServer/Controllers/GreenField/GreenfieldStoresController.cs @@ -240,7 +240,7 @@ namespace BTCPayServer.Controllers.Greenfield } if (!string.IsNullOrEmpty(request.DefaultPaymentMethod) && - !PaymentMethodId.TryParse(request.DefaultPaymentMethod, out var defaultPaymentMethodId)) + !PaymentMethodId.TryParse(request.DefaultPaymentMethod, out _)) { ModelState.AddModelError(nameof(request.Name), "DefaultPaymentMethod is invalid"); } diff --git a/BTCPayServer/Controllers/UIAccountController.cs b/BTCPayServer/Controllers/UIAccountController.cs index e6ca2864e..35f30d71b 100644 --- a/BTCPayServer/Controllers/UIAccountController.cs +++ b/BTCPayServer/Controllers/UIAccountController.cs @@ -205,7 +205,7 @@ namespace BTCPayServer.Controllers } else { - var incrementAccessFailedResult = await _userManager.AccessFailedAsync(user); + await _userManager.AccessFailedAsync(user); ModelState.AddModelError(string.Empty, "Invalid login attempt."); return View(model); diff --git a/BTCPayServer/Controllers/UICustodianAccountsController.cs b/BTCPayServer/Controllers/UICustodianAccountsController.cs index d143252bb..b0141fae0 100644 --- a/BTCPayServer/Controllers/UICustodianAccountsController.cs +++ b/BTCPayServer/Controllers/UICustodianAccountsController.cs @@ -391,10 +391,6 @@ namespace BTCPayServer.Controllers return NotFound(); } - var store = GetCurrentStore(); - var storeBlob = BTCPayServer.Data.StoreDataExtensions.GetStoreBlob(store); - var defaultCurrency = storeBlob.DefaultCurrency; - try { var assetBalancesData = @@ -583,7 +579,7 @@ namespace BTCPayServer.Controllers try { - if (custodian is ICanWithdraw withdrawableCustodian) + if (custodian is ICanWithdraw) { var config = custodianAccount.GetBlob(); diff --git a/BTCPayServer/Controllers/UIInvoiceController.cs b/BTCPayServer/Controllers/UIInvoiceController.cs index 9205adce3..df540f91b 100644 --- a/BTCPayServer/Controllers/UIInvoiceController.cs +++ b/BTCPayServer/Controllers/UIInvoiceController.cs @@ -227,7 +227,6 @@ namespace BTCPayServer.Controllers entity.Status = InvoiceStatusLegacy.New; entity.UpdateTotals(); HashSet currencyPairsToFetch = new HashSet(); - var rules = storeBlob.GetRateRules(_NetworkProvider); var excludeFilter = storeBlob.GetExcludedPaymentMethods(); // Here we can compose filters from other origin with PaymentFilter.Any() if (invoicePaymentMethodFilter != null) { diff --git a/BTCPayServer/Controllers/UIServerController.cs b/BTCPayServer/Controllers/UIServerController.cs index 0e6273331..71e39b11e 100644 --- a/BTCPayServer/Controllers/UIServerController.cs +++ b/BTCPayServer/Controllers/UIServerController.cs @@ -168,37 +168,31 @@ namespace BTCPayServer.Controllers return View(vm); } var builder = new UriBuilder(); - using (var client = new HttpClient(new HttpClientHandler() + try { - ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator - })) - { - try - { - builder.Scheme = this.Request.Scheme; - builder.Host = vm.DNSDomain; - var addresses1 = GetAddressAsync(this.Request.Host.Host); - var addresses2 = GetAddressAsync(vm.DNSDomain); - await Task.WhenAll(addresses1, addresses2); + builder.Scheme = this.Request.Scheme; + builder.Host = vm.DNSDomain; + var addresses1 = GetAddressAsync(this.Request.Host.Host); + var addresses2 = GetAddressAsync(vm.DNSDomain); + await Task.WhenAll(addresses1, addresses2); - var addressesSet = addresses1.GetAwaiter().GetResult().Select(c => c.ToString()).ToHashSet(); - var hasCommonAddress = addresses2.GetAwaiter().GetResult().Select(c => c.ToString()).Any(s => addressesSet.Contains(s)); - if (!hasCommonAddress) - { - ModelState.AddModelError(nameof(vm.DNSDomain), $"Invalid host ({vm.DNSDomain} is not pointing to this BTCPay instance)"); - return View(vm); - } - } - catch (Exception ex) + var addressesSet = addresses1.GetAwaiter().GetResult().Select(c => c.ToString()).ToHashSet(); + var hasCommonAddress = addresses2.GetAwaiter().GetResult().Select(c => c.ToString()).Any(s => addressesSet.Contains(s)); + if (!hasCommonAddress) { - var messages = new List(); - messages.Add(ex.Message); - if (ex.InnerException != null) - messages.Add(ex.InnerException.Message); - ModelState.AddModelError(nameof(vm.DNSDomain), $"Invalid domain ({string.Join(", ", messages.ToArray())})"); + ModelState.AddModelError(nameof(vm.DNSDomain), $"Invalid host ({vm.DNSDomain} is not pointing to this BTCPay instance)"); return View(vm); } } + catch (Exception ex) + { + var messages = new List(); + messages.Add(ex.Message); + if (ex.InnerException != null) + messages.Add(ex.InnerException.Message); + ModelState.AddModelError(nameof(vm.DNSDomain), $"Invalid domain ({string.Join(", ", messages.ToArray())})"); + return View(vm); + } var error = await RunSSH(vm, $"changedomain.sh {vm.DNSDomain}"); if (error != null) @@ -685,7 +679,7 @@ namespace BTCPayServer.Controllers [HttpPost] public async Task ServicePost(string serviceName, string cryptoCode) { - if (!_dashBoard.IsFullySynched(cryptoCode, out var unusud)) + if (!_dashBoard.IsFullySynched(cryptoCode, out _)) { TempData[WellKnownTempData.ErrorMessage] = $"{cryptoCode} is not fully synched"; return RedirectToAction(nameof(Services)); diff --git a/BTCPayServer/Controllers/UIStoresController.Onchain.cs b/BTCPayServer/Controllers/UIStoresController.Onchain.cs index 171326a93..fff198c72 100644 --- a/BTCPayServer/Controllers/UIStoresController.Onchain.cs +++ b/BTCPayServer/Controllers/UIStoresController.Onchain.cs @@ -191,7 +191,7 @@ namespace BTCPayServer.Controllers [HttpGet("{storeId}/onchain/{cryptoCode}/generate/{method?}")] public async Task GenerateWallet(WalletSetupViewModel vm) { - var checkResult = IsAvailable(vm.CryptoCode, out var store, out var network); + var checkResult = IsAvailable(vm.CryptoCode, out _, out var network); if (checkResult != null) { return checkResult; @@ -231,7 +231,7 @@ namespace BTCPayServer.Controllers [HttpPost("{storeId}/onchain/{cryptoCode}/generate/{method}")] public async Task GenerateWallet(string storeId, string cryptoCode, WalletSetupMethod method, WalletSetupRequest request) { - var checkResult = IsAvailable(cryptoCode, out var store, out var network); + var checkResult = IsAvailable(cryptoCode, out _, out var network); if (checkResult != null) { return checkResult; diff --git a/BTCPayServer/Controllers/UIStoresController.cs b/BTCPayServer/Controllers/UIStoresController.cs index dbc3fbaab..689894f7b 100644 --- a/BTCPayServer/Controllers/UIStoresController.cs +++ b/BTCPayServer/Controllers/UIStoresController.cs @@ -504,7 +504,7 @@ namespace BTCPayServer.Controllers var methodCriterion = model.PaymentMethodCriteria[index]; if (!string.IsNullOrWhiteSpace(methodCriterion.Value)) { - if (!CurrencyValue.TryParse(methodCriterion.Value, out var value)) + if (!CurrencyValue.TryParse(methodCriterion.Value, out _)) { model.AddModelError(viewModel => viewModel.PaymentMethodCriteria[index].Value, $"{methodCriterion.PaymentMethod}: Invalid format. Make sure to enter a valid amount and currency code. Examples: '5 USD', '0.001 BTC'", this); @@ -674,7 +674,7 @@ namespace BTCPayServer.Controllers }); break; - case LNURLPayPaymentType lnurlPayPaymentType: + case LNURLPayPaymentType: break; case LightningPaymentType _: @@ -1000,7 +1000,7 @@ namespace BTCPayServer.Controllers var store = model.StoreId switch { null => CurrentStore, - string id => await _Repo.FindStore(storeId, userId) + _ => await _Repo.FindStore(storeId, userId) }; if (store == null) return Challenge(AuthenticationSchemes.Cookie); diff --git a/BTCPayServer/Controllers/UIWalletsController.cs b/BTCPayServer/Controllers/UIWalletsController.cs index 644056ce2..8063e8ba7 100644 --- a/BTCPayServer/Controllers/UIWalletsController.cs +++ b/BTCPayServer/Controllers/UIWalletsController.cs @@ -146,7 +146,6 @@ namespace BTCPayServer.Controllers return NotFound(); var txObjId = new WalletObjectId(walletId, WalletObjectData.Types.Tx, transactionId); - var wallet = _walletProvider.GetWallet(paymentMethod.Network); if (addlabel != null) { await WalletRepository.AddWalletObjectLabels(txObjId, addlabel); @@ -414,7 +413,6 @@ namespace BTCPayServer.Controllers await ExplorerClientProvider.GetExplorerClient(walletId.CryptoCode).WaitServerStartedAsync(); await Task.Delay(1000); await using var conn = await factory.OpenConnection(); - var wallet_id = paymentMethod.GetNBXWalletId(); var txIds = sending.Select(s => s.Result.ToString()).ToArray(); await conn.ExecuteAsync( diff --git a/BTCPayServer/Extensions.cs b/BTCPayServer/Extensions.cs index 51a94e404..f60ded16c 100644 --- a/BTCPayServer/Extensions.cs +++ b/BTCPayServer/Extensions.cs @@ -154,7 +154,7 @@ namespace BTCPayServer public static Uri GetServerUri(this ILightningClient client) { - var kv = LightningConnectionStringHelper.ExtractValues(client.ToString(), out var type); + var kv = LightningConnectionStringHelper.ExtractValues(client.ToString(), out _); return !kv.TryGetValue("server", out var server) ? null : new Uri(server, UriKind.Absolute); } @@ -173,7 +173,7 @@ namespace BTCPayServer public static bool IsSafe(this ILightningClient client) { - var kv = LightningConnectionStringHelper.ExtractValues(client.ToString(), out var type); + var kv = LightningConnectionStringHelper.ExtractValues(client.ToString(), out _); if (kv.TryGetValue("cookiefilepath", out _) || kv.TryGetValue("macaroondirectorypath", out _) || kv.TryGetValue("macaroonfilepath", out _) ) diff --git a/BTCPayServer/Hosting/MigrationStartupTask.cs b/BTCPayServer/Hosting/MigrationStartupTask.cs index 4b53bd4e4..b9feee307 100644 --- a/BTCPayServer/Hosting/MigrationStartupTask.cs +++ b/BTCPayServer/Hosting/MigrationStartupTask.cs @@ -475,9 +475,6 @@ namespace BTCPayServer.Hosting continue; var obj = new JObject(); obj.Add("color", label.Value); - var labelObjId = new WalletObjectId(WalletId.Parse(wallet.Id), - WalletObjectData.Types.Label, - labelId); ctx.WalletObjects.Add(new WalletObjectData() { WalletId = wallet.Id, diff --git a/BTCPayServer/Hosting/Startup.cs b/BTCPayServer/Hosting/Startup.cs index 0541ac6b5..7cb8cff10 100644 --- a/BTCPayServer/Hosting/Startup.cs +++ b/BTCPayServer/Hosting/Startup.cs @@ -139,7 +139,7 @@ namespace BTCPayServer.Hosting services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); - var mvcBuilder = services.AddMvc(o => + services.AddMvc(o => { o.Filters.Add(new XFrameOptionsAttribute(XFrameOptionsAttribute.XFrameOptions.Deny)); o.Filters.Add(new XContentTypeOptionsAttribute("nosniff")); diff --git a/BTCPayServer/Hosting/ToPostgresMigrationStartupTask.cs b/BTCPayServer/Hosting/ToPostgresMigrationStartupTask.cs index 4c594941b..0e39371fc 100644 --- a/BTCPayServer/Hosting/ToPostgresMigrationStartupTask.cs +++ b/BTCPayServer/Hosting/ToPostgresMigrationStartupTask.cs @@ -172,7 +172,6 @@ namespace BTCPayServer.Hosting if (await otherContext.Settings.FirstOrDefaultAsync() == null) return; { - var postgres = new NpgsqlConnectionStringBuilder(p); using var postgresContext = new ApplicationDbContext(new DbContextOptionsBuilder().UseNpgsql(p, o => { o.CommandTimeout(60 * 60 * 10); diff --git a/BTCPayServer/PaymentRequest/PaymentRequestHub.cs b/BTCPayServer/PaymentRequest/PaymentRequestHub.cs index e80ed1c5e..0ce7aff73 100644 --- a/BTCPayServer/PaymentRequest/PaymentRequestHub.cs +++ b/BTCPayServer/PaymentRequest/PaymentRequestHub.cs @@ -80,7 +80,7 @@ namespace BTCPayServer.PaymentRequest await _PaymentRequestController.CancelUnpaidPendingInvoice(prId, false); switch (result) { - case OkObjectResult okObjectResult: + case OkObjectResult: await Clients.Group(prId).SendCoreAsync(InvoiceCancelled, System.Array.Empty()); break; diff --git a/BTCPayServer/Payments/Bitcoin/NBXplorerListener.cs b/BTCPayServer/Payments/Bitcoin/NBXplorerListener.cs index de7647730..594da732d 100644 --- a/BTCPayServer/Payments/Bitcoin/NBXplorerListener.cs +++ b/BTCPayServer/Payments/Bitcoin/NBXplorerListener.cs @@ -411,7 +411,6 @@ namespace BTCPayServer.Payments.Bitcoin private async Task ReceivedPayment(BTCPayWallet wallet, InvoiceEntity invoice, PaymentEntity payment, DerivationStrategyBase strategy) { - var paymentData = (BitcoinLikePaymentData)payment.GetCryptoPaymentData(); invoice = (await UpdatePaymentStates(wallet, invoice.Id)); if (invoice == null) return null; diff --git a/BTCPayServer/Payments/LNURLPay/LNURLPayPaymentHandler.cs b/BTCPayServer/Payments/LNURLPay/LNURLPayPaymentHandler.cs index b59d9689c..3138e18b9 100644 --- a/BTCPayServer/Payments/LNURLPay/LNURLPayPaymentHandler.cs +++ b/BTCPayServer/Payments/LNURLPay/LNURLPayPaymentHandler.cs @@ -57,8 +57,7 @@ namespace BTCPayServer.Payments.Lightning { throw new PaymentMethodUnavailableException("LNURL requires a lightning node to be configured for the store."); } - - var client = lnSupported.CreateLightningClient(network, Options.Value, _lightningClientFactoryService); + var nodeInfo = (await _lightningLikePaymentHandler.GetNodeInfo(lnSupported, _networkProvider.GetNetwork(supportedPaymentMethod.CryptoCode), logs, paymentMethod.PreferOnion)).FirstOrDefault(); return new LNURLPayPaymentMethodDetails() diff --git a/BTCPayServer/Payments/Lightning/LightningListener.cs b/BTCPayServer/Payments/Lightning/LightningListener.cs index a55d6cc49..cbc09caae 100644 --- a/BTCPayServer/Payments/Lightning/LightningListener.cs +++ b/BTCPayServer/Payments/Lightning/LightningListener.cs @@ -251,7 +251,7 @@ namespace BTCPayServer.Payments.Lightning { lock (_InstanceListeners) { - foreach ((var key, var instance) in _InstanceListeners.ToArray()) + foreach ((_, var instance) in _InstanceListeners.ToArray()) { instance.RemoveExpiredInvoices(); if (!instance.Empty) diff --git a/BTCPayServer/PayoutProcessors/UIPayoutProcessorsController.cs b/BTCPayServer/PayoutProcessors/UIPayoutProcessorsController.cs index 1208e5707..1b2e44af8 100644 --- a/BTCPayServer/PayoutProcessors/UIPayoutProcessorsController.cs +++ b/BTCPayServer/PayoutProcessors/UIPayoutProcessorsController.cs @@ -42,9 +42,6 @@ public class UIPayoutProcessorsController : Controller new PayoutProcessorService.PayoutProcessorQuery() { Stores = new[] { storeId } })) .GroupBy(data => data.Processor); - var paymentMethods = HttpContext.GetStoreData().GetEnabledPaymentMethods(_btcPayNetworkProvider) - .Select(method => method.PaymentId).ToList(); - return View(_payoutProcessorFactories.Select(factory => { var conf = activeProcessors.FirstOrDefault(datas => datas.Key == factory.Processor) diff --git a/BTCPayServer/Plugins/Altcoins/AltcoinsPlugin.cs b/BTCPayServer/Plugins/Altcoins/AltcoinsPlugin.cs index 8663bc59a..36a3b10cf 100644 --- a/BTCPayServer/Plugins/Altcoins/AltcoinsPlugin.cs +++ b/BTCPayServer/Plugins/Altcoins/AltcoinsPlugin.cs @@ -25,7 +25,6 @@ namespace BTCPayServer.Plugins.Altcoins public override void Execute(IServiceCollection applicationBuilder) { var services = (PluginServiceCollection)applicationBuilder; - var onChain = new Payments.PaymentMethodId("BTC", Payments.PaymentTypes.BTCLike); NBXplorerNetworkProvider = services.BootstrapServices.GetRequiredService(); ChainName = NBXplorerNetworkProvider.NetworkType; diff --git a/BTCPayServer/Plugins/Bitcoin/BitcoinPlugin.cs b/BTCPayServer/Plugins/Bitcoin/BitcoinPlugin.cs index d055b2504..70cb0aa80 100644 --- a/BTCPayServer/Plugins/Bitcoin/BitcoinPlugin.cs +++ b/BTCPayServer/Plugins/Bitcoin/BitcoinPlugin.cs @@ -21,7 +21,6 @@ namespace BTCPayServer.Plugins.Bitcoin var nbxplorerNetworkProvider = services.BootstrapServices.GetRequiredService(); var nbxplorerNetwork = nbxplorerNetworkProvider.GetFromCryptoCode("BTC"); var chainName = nbxplorerNetwork.NBitcoinNetwork.ChainName; - var selectedChains = services.BootstrapServices.GetRequiredService(); if (!services.BootstrapServices.GetRequiredService().Contains("BTC")) return; var blockExplorerLink = chainName == ChainName.Mainnet ? "https://mempool.space/tx/{0}" : diff --git a/BTCPayServer/Plugins/Shopify/ShopifyApiClient.cs b/BTCPayServer/Plugins/Shopify/ShopifyApiClient.cs index 7a600b428..d08c84c63 100644 --- a/BTCPayServer/Plugins/Shopify/ShopifyApiClient.cs +++ b/BTCPayServer/Plugins/Shopify/ShopifyApiClient.cs @@ -73,7 +73,7 @@ namespace BTCPayServer.Plugins.Shopify public async Task RemoveWebhook(string id) { var req = CreateRequest(_credentials.ShopName, HttpMethod.Delete, $"webhooks/{id}.json"); - var strResp = await SendRequest(req); + await SendRequest(req); } public async Task CheckScopes() diff --git a/BTCPayServer/Services/Invoices/InvoiceRepository.cs b/BTCPayServer/Services/Invoices/InvoiceRepository.cs index ece763785..b78a73b05 100644 --- a/BTCPayServer/Services/Invoices/InvoiceRepository.cs +++ b/BTCPayServer/Services/Invoices/InvoiceRepository.cs @@ -319,8 +319,6 @@ namespace BTCPayServer.Services.Invoices var paymentMethod = invoiceEntity.GetPaymentMethod(network, paymentMethodDetails.GetPaymentType()); if (paymentMethod == null) return false; - - var existingPaymentMethod = paymentMethod.GetPaymentMethodDetails(); paymentMethod.SetPaymentMethodDetails(paymentMethodDetails); #pragma warning disable CS0618 if (network.IsBTC) @@ -358,7 +356,6 @@ namespace BTCPayServer.Services.Invoices var invoice = await context.Invoices.FindAsync(invoiceId); if (invoice == null) return; - var network = paymentMethod.Network; var invoiceEntity = invoice.GetBlob(_btcPayNetworkProvider); var newDetails = paymentMethod.GetPaymentMethodDetails(); var existing = invoiceEntity.GetPaymentMethod(paymentMethod.GetId()); diff --git a/BTCPayServer/Views/Shared/CreateOrEditRole.cshtml b/BTCPayServer/Views/Shared/CreateOrEditRole.cshtml index 94f10b0fc..489c1e882 100644 --- a/BTCPayServer/Views/Shared/CreateOrEditRole.cshtml +++ b/BTCPayServer/Views/Shared/CreateOrEditRole.cshtml @@ -14,7 +14,6 @@ role = null; var storeId = Context.GetRouteValue("storeId") as string; - var controller = ViewContext.RouteData.Values["controller"].ToString().TrimEnd("Controller", StringComparison.InvariantCultureIgnoreCase); if (storeId is null) ViewData.SetActivePage(ServerNavPages.Roles, role is null ? "Create role" : "Update role");