Remove unused variables (#5669)

This commit is contained in:
Nicolas Dorier 2024-01-18 09:47:39 +09:00 committed by GitHub
parent dd7ab2f647
commit 376067324b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
39 changed files with 78 additions and 126 deletions

View File

@ -174,7 +174,6 @@ namespace BTCPayServer.Logging
logLevelColors = GetLogLevelConsoleColors(logLevel); logLevelColors = GetLogLevelConsoleColors(logLevel);
logLevelString = GetLogLevelString(logLevel); logLevelString = GetLogLevelString(logLevel);
// category and event id // category and event id
var lenBefore = logBuilder.ToString().Length;
logBuilder.Append(_loglevelPadding); logBuilder.Append(_loglevelPadding);
logBuilder.Append(logName); logBuilder.Append(logName);
logBuilder.Append(": "); logBuilder.Append(": ");

View File

@ -110,7 +110,7 @@ namespace BTCPayServer.Services.Rates
public void LoadState(BackgroundFetcherState state) public void LoadState(BackgroundFetcherState state)
{ {
if (state.LastRequested is DateTimeOffset lastRequested) if (state.LastRequested is DateTimeOffset)
this.LastRequested = state.LastRequested; this.LastRequested = state.LastRequested;
if (state.LastUpdated is DateTimeOffset updated && state.Rates is List<BackgroundFetcherRate> rates) if (state.LastUpdated is DateTimeOffset updated && state.Rates is List<BackgroundFetcherRate> rates)
{ {

View File

@ -87,7 +87,6 @@ namespace BTCPayServer.Services.Rates
var normalizedPairsList = symbols.Where(s => !notFoundSymbols.ContainsKey(s)).Select(s => helper.NormalizeMarketSymbol(s)).ToList(); var normalizedPairsList = symbols.Where(s => !notFoundSymbols.ContainsKey(s)).Select(s => helper.NormalizeMarketSymbol(s)).ToList();
var csvPairsList = string.Join(",", normalizedPairsList); var csvPairsList = string.Join(",", normalizedPairsList);
JToken apiTickers = await MakeJsonRequestAsync<JToken>("/0/public/Ticker", null, new Dictionary<string, object> { { "pair", csvPairsList } }, cancellationToken: cancellationToken); JToken apiTickers = await MakeJsonRequestAsync<JToken>("/0/public/Ticker", null, new Dictionary<string, object> { { "pair", csvPairsList } }, cancellationToken: cancellationToken);
var tickers = new List<KeyValuePair<string, ExchangeTicker>>();
foreach (string symbol in symbols) foreach (string symbol in symbols)
{ {
var ticker = ConvertToExchangeTicker(symbol, apiTickers[symbol]); var ticker = ConvertToExchangeTicker(symbol, apiTickers[symbol]);

View File

@ -45,7 +45,6 @@ namespace BTCPayServer.Services.Rates
var fetchingRates = new Dictionary<CurrencyPair, Task<RateResult>>(); var fetchingRates = new Dictionary<CurrencyPair, Task<RateResult>>();
var fetchingExchanges = new Dictionary<string, Task<QueryRateResult>>(); var fetchingExchanges = new Dictionary<string, Task<QueryRateResult>>();
var consolidatedRates = new ExchangeRates();
foreach (var i in pairs.Select(p => (Pair: p, RateRule: rules.GetRuleFor(p)))) foreach (var i in pairs.Select(p => (Pair: p, RateRule: rules.GetRuleFor(p))))
{ {

View File

@ -649,11 +649,6 @@ namespace BTCPayServer.Tests
public void CanAcceptInvoiceWithTolerance() public void CanAcceptInvoiceWithTolerance()
{ {
var networkProvider = CreateNetworkProvider(ChainName.Regtest); 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(); var entity = new InvoiceEntity();
entity.Networks = networkProvider; entity.Networks = networkProvider;
#pragma warning disable CS0618 #pragma warning disable CS0618
@ -1620,7 +1615,7 @@ bc1qfzu57kgu5jthl934f9xrdzzx8mmemx7gn07tf0grnvz504j6kzusu2v0ku
{ {
var b = JsonConvert.DeserializeObject<PullPaymentBlob>("{}"); var b = JsonConvert.DeserializeObject<PullPaymentBlob>("{}");
Assert.Equal(TimeSpan.FromDays(30.0), b.BOLT11Expiration); Assert.Equal(TimeSpan.FromDays(30.0), b.BOLT11Expiration);
var aaa = JsonConvert.SerializeObject(b); JsonConvert.SerializeObject(b);
} }
[Fact] [Fact]
@ -2129,7 +2124,7 @@ bc1qfzu57kgu5jthl934f9xrdzzx8mmemx7gn07tf0grnvz504j6kzusu2v0ku
[Fact] [Fact]
public void AllPoliciesShowInUI() 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) foreach (var policy in Policies.AllPolicies)
{ {
Assert.True(UIManageController.AddApiKeyViewModel.PermissionValueItem.PermissionDescriptions.ContainsKey(policy)); Assert.True(UIManageController.AddApiKeyViewModel.PermissionValueItem.PermissionDescriptions.ContainsKey(policy));

View File

@ -58,8 +58,8 @@ namespace BTCPayServer.Tests
var factory = tester.PayTester.GetService<IBTCPayServerClientFactory>(); var factory = tester.PayTester.GetService<IBTCPayServerClientFactory>();
Assert.NotNull(factory); Assert.NotNull(factory);
var client = await factory.Create(user.UserId, user.StoreId); var client = await factory.Create(user.UserId, user.StoreId);
var u = await client.GetCurrentUser(); await client.GetCurrentUser();
var s = await client.GetStores(); await client.GetStores();
var store = await client.GetStore(user.StoreId); var store = await client.GetStore(user.StoreId);
Assert.NotNull(store); Assert.NotNull(store);
var addr = await client.GetLightningDepositAddress(user.StoreId, "BTC"); var addr = await client.GetLightningDepositAddress(user.StoreId, "BTC");
@ -1138,7 +1138,7 @@ namespace BTCPayServer.Tests
var approved = await acc.CreateClient(Policies.CanCreatePullPayments); var approved = await acc.CreateClient(Policies.CanCreatePullPayments);
await AssertPermissionError(Policies.CanCreatePullPayments, async () => await AssertPermissionError(Policies.CanCreatePullPayments, async () =>
{ {
var pullPayment = await nonApproved.CreatePullPayment(acc.StoreId, new CreatePullPaymentRequest() await nonApproved.CreatePullPayment(acc.StoreId, new CreatePullPaymentRequest()
{ {
Amount = 100, Amount = 100,
Currency = "USD", Currency = "USD",
@ -1149,7 +1149,7 @@ namespace BTCPayServer.Tests
}); });
await AssertPermissionError(Policies.CanCreatePullPayments, async () => await AssertPermissionError(Policies.CanCreatePullPayments, async () =>
{ {
var pullPayment = await nonApproved.CreatePayout(acc.StoreId, new CreatePayoutThroughStoreRequest() await nonApproved.CreatePayout(acc.StoreId, new CreatePayoutThroughStoreRequest()
{ {
Amount = 100, Amount = 100,
PaymentMethod = "BTC", 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, Amount = 100,
Currency = "USD", Currency = "USD",
@ -1167,7 +1167,7 @@ namespace BTCPayServer.Tests
AutoApproveClaims = true AutoApproveClaims = true
}); });
var p = await approved.CreatePayout(acc.StoreId, new CreatePayoutThroughStoreRequest() await approved.CreatePayout(acc.StoreId, new CreatePayoutThroughStoreRequest()
{ {
Amount = 100, Amount = 100,
PaymentMethod = "BTC", PaymentMethod = "BTC",
@ -2537,7 +2537,6 @@ namespace BTCPayServer.Tests
Expiry = TimeSpan.FromSeconds(400), Expiry = TimeSpan.FromSeconds(400),
PrivateRouteHints = false PrivateRouteHints = false
}); });
var chargeInvoice = invoiceData;
Assert.NotNull(await client.GetLightningInvoice("BTC", invoiceData.Id)); Assert.NotNull(await client.GetLightningInvoice("BTC", invoiceData.Id));
// check list for internal node // check list for internal node
@ -3679,7 +3678,7 @@ namespace BTCPayServer.Tests
SavePrivateKeys = true SavePrivateKeys = true
}); });
var preApprovedPayoutWithoutPullPayment = await adminClient.CreatePayout(admin.StoreId, new CreatePayoutThroughStoreRequest() await adminClient.CreatePayout(admin.StoreId, new CreatePayoutThroughStoreRequest()
{ {
Amount = 0.0001m, Amount = 0.0001m,
Approved = true, Approved = true,
@ -3911,7 +3910,7 @@ namespace BTCPayServer.Tests
beforeHookTcs = new TaskCompletionSource(); beforeHookTcs = new TaskCompletionSource();
afterHookTcs = new TaskCompletionSource(); afterHookTcs = new TaskCompletionSource();
var payoutThatShouldNotBeProcessedStraightAway3 = await adminClient.CreatePayout(admin.StoreId, new CreatePayoutThroughStoreRequest() await adminClient.CreatePayout(admin.StoreId, new CreatePayoutThroughStoreRequest()
{ {
Amount = 0.3m, Amount = 0.3m,
Approved = true, Approved = true,
@ -4331,7 +4330,7 @@ clientBasic.PreviewUpdateStoreRateConfiguration(user.StoreId, new StoreRateConfi
await admin.GrantAccessAsync(true); await admin.GrantAccessAsync(true);
var unauthClient = new BTCPayServerClient(tester.PayTester.ServerUri); 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 adminClient = await admin.CreateClient(Policies.Unrestricted);
var managerClient = await admin.CreateClient(Policies.CanManageCustodianAccounts); var managerClient = await admin.CreateClient(Policies.CanManageCustodianAccounts);
var withdrawalClient = await admin.CreateClient(Policies.CanWithdrawFromCustodianAccounts); var withdrawalClient = await admin.CreateClient(Policies.CanWithdrawFromCustodianAccounts);

View File

@ -29,7 +29,7 @@ namespace BTCPayServer.Tests
using var s = CreateSeleniumTester(newDb: true); using var s = CreateSeleniumTester(newDb: true);
await s.StartAsync(); await s.StartAsync();
var u1 = s.RegisterNewUser(true); s.RegisterNewUser(true);
var hot = s.CreateNewStore(); var hot = s.CreateNewStore();
var seed = s.GenerateWallet(isHotWallet: true); var seed = s.GenerateWallet(isHotWallet: true);
var cold = s.CreateNewStore(); var cold = s.CreateNewStore();

View File

@ -68,7 +68,7 @@ namespace BTCPayServer.Tests
{ {
using var tester = CreateServerTester(); using var tester = CreateServerTester();
await tester.StartAsync(); await tester.StartAsync();
var network = tester.NetworkProvider.GetNetwork<BTCPayNetwork>("BTC"); tester.NetworkProvider.GetNetwork<BTCPayNetwork>("BTC");
var repo = tester.PayTester.GetService<UTXOLocker>(); var repo = tester.PayTester.GetService<UTXOLocker>();
var outpoint = RandomOutpoint(); var outpoint = RandomOutpoint();
@ -189,10 +189,10 @@ namespace BTCPayServer.Tests
using var tester = CreateServerTester(); using var tester = CreateServerTester();
await tester.StartAsync(); await tester.StartAsync();
var broadcaster = tester.PayTester.GetService<DelayedTransactionBroadcaster>(); var broadcaster = tester.PayTester.GetService<DelayedTransactionBroadcaster>();
var payjoinRepository = tester.PayTester.GetService<UTXOLocker>(); tester.PayTester.GetService<UTXOLocker>();
broadcaster.Disable(); broadcaster.Disable();
var network = tester.NetworkProvider.GetNetwork<BTCPayNetwork>("BTC"); var network = tester.NetworkProvider.GetNetwork<BTCPayNetwork>("BTC");
var btcPayWallet = tester.PayTester.GetService<BTCPayWalletProvider>().GetWallet(network); tester.PayTester.GetService<BTCPayWalletProvider>().GetWallet(network);
var cashCow = tester.ExplorerNode; var cashCow = tester.ExplorerNode;
cashCow.Generate(2); // get some money in case cashCow.Generate(2); // get some money in case
@ -218,7 +218,7 @@ namespace BTCPayServer.Tests
receiverUser.GrantAccess(true); receiverUser.GrantAccess(true);
receiverUser.RegisterDerivationScheme("BTC", receiverAddressType, true); receiverUser.RegisterDerivationScheme("BTC", receiverAddressType, true);
await receiverUser.ModifyOnchainPaymentSettings(p => p.PayJoinEnabled = 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"; string errorCode = receiverAddressType == senderAddressType ? null : "unavailable|any UTXO available";
var invoice = receiverUser.BitPay.CreateInvoice(new Invoice() { Price = 50000, Currency = "SATS", FullNotifications = true }); 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)); txBuilder.SendEstimatedFees(new FeeRate(50m));
var psbt = txBuilder.BuildPSBT(false); var psbt = txBuilder.BuildPSBT(false);
psbt = await senderUser.Sign(psbt); 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); s.RegisterNewUser(true);
var receiver = s.CreateNewStore(); var receiver = s.CreateNewStore();
s.EnableCheckout(CheckoutType.V1); 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 receiverWalletId = new WalletId(receiver.storeId, "BTC");
var sender = s.CreateNewStore(); 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"); var senderWalletId = new WalletId(sender.storeId, "BTC");
await s.Server.ExplorerNode.GenerateAsync(1); await s.Server.ExplorerNode.GenerateAsync(1);
@ -305,7 +305,7 @@ namespace BTCPayServer.Tests
var cryptoCode = "BTC"; var cryptoCode = "BTC";
var receiver = s.CreateNewStore(); var receiver = s.CreateNewStore();
s.EnableCheckout(CheckoutType.V1); 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); var receiverWalletId = new WalletId(receiver.storeId, cryptoCode);
//payjoin is enabled by default. //payjoin is enabled by default.
@ -320,7 +320,7 @@ namespace BTCPayServer.Tests
Assert.True(s.Driver.FindElement(By.Id("PayJoinEnabled")).Selected); Assert.True(s.Driver.FindElement(By.Id("PayJoinEnabled")).Selected);
var sender = s.CreateNewStore(); 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); var senderWalletId = new WalletId(sender.storeId, cryptoCode);
await s.Server.ExplorerNode.GenerateAsync(1); await s.Server.ExplorerNode.GenerateAsync(1);
await s.FundStoreWallet(senderWalletId); await s.FundStoreWallet(senderWalletId);
@ -374,7 +374,7 @@ namespace BTCPayServer.Tests
s.Driver.FindElement(By.Id("FeeSatoshiPerByte")).Clear(); s.Driver.FindElement(By.Id("FeeSatoshiPerByte")).Clear();
s.Driver.FindElement(By.Id("FeeSatoshiPerByte")).SendKeys("2"); s.Driver.FindElement(By.Id("FeeSatoshiPerByte")).SendKeys("2");
s.Driver.FindElement(By.Id("SignTransaction")).Click(); s.Driver.FindElement(By.Id("SignTransaction")).Click();
var txId = await s.Server.WaitForEvent<NewOnChainTransactionEvent>(() => await s.Server.WaitForEvent<NewOnChainTransactionEvent>(() =>
{ {
s.Driver.FindElement(By.CssSelector("button[value=payjoin]")).Click(); s.Driver.FindElement(By.CssSelector("button[value=payjoin]")).Click();
return Task.CompletedTask; return Task.CompletedTask;
@ -406,7 +406,6 @@ namespace BTCPayServer.Tests
await TestUtils.EventuallyAsync(async () => await TestUtils.EventuallyAsync(async () =>
{ {
var invoice = await s.Server.PayTester.GetService<InvoiceRepository>().GetInvoice(invoiceId); var invoice = await s.Server.PayTester.GetService<InvoiceRepository>().GetInvoice(invoiceId);
var dto = invoice.EntityToDTO();
Assert.Equal(InvoiceStatusLegacy.Paid, invoice.Status); Assert.Equal(InvoiceStatusLegacy.Paid, invoice.Status);
}); });
s.GoToInvoices(receiver.storeId); s.GoToInvoices(receiver.storeId);
@ -875,7 +874,6 @@ retry:
new Invoice() { Price = 0.02m, Currency = "BTC", FullNotifications = true }); new Invoice() { Price = 0.02m, Currency = "BTC", FullNotifications = true });
cashCow.SendToAddress(BitcoinAddress.Create(invoice.BitcoinAddress, cashCow.Network), cashCow.SendToAddress(BitcoinAddress.Create(invoice.BitcoinAddress, cashCow.Network),
Money.Coins(0.06m)); Money.Coins(0.06m));
var receiverWalletId = new WalletId(receiverUser.StoreId, "BTC");
//give the cow some cash //give the cow some cash
await cashCow.GenerateAsync(1); await cashCow.GenerateAsync(1);
@ -963,8 +961,6 @@ retry:
senderUser.GenerateWalletResponseV.MasterHDKey.Derive(signingKeySettings.GetRootedKeyPath() senderUser.GenerateWalletResponseV.MasterHDKey.Derive(signingKeySettings.GetRootedKeyPath()
.KeyPath); .KeyPath);
var n = tester.ExplorerClient.Network.NBitcoinNetwork;
var Invoice1Coin1 = tester.ExplorerClient.Network.NBitcoinNetwork.CreateTransactionBuilder() var Invoice1Coin1 = tester.ExplorerClient.Network.NBitcoinNetwork.CreateTransactionBuilder()
.SetChange(senderChange) .SetChange(senderChange)
.Send(parsedBip21.Address, parsedBip21.Amount) .Send(parsedBip21.Address, parsedBip21.Amount)
@ -973,7 +969,7 @@ retry:
.SendEstimatedFees(new FeeRate(100m)) .SendEstimatedFees(new FeeRate(100m))
.BuildTransaction(true); .BuildTransaction(true);
var Invoice1Coin2 = tester.ExplorerClient.Network.NBitcoinNetwork.CreateTransactionBuilder() tester.ExplorerClient.Network.NBitcoinNetwork.CreateTransactionBuilder()
.SetChange(senderChange) .SetChange(senderChange)
.Send(parsedBip21.Address, parsedBip21.Amount) .Send(parsedBip21.Address, parsedBip21.Amount)
.AddCoins(coin2.Coin) .AddCoins(coin2.Coin)
@ -1133,8 +1129,7 @@ retry:
var invoice7Coin6Response1Tx = await senderUser.SubmitPayjoin(invoice7, invoice7Coin6Tx, btcPayNetwork); var invoice7Coin6Response1Tx = await senderUser.SubmitPayjoin(invoice7, invoice7Coin6Tx, btcPayNetwork);
var Invoice7Coin6Response1TxSigned = invoice7Coin6TxBuilder.SignTransaction(invoice7Coin6Response1Tx); 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); ////var receiverWalletPayJoinState = payJoinStateProvider.Get(receiverWalletId);

View File

@ -1633,7 +1633,6 @@ namespace BTCPayServer.Tests
var mnemonic = s.GenerateWallet(cryptoCode, "", true, true); var mnemonic = s.GenerateWallet(cryptoCode, "", true, true);
//lets import and save private keys //lets import and save private keys
var root = mnemonic.DeriveExtKey();
invoiceId = s.CreateInvoice(storeId); invoiceId = s.CreateInvoice(storeId);
invoice = await s.Server.PayTester.InvoiceRepository.GetInvoice(invoiceId); invoice = await s.Server.PayTester.InvoiceRepository.GetInvoice(invoiceId);
address = invoice.EntityToDTO().Addresses["BTC"]; 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) // BOLT11 is also displayed for standard invoice (not LNURL, even if it is available)
s.Driver.FindElement(By.Id("copy-tab")).Click(); s.Driver.FindElement(By.Id("copy-tab")).Click();
var bolt11 = s.Driver.FindElement(By.CssSelector("input.checkoutTextbox")).GetAttribute("value"); 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(); var invoiceId = s.Driver.Url.Split('/').Last();
using (var resp = await s.Server.PayTester.HttpClient.GetAsync("BTC/lnurl/pay/i/" + invoiceId)) 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 } }); invoices = await repo.GetInvoices(new InvoiceQuery() { StoreId = new[] { s.StoreId } });
Assert.Equal(2, invoices.Length); Assert.Equal(2, invoices.Length);
var emailSuffix = $"@{s.Server.PayTester.HostName}:{s.Server.PayTester.Port}";
foreach (var i in invoices) foreach (var i in invoices)
{ {
var lightningPaymentMethod = i.GetPaymentMethod(new PaymentMethodId("BTC", PaymentTypes.LNURLPay)); var lightningPaymentMethod = i.GetPaymentMethod(new PaymentMethodId("BTC", PaymentTypes.LNURLPay));

View File

@ -73,7 +73,7 @@ namespace BTCPayServer.Tests
public async Task<BTCPayServerClient> CreateClient(params string[] permissions) public async Task<BTCPayServerClient> CreateClient(params string[] permissions)
{ {
var manageController = parent.PayTester.GetController<UIManageController>(UserId, StoreId, IsAdmin); var manageController = parent.PayTester.GetController<UIManageController>(UserId, StoreId, IsAdmin);
var x = Assert.IsType<RedirectToActionResult>(await manageController.AddApiKey( Assert.IsType<RedirectToActionResult>(await manageController.AddApiKey(
new UIManageController.AddApiKeyViewModel() new UIManageController.AddApiKeyViewModel()
{ {
PermissionValues = permissions.Select(s => PermissionValues = permissions.Select(s =>
@ -339,7 +339,6 @@ namespace BTCPayServer.Tests
public async Task<BitcoinAddress> GetNewAddress(BTCPayNetwork network) public async Task<BitcoinAddress> GetNewAddress(BTCPayNetwork network)
{ {
var cashCow = parent.ExplorerNode;
var btcPayWallet = parent.PayTester.GetService<BTCPayWalletProvider>().GetWallet(network); var btcPayWallet = parent.PayTester.GetService<BTCPayWalletProvider>().GetWallet(network);
var address = (await btcPayWallet.ReserveAddressAsync(this.DerivationScheme)).Address; var address = (await btcPayWallet.ReserveAddressAsync(this.DerivationScheme)).Address;
return address; return address;
@ -347,7 +346,7 @@ namespace BTCPayServer.Tests
public async Task<PSBT> Sign(PSBT psbt) public async Task<PSBT> Sign(PSBT psbt)
{ {
var btcPayWallet = parent.PayTester.GetService<BTCPayWalletProvider>() parent.PayTester.GetService<BTCPayWalletProvider>()
.GetWallet(psbt.Network.NetworkSet.CryptoCode); .GetWallet(psbt.Network.NetworkSet.CryptoCode);
var explorerClient = parent.PayTester.GetService<ExplorerClientProvider>() var explorerClient = parent.PayTester.GetService<ExplorerClientProvider>()
.GetExplorerClient(psbt.Network.NetworkSet.CryptoCode); .GetExplorerClient(psbt.Network.NetworkSet.CryptoCode);
@ -444,7 +443,7 @@ namespace BTCPayServer.Tests
var parsedBip21 = new BitcoinUrlBuilder( var parsedBip21 = new BitcoinUrlBuilder(
invoice.CryptoInfo.First(c => c.CryptoCode == network.NetworkSet.CryptoCode).PaymentUrls.BIP21, invoice.CryptoInfo.First(c => c.CryptoCode == network.NetworkSet.CryptoCode).PaymentUrls.BIP21,
network); network);
if (!parsedBip21.TryGetPayjoinEndpoint(out var endpoint)) if (!parsedBip21.TryGetPayjoinEndpoint(out _))
return null; return null;
return parsedBip21; return parsedBip21;
} }

View File

@ -278,7 +278,6 @@ retry:
} }
catch (Exception ex) when (ex is MatchesException) catch (Exception ex) when (ex is MatchesException)
{ {
var details = ex.Message;
TestLogs.LogInformation($"FAILED: {url} ({file}) anchor not found: {uri.Fragment}"); TestLogs.LogInformation($"FAILED: {url} ({file}) anchor not found: {uri.Fragment}");
throw; throw;

View File

@ -267,7 +267,6 @@ namespace BTCPayServer.Tests
} }
catch (Exception ex) when (ex is MatchesException) catch (Exception ex) when (ex is MatchesException)
{ {
var details = ex.Message;
TestLogs.LogInformation($"FAILED: {url} ({file}) anchor not found: {uri.Fragment}"); TestLogs.LogInformation($"FAILED: {url} ({file}) anchor not found: {uri.Fragment}");
throw; throw;
@ -347,7 +346,7 @@ namespace BTCPayServer.Tests
try try
{ {
var throwsBitpay404Error = user.BitPay.GetInvoice(invoice.Id + "123"); user.BitPay.GetInvoice(invoice.Id + "123");
} }
catch (BitPayException ex) catch (BitPayException ex)
{ {
@ -885,7 +884,7 @@ namespace BTCPayServer.Tests
Assert.Equal("LTC", GetCurrencyPairRateResult.Data.Code); Assert.Equal("LTC", GetCurrencyPairRateResult.Data.Code);
// Should be OK because the request is signed, so we can know the store // 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(); HttpClient client = new HttpClient();
// Unauthentified requests should also be ok // Unauthentified requests should also be ok
var response = var response =
@ -1072,7 +1071,7 @@ namespace BTCPayServer.Tests
var invoice = await user.BitPay.CreateInvoiceAsync(new Invoice(0.01m, "BTC")); var invoice = await user.BitPay.CreateInvoiceAsync(new Invoice(0.01m, "BTC"));
await tester.WaitForEvent<InvoiceEvent>(async () => await tester.WaitForEvent<InvoiceEvent>(async () =>
{ {
var tx = await tester.ExplorerNode.SendToAddressAsync( await tester.ExplorerNode.SendToAddressAsync(
BitcoinAddress.Create(invoice.BitcoinAddress, Network.RegTest), BitcoinAddress.Create(invoice.BitcoinAddress, Network.RegTest),
Money.Coins(0.01m)); Money.Coins(0.01m));
}); });
@ -1457,7 +1456,7 @@ namespace BTCPayServer.Tests
// via UI // via UI
var controller = user.GetController<UIInvoiceController>(); var controller = user.GetController<UIInvoiceController>();
var model = await controller.CreateInvoice(); await controller.CreateInvoice();
(await controller.CreateInvoice(new CreateInvoiceModel(), default)).AssertType<RedirectToActionResult>(); (await controller.CreateInvoice(new CreateInvoiceModel(), default)).AssertType<RedirectToActionResult>();
invoice = await client.GetInvoice(user.StoreId, controller.CreatedInvoiceId); invoice = await client.GetInvoice(user.StoreId, controller.CreatedInvoiceId);
Assert.Equal("EUR", invoice.Currency); Assert.Equal("EUR", invoice.Currency);
@ -2139,8 +2138,7 @@ namespace BTCPayServer.Tests
user.RegisterDerivationScheme("BTC"); user.RegisterDerivationScheme("BTC");
var serverController = user.GetController<UIServerController>(); var serverController = user.GetController<UIServerController>();
var vm = Assert.IsType<LogsViewModel>( Assert.IsType<LogsViewModel>(Assert.IsType<ViewResult>(await serverController.LogsView()).Model);
Assert.IsType<ViewResult>(await serverController.LogsView()).Model);
} }
[Fact(Timeout = LongRunningTestTimeout)] [Fact(Timeout = LongRunningTestTimeout)]
@ -2394,7 +2392,7 @@ namespace BTCPayServer.Tests
Assert.NotNull(lnMethod.GetExternalLightningUrl()); Assert.NotNull(lnMethod.GetExternalLightningUrl());
var url = 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); Assert.Equal(LightningConnectionType.Charge, connType);
var client = Assert.IsType<ChargeClient>(tester.PayTester.GetService<LightningClientFactoryService>() var client = Assert.IsType<ChargeClient>(tester.PayTester.GetService<LightningClientFactoryService>()
.Create(url, tester.NetworkProvider.GetNetwork<BTCPayNetwork>("BTC"))); .Create(url, tester.NetworkProvider.GetNetwork<BTCPayNetwork>("BTC")));
@ -2771,7 +2769,7 @@ namespace BTCPayServer.Tests
Assert.Equal(fileContent, data); Assert.Equal(fileContent, data);
//create a temporary link to file //create a temporary link to file
var tmpLinkGenerate = Assert.IsType<RedirectToActionResult>(await controller.CreateTemporaryFileUrl(fileId, Assert.IsType<RedirectToActionResult>(await controller.CreateTemporaryFileUrl(fileId,
new UIServerController.CreateTemporaryFileUrlViewModel new UIServerController.CreateTemporaryFileUrlViewModel
{ {
IsDownload = true, IsDownload = true,

View File

@ -409,7 +409,7 @@ retry:
content.Headers.TryAddWithoutValidation("Content-Type", "application/vnd.api+json;profile=\"bulk\""); content.Headers.TryAddWithoutValidation("Content-Type", "application/vnd.api+json;profile=\"bulk\"");
message.Content = content; message.Content = content;
using var response = await Client.SendAsync(message); using var response = await Client.SendAsync(message);
var str = await response.Content.ReadAsStringAsync(); await response.Content.ReadAsStringAsync();
}).ToArray()); }).ToArray());
} }

View File

@ -30,7 +30,7 @@ public class AppSales : ViewComponent
public async Task<IViewComponentResult> InvokeAsync(string appId, string appType) public async Task<IViewComponentResult> InvokeAsync(string appId, string appType)
{ {
var type = _appService.GetAppType(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)); return new HtmlContentViewComponentResult(new StringHtmlContent(string.Empty));
var vm = new AppSalesViewModel var vm = new AppSalesViewModel
{ {

View File

@ -23,7 +23,7 @@ namespace BTCPayServer.Controllers.Greenfield
GenerateWalletRequest request) GenerateWalletRequest request)
{ {
AssertCryptoCodeWallet(cryptoCode, out var network, out var wallet); AssertCryptoCodeWallet(cryptoCode, out var network, out _);
if (!_walletProvider.IsAvailable(network)) if (!_walletProvider.IsAvailable(network))
{ {

View File

@ -117,7 +117,7 @@ namespace BTCPayServer.Controllers.Greenfield
public async Task<IActionResult> GetOnChainFeeRate(string storeId, string cryptoCode, int? blockTarget = null) public async Task<IActionResult> GetOnChainFeeRate(string storeId, string cryptoCode, int? blockTarget = null)
{ {
if (IsInvalidWalletRequest(cryptoCode, out var network, if (IsInvalidWalletRequest(cryptoCode, out var network,
out var derivationScheme, out var actionResult)) out _, out var actionResult))
return actionResult; return actionResult;
var feeRateTarget = blockTarget ?? Store.GetStoreBlob().RecommendedFeeBlockTarget; 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")] [HttpDelete("~/api/v1/stores/{storeId}/payment-methods/onchain/{cryptoCode}/wallet/address")]
public async Task<IActionResult> UnReserveOnChainWalletReceiveAddress(string storeId, string cryptoCode) public async Task<IActionResult> UnReserveOnChainWalletReceiveAddress(string storeId, string cryptoCode)
{ {
if (IsInvalidWalletRequest(cryptoCode, out var network, if (IsInvalidWalletRequest(cryptoCode, out _,
out var derivationScheme, out var actionResult)) out _, out var actionResult))
return actionResult; return actionResult;
var addr = await _walletReceiveService.UnReserveAddress(new WalletId(storeId, cryptoCode)); var addr = await _walletReceiveService.UnReserveAddress(new WalletId(storeId, cryptoCode));

View File

@ -78,7 +78,7 @@ namespace BTCPayServer.Controllers.Greenfield
private void ValidateWebhookRequest(StoreWebhookBaseData create) 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"); ModelState.AddModelError(nameof(Url), "Invalid Url");
} }

View File

@ -240,7 +240,7 @@ namespace BTCPayServer.Controllers.Greenfield
} }
if (!string.IsNullOrEmpty(request.DefaultPaymentMethod) && 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"); ModelState.AddModelError(nameof(request.Name), "DefaultPaymentMethod is invalid");
} }

View File

@ -205,7 +205,7 @@ namespace BTCPayServer.Controllers
} }
else else
{ {
var incrementAccessFailedResult = await _userManager.AccessFailedAsync(user); await _userManager.AccessFailedAsync(user);
ModelState.AddModelError(string.Empty, "Invalid login attempt."); ModelState.AddModelError(string.Empty, "Invalid login attempt.");
return View(model); return View(model);

View File

@ -391,10 +391,6 @@ namespace BTCPayServer.Controllers
return NotFound(); return NotFound();
} }
var store = GetCurrentStore();
var storeBlob = BTCPayServer.Data.StoreDataExtensions.GetStoreBlob(store);
var defaultCurrency = storeBlob.DefaultCurrency;
try try
{ {
var assetBalancesData = var assetBalancesData =
@ -583,7 +579,7 @@ namespace BTCPayServer.Controllers
try try
{ {
if (custodian is ICanWithdraw withdrawableCustodian) if (custodian is ICanWithdraw)
{ {
var config = custodianAccount.GetBlob(); var config = custodianAccount.GetBlob();

View File

@ -227,7 +227,6 @@ namespace BTCPayServer.Controllers
entity.Status = InvoiceStatusLegacy.New; entity.Status = InvoiceStatusLegacy.New;
entity.UpdateTotals(); entity.UpdateTotals();
HashSet<CurrencyPair> currencyPairsToFetch = new HashSet<CurrencyPair>(); HashSet<CurrencyPair> currencyPairsToFetch = new HashSet<CurrencyPair>();
var rules = storeBlob.GetRateRules(_NetworkProvider);
var excludeFilter = storeBlob.GetExcludedPaymentMethods(); // Here we can compose filters from other origin with PaymentFilter.Any() var excludeFilter = storeBlob.GetExcludedPaymentMethods(); // Here we can compose filters from other origin with PaymentFilter.Any()
if (invoicePaymentMethodFilter != null) if (invoicePaymentMethodFilter != null)
{ {

View File

@ -168,37 +168,31 @@ namespace BTCPayServer.Controllers
return View(vm); return View(vm);
} }
var builder = new UriBuilder(); var builder = new UriBuilder();
using (var client = new HttpClient(new HttpClientHandler() try
{ {
ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator builder.Scheme = this.Request.Scheme;
})) builder.Host = vm.DNSDomain;
{ var addresses1 = GetAddressAsync(this.Request.Host.Host);
try 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 addressesSet = addresses1.GetAwaiter().GetResult().Select(c => c.ToString()).ToHashSet();
var hasCommonAddress = addresses2.GetAwaiter().GetResult().Select(c => c.ToString()).Any(s => addressesSet.Contains(s)); var hasCommonAddress = addresses2.GetAwaiter().GetResult().Select(c => c.ToString()).Any(s => addressesSet.Contains(s));
if (!hasCommonAddress) 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 messages = new List<object>(); ModelState.AddModelError(nameof(vm.DNSDomain), $"Invalid host ({vm.DNSDomain} is not pointing to this BTCPay instance)");
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); return View(vm);
} }
} }
catch (Exception ex)
{
var messages = new List<object>();
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}"); var error = await RunSSH(vm, $"changedomain.sh {vm.DNSDomain}");
if (error != null) if (error != null)
@ -685,7 +679,7 @@ namespace BTCPayServer.Controllers
[HttpPost] [HttpPost]
public async Task<IActionResult> ServicePost(string serviceName, string cryptoCode) public async Task<IActionResult> 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"; TempData[WellKnownTempData.ErrorMessage] = $"{cryptoCode} is not fully synched";
return RedirectToAction(nameof(Services)); return RedirectToAction(nameof(Services));

View File

@ -191,7 +191,7 @@ namespace BTCPayServer.Controllers
[HttpGet("{storeId}/onchain/{cryptoCode}/generate/{method?}")] [HttpGet("{storeId}/onchain/{cryptoCode}/generate/{method?}")]
public async Task<IActionResult> GenerateWallet(WalletSetupViewModel vm) public async Task<IActionResult> 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) if (checkResult != null)
{ {
return checkResult; return checkResult;
@ -231,7 +231,7 @@ namespace BTCPayServer.Controllers
[HttpPost("{storeId}/onchain/{cryptoCode}/generate/{method}")] [HttpPost("{storeId}/onchain/{cryptoCode}/generate/{method}")]
public async Task<IActionResult> GenerateWallet(string storeId, string cryptoCode, WalletSetupMethod method, WalletSetupRequest request) public async Task<IActionResult> 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) if (checkResult != null)
{ {
return checkResult; return checkResult;

View File

@ -504,7 +504,7 @@ namespace BTCPayServer.Controllers
var methodCriterion = model.PaymentMethodCriteria[index]; var methodCriterion = model.PaymentMethodCriteria[index];
if (!string.IsNullOrWhiteSpace(methodCriterion.Value)) 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, 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); $"{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; break;
case LNURLPayPaymentType lnurlPayPaymentType: case LNURLPayPaymentType:
break; break;
case LightningPaymentType _: case LightningPaymentType _:
@ -1000,7 +1000,7 @@ namespace BTCPayServer.Controllers
var store = model.StoreId switch var store = model.StoreId switch
{ {
null => CurrentStore, null => CurrentStore,
string id => await _Repo.FindStore(storeId, userId) _ => await _Repo.FindStore(storeId, userId)
}; };
if (store == null) if (store == null)
return Challenge(AuthenticationSchemes.Cookie); return Challenge(AuthenticationSchemes.Cookie);

View File

@ -146,7 +146,6 @@ namespace BTCPayServer.Controllers
return NotFound(); return NotFound();
var txObjId = new WalletObjectId(walletId, WalletObjectData.Types.Tx, transactionId); var txObjId = new WalletObjectId(walletId, WalletObjectData.Types.Tx, transactionId);
var wallet = _walletProvider.GetWallet(paymentMethod.Network);
if (addlabel != null) if (addlabel != null)
{ {
await WalletRepository.AddWalletObjectLabels(txObjId, addlabel); await WalletRepository.AddWalletObjectLabels(txObjId, addlabel);
@ -414,7 +413,6 @@ namespace BTCPayServer.Controllers
await ExplorerClientProvider.GetExplorerClient(walletId.CryptoCode).WaitServerStartedAsync(); await ExplorerClientProvider.GetExplorerClient(walletId.CryptoCode).WaitServerStartedAsync();
await Task.Delay(1000); await Task.Delay(1000);
await using var conn = await factory.OpenConnection(); await using var conn = await factory.OpenConnection();
var wallet_id = paymentMethod.GetNBXWalletId();
var txIds = sending.Select(s => s.Result.ToString()).ToArray(); var txIds = sending.Select(s => s.Result.ToString()).ToArray();
await conn.ExecuteAsync( await conn.ExecuteAsync(

View File

@ -154,7 +154,7 @@ namespace BTCPayServer
public static Uri GetServerUri(this ILightningClient client) 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); 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) 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 _) || if (kv.TryGetValue("cookiefilepath", out _) ||
kv.TryGetValue("macaroondirectorypath", out _) || kv.TryGetValue("macaroondirectorypath", out _) ||
kv.TryGetValue("macaroonfilepath", out _) ) kv.TryGetValue("macaroonfilepath", out _) )

View File

@ -475,9 +475,6 @@ namespace BTCPayServer.Hosting
continue; continue;
var obj = new JObject(); var obj = new JObject();
obj.Add("color", label.Value); obj.Add("color", label.Value);
var labelObjId = new WalletObjectId(WalletId.Parse(wallet.Id),
WalletObjectData.Types.Label,
labelId);
ctx.WalletObjects.Add(new WalletObjectData() ctx.WalletObjects.Add(new WalletObjectData()
{ {
WalletId = wallet.Id, WalletId = wallet.Id,

View File

@ -139,7 +139,7 @@ namespace BTCPayServer.Hosting
services.AddSingleton<UserLoginCodeService>(); services.AddSingleton<UserLoginCodeService>();
services.AddSingleton<LnurlAuthService>(); services.AddSingleton<LnurlAuthService>();
services.AddSingleton<LightningAddressService>(); services.AddSingleton<LightningAddressService>();
var mvcBuilder = services.AddMvc(o => services.AddMvc(o =>
{ {
o.Filters.Add(new XFrameOptionsAttribute(XFrameOptionsAttribute.XFrameOptions.Deny)); o.Filters.Add(new XFrameOptionsAttribute(XFrameOptionsAttribute.XFrameOptions.Deny));
o.Filters.Add(new XContentTypeOptionsAttribute("nosniff")); o.Filters.Add(new XContentTypeOptionsAttribute("nosniff"));

View File

@ -172,7 +172,6 @@ namespace BTCPayServer.Hosting
if (await otherContext.Settings.FirstOrDefaultAsync() == null) if (await otherContext.Settings.FirstOrDefaultAsync() == null)
return; return;
{ {
var postgres = new NpgsqlConnectionStringBuilder(p);
using var postgresContext = new ApplicationDbContext(new DbContextOptionsBuilder<ApplicationDbContext>().UseNpgsql(p, o => using var postgresContext = new ApplicationDbContext(new DbContextOptionsBuilder<ApplicationDbContext>().UseNpgsql(p, o =>
{ {
o.CommandTimeout(60 * 60 * 10); o.CommandTimeout(60 * 60 * 10);

View File

@ -80,7 +80,7 @@ namespace BTCPayServer.PaymentRequest
await _PaymentRequestController.CancelUnpaidPendingInvoice(prId, false); await _PaymentRequestController.CancelUnpaidPendingInvoice(prId, false);
switch (result) switch (result)
{ {
case OkObjectResult okObjectResult: case OkObjectResult:
await Clients.Group(prId).SendCoreAsync(InvoiceCancelled, System.Array.Empty<object>()); await Clients.Group(prId).SendCoreAsync(InvoiceCancelled, System.Array.Empty<object>());
break; break;

View File

@ -411,7 +411,6 @@ namespace BTCPayServer.Payments.Bitcoin
private async Task<InvoiceEntity> ReceivedPayment(BTCPayWallet wallet, InvoiceEntity invoice, PaymentEntity payment, DerivationStrategyBase strategy) private async Task<InvoiceEntity> ReceivedPayment(BTCPayWallet wallet, InvoiceEntity invoice, PaymentEntity payment, DerivationStrategyBase strategy)
{ {
var paymentData = (BitcoinLikePaymentData)payment.GetCryptoPaymentData();
invoice = (await UpdatePaymentStates(wallet, invoice.Id)); invoice = (await UpdatePaymentStates(wallet, invoice.Id));
if (invoice == null) if (invoice == null)
return null; return null;

View File

@ -58,7 +58,6 @@ namespace BTCPayServer.Payments.Lightning
throw new PaymentMethodUnavailableException("LNURL requires a lightning node to be configured for the store."); 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<BTCPayNetwork>(supportedPaymentMethod.CryptoCode), logs, paymentMethod.PreferOnion)).FirstOrDefault(); var nodeInfo = (await _lightningLikePaymentHandler.GetNodeInfo(lnSupported, _networkProvider.GetNetwork<BTCPayNetwork>(supportedPaymentMethod.CryptoCode), logs, paymentMethod.PreferOnion)).FirstOrDefault();
return new LNURLPayPaymentMethodDetails() return new LNURLPayPaymentMethodDetails()

View File

@ -251,7 +251,7 @@ namespace BTCPayServer.Payments.Lightning
{ {
lock (_InstanceListeners) lock (_InstanceListeners)
{ {
foreach ((var key, var instance) in _InstanceListeners.ToArray()) foreach ((_, var instance) in _InstanceListeners.ToArray())
{ {
instance.RemoveExpiredInvoices(); instance.RemoveExpiredInvoices();
if (!instance.Empty) if (!instance.Empty)

View File

@ -42,9 +42,6 @@ public class UIPayoutProcessorsController : Controller
new PayoutProcessorService.PayoutProcessorQuery() { Stores = new[] { storeId } })) new PayoutProcessorService.PayoutProcessorQuery() { Stores = new[] { storeId } }))
.GroupBy(data => data.Processor); .GroupBy(data => data.Processor);
var paymentMethods = HttpContext.GetStoreData().GetEnabledPaymentMethods(_btcPayNetworkProvider)
.Select(method => method.PaymentId).ToList();
return View(_payoutProcessorFactories.Select(factory => return View(_payoutProcessorFactories.Select(factory =>
{ {
var conf = activeProcessors.FirstOrDefault(datas => datas.Key == factory.Processor) var conf = activeProcessors.FirstOrDefault(datas => datas.Key == factory.Processor)

View File

@ -25,7 +25,6 @@ namespace BTCPayServer.Plugins.Altcoins
public override void Execute(IServiceCollection applicationBuilder) public override void Execute(IServiceCollection applicationBuilder)
{ {
var services = (PluginServiceCollection)applicationBuilder; var services = (PluginServiceCollection)applicationBuilder;
var onChain = new Payments.PaymentMethodId("BTC", Payments.PaymentTypes.BTCLike);
NBXplorerNetworkProvider = services.BootstrapServices.GetRequiredService<NBXplorerNetworkProvider>(); NBXplorerNetworkProvider = services.BootstrapServices.GetRequiredService<NBXplorerNetworkProvider>();
ChainName = NBXplorerNetworkProvider.NetworkType; ChainName = NBXplorerNetworkProvider.NetworkType;

View File

@ -21,7 +21,6 @@ namespace BTCPayServer.Plugins.Bitcoin
var nbxplorerNetworkProvider = services.BootstrapServices.GetRequiredService<NBXplorerNetworkProvider>(); var nbxplorerNetworkProvider = services.BootstrapServices.GetRequiredService<NBXplorerNetworkProvider>();
var nbxplorerNetwork = nbxplorerNetworkProvider.GetFromCryptoCode("BTC"); var nbxplorerNetwork = nbxplorerNetworkProvider.GetFromCryptoCode("BTC");
var chainName = nbxplorerNetwork.NBitcoinNetwork.ChainName; var chainName = nbxplorerNetwork.NBitcoinNetwork.ChainName;
var selectedChains = services.BootstrapServices.GetRequiredService<SelectedChains>();
if (!services.BootstrapServices.GetRequiredService<SelectedChains>().Contains("BTC")) if (!services.BootstrapServices.GetRequiredService<SelectedChains>().Contains("BTC"))
return; return;
var blockExplorerLink = chainName == ChainName.Mainnet ? "https://mempool.space/tx/{0}" : var blockExplorerLink = chainName == ChainName.Mainnet ? "https://mempool.space/tx/{0}" :

View File

@ -73,7 +73,7 @@ namespace BTCPayServer.Plugins.Shopify
public async Task RemoveWebhook(string id) public async Task RemoveWebhook(string id)
{ {
var req = CreateRequest(_credentials.ShopName, HttpMethod.Delete, $"webhooks/{id}.json"); var req = CreateRequest(_credentials.ShopName, HttpMethod.Delete, $"webhooks/{id}.json");
var strResp = await SendRequest(req); await SendRequest(req);
} }
public async Task<string[]> CheckScopes() public async Task<string[]> CheckScopes()

View File

@ -319,8 +319,6 @@ namespace BTCPayServer.Services.Invoices
var paymentMethod = invoiceEntity.GetPaymentMethod(network, paymentMethodDetails.GetPaymentType()); var paymentMethod = invoiceEntity.GetPaymentMethod(network, paymentMethodDetails.GetPaymentType());
if (paymentMethod == null) if (paymentMethod == null)
return false; return false;
var existingPaymentMethod = paymentMethod.GetPaymentMethodDetails();
paymentMethod.SetPaymentMethodDetails(paymentMethodDetails); paymentMethod.SetPaymentMethodDetails(paymentMethodDetails);
#pragma warning disable CS0618 #pragma warning disable CS0618
if (network.IsBTC) if (network.IsBTC)
@ -358,7 +356,6 @@ namespace BTCPayServer.Services.Invoices
var invoice = await context.Invoices.FindAsync(invoiceId); var invoice = await context.Invoices.FindAsync(invoiceId);
if (invoice == null) if (invoice == null)
return; return;
var network = paymentMethod.Network;
var invoiceEntity = invoice.GetBlob(_btcPayNetworkProvider); var invoiceEntity = invoice.GetBlob(_btcPayNetworkProvider);
var newDetails = paymentMethod.GetPaymentMethodDetails(); var newDetails = paymentMethod.GetPaymentMethodDetails();
var existing = invoiceEntity.GetPaymentMethod(paymentMethod.GetId()); var existing = invoiceEntity.GetPaymentMethod(paymentMethod.GetId());

View File

@ -14,7 +14,6 @@
role = null; role = null;
var storeId = Context.GetRouteValue("storeId") as string; var storeId = Context.GetRouteValue("storeId") as string;
var controller = ViewContext.RouteData.Values["controller"].ToString().TrimEnd("Controller", StringComparison.InvariantCultureIgnoreCase);
if (storeId is null) if (storeId is null)
ViewData.SetActivePage(ServerNavPages.Roles, role is null ? "Create role" : "Update role"); ViewData.SetActivePage(ServerNavPages.Roles, role is null ? "Create role" : "Update role");