diff --git a/BTCPayServer.Tests/UnitTest1.cs b/BTCPayServer.Tests/UnitTest1.cs index 97799073c..7f00bef2a 100644 --- a/BTCPayServer.Tests/UnitTest1.cs +++ b/BTCPayServer.Tests/UnitTest1.cs @@ -1801,7 +1801,7 @@ ReceivedDate,StoreId,OrderId,InvoiceId,CreatedDate,ExpirationDate,MonitoringDate Assert.True(IsMapped(invoice, ctx)); cashCow.SendToAddress(invoiceAddress, firstPayment); - var invoiceEntity = repo.GetInvoice(null, invoice.Id, true).GetAwaiter().GetResult(); + var invoiceEntity = repo.GetInvoice(invoice.Id, true).GetAwaiter().GetResult(); Assert.Single(invoiceEntity.HistoricalAddresses); Assert.Null(invoiceEntity.HistoricalAddresses[0].UnAssigned); @@ -1819,7 +1819,7 @@ ReceivedDate,StoreId,OrderId,InvoiceId,CreatedDate,ExpirationDate,MonitoringDate Assert.True(IsMapped(invoice, ctx)); Assert.True(IsMapped(localInvoice, ctx)); - invoiceEntity = repo.GetInvoice(null, invoice.Id, true).GetAwaiter().GetResult(); + invoiceEntity = repo.GetInvoice(invoice.Id, true).GetAwaiter().GetResult(); var historical1 = invoiceEntity.HistoricalAddresses.FirstOrDefault(h => h.GetAddress() == invoice.BitcoinAddress); Assert.NotNull(historical1.UnAssigned); var historical2 = invoiceEntity.HistoricalAddresses.FirstOrDefault(h => h.GetAddress() == localInvoice.BitcoinAddress); diff --git a/BTCPayServer/Controllers/InvoiceController.PaymentProtocol.cs b/BTCPayServer/Controllers/InvoiceController.PaymentProtocol.cs index 3ba0a4120..40331e7f5 100644 --- a/BTCPayServer/Controllers/InvoiceController.PaymentProtocol.cs +++ b/BTCPayServer/Controllers/InvoiceController.PaymentProtocol.cs @@ -21,7 +21,7 @@ namespace BTCPayServer.Controllers { if (cryptoCode == null) cryptoCode = "BTC"; - var invoice = await _InvoiceRepository.GetInvoice(null, invoiceId); + var invoice = await _InvoiceRepository.GetInvoice(invoiceId); var network = _NetworkProvider.GetNetwork(cryptoCode); var paymentMethodId = new PaymentMethodId(cryptoCode, Payments.PaymentTypes.BTCLike); if (invoice == null || invoice.IsExpired() || network == null || !invoice.Support(paymentMethodId)) @@ -66,7 +66,7 @@ namespace BTCPayServer.Controllers [MediaTypeConstraint("application/bitcoin-payment")] public async Task PostPayment(string invoiceId, string cryptoCode = null) { - var invoice = await _InvoiceRepository.GetInvoice(null, invoiceId); + var invoice = await _InvoiceRepository.GetInvoice(invoiceId); if (cryptoCode == null) cryptoCode = "BTC"; var network = _NetworkProvider.GetNetwork(cryptoCode); diff --git a/BTCPayServer/Controllers/InvoiceController.UI.cs b/BTCPayServer/Controllers/InvoiceController.UI.cs index 08eda9572..5643de4e9 100644 --- a/BTCPayServer/Controllers/InvoiceController.UI.cs +++ b/BTCPayServer/Controllers/InvoiceController.UI.cs @@ -211,7 +211,7 @@ namespace BTCPayServer.Controllers private async Task GetInvoiceModel(string invoiceId, string paymentMethodIdStr) { - var invoice = await _InvoiceRepository.GetInvoice(null, invoiceId); + var invoice = await _InvoiceRepository.GetInvoice(invoiceId); if (invoice == null) return null; var store = await _StoreRepository.FindStore(invoice.StoreId); @@ -371,7 +371,7 @@ namespace BTCPayServer.Controllers { if (!HttpContext.WebSockets.IsWebSocketRequest) return NotFound(); - var invoice = await _InvoiceRepository.GetInvoice(null, invoiceId); + var invoice = await _InvoiceRepository.GetInvoice(invoiceId); if (invoice == null || invoice.Status == "complete" || invoice.Status == "invalid" || invoice.Status == "expired") return NotFound(); var webSocket = await HttpContext.WebSockets.AcceptWebSocketAsync(); @@ -593,7 +593,7 @@ namespace BTCPayServer.Controllers [BitpayAPIConstraint(false)] public async Task InvalidatePaidInvoice(string invoiceId) { - var invoice = await _InvoiceRepository.GetInvoice(null, invoiceId); + var invoice = await _InvoiceRepository.GetInvoice(invoiceId); if (invoice == null) return NotFound(); await _InvoiceRepository.UpdatePaidInvoiceToInvalid(invoiceId); diff --git a/BTCPayServer/HostedServices/InvoiceNotificationManager.cs b/BTCPayServer/HostedServices/InvoiceNotificationManager.cs index 019a6c38b..4a7e9fb24 100644 --- a/BTCPayServer/HostedServices/InvoiceNotificationManager.cs +++ b/BTCPayServer/HostedServices/InvoiceNotificationManager.cs @@ -330,7 +330,7 @@ namespace BTCPayServer.HostedServices { leases.Add(_EventAggregator.Subscribe(async e => { - var invoice = await _InvoiceRepository.GetInvoice(null, e.Invoice.Id); + var invoice = await _InvoiceRepository.GetInvoice(e.Invoice.Id); if (invoice == null) return; List tasks = new List(); diff --git a/BTCPayServer/HostedServices/InvoiceWatcher.cs b/BTCPayServer/HostedServices/InvoiceWatcher.cs index ddddd8698..4abc0acca 100644 --- a/BTCPayServer/HostedServices/InvoiceWatcher.cs +++ b/BTCPayServer/HostedServices/InvoiceWatcher.cs @@ -208,7 +208,7 @@ namespace BTCPayServer.HostedServices private async Task Wait(string invoiceId) { - var invoice = await _InvoiceRepository.GetInvoice(null, invoiceId); + var invoice = await _InvoiceRepository.GetInvoice(invoiceId); try { var delay = invoice.ExpirationTime - DateTimeOffset.UtcNow; @@ -283,7 +283,7 @@ namespace BTCPayServer.HostedServices loopCount++; try { - var invoice = await _InvoiceRepository.GetInvoice(null, invoiceId, true); + var invoice = await _InvoiceRepository.GetInvoice(invoiceId, true); if (invoice == null) break; var updateContext = new UpdateInvoiceContext(invoice); diff --git a/BTCPayServer/Payments/Bitcoin/NBXplorerListener.cs b/BTCPayServer/Payments/Bitcoin/NBXplorerListener.cs index 7ae9d6880..ca0860629 100644 --- a/BTCPayServer/Payments/Bitcoin/NBXplorerListener.cs +++ b/BTCPayServer/Payments/Bitcoin/NBXplorerListener.cs @@ -205,7 +205,7 @@ namespace BTCPayServer.Payments.Bitcoin async Task UpdatePaymentStates(BTCPayWallet wallet, string invoiceId) { - var invoice = await _InvoiceRepository.GetInvoice(null, invoiceId, false); + var invoice = await _InvoiceRepository.GetInvoice(invoiceId, false); if (invoice == null) return null; List updatedPaymentEntities = new List(); @@ -315,7 +315,7 @@ namespace BTCPayServer.Payments.Bitcoin var invoices = await _InvoiceRepository.GetPendingInvoices(); foreach (var invoiceId in invoices) { - var invoice = await _InvoiceRepository.GetInvoice(null, invoiceId, true); + var invoice = await _InvoiceRepository.GetInvoice(invoiceId, true); if (invoice == null) continue; var alreadyAccounted = GetAllBitcoinPaymentData(invoice).Select(p => p.Outpoint).ToHashSet(); diff --git a/BTCPayServer/Payments/Lightning/LightningListener.cs b/BTCPayServer/Payments/Lightning/LightningListener.cs index dcfa57541..1fef6f9c6 100644 --- a/BTCPayServer/Payments/Lightning/LightningListener.cs +++ b/BTCPayServer/Payments/Lightning/LightningListener.cs @@ -73,7 +73,7 @@ namespace BTCPayServer.Payments.Lightning { if (Listening(invoiceId)) return; - var invoice = await _InvoiceRepository.GetInvoice(null, invoiceId); + var invoice = await _InvoiceRepository.GetInvoice(invoiceId); foreach (var paymentMethod in invoice.GetPaymentMethods(_NetworkProvider) .Where(c => c.GetId().PaymentType == PaymentTypes.LightningLike)) { @@ -194,7 +194,7 @@ namespace BTCPayServer.Payments.Lightning }, network.CryptoCode, accounted: true); if (payment != null) { - var invoice = await _InvoiceRepository.GetInvoice(null, listenedInvoice.InvoiceId); + var invoice = await _InvoiceRepository.GetInvoice(listenedInvoice.InvoiceId); if (invoice != null) _Aggregator.Publish(new InvoiceEvent(invoice.EntityToDTO(_NetworkProvider), 1002, "invoice_receivedPayment")); } diff --git a/BTCPayServer/Services/Invoices/InvoiceRepository.cs b/BTCPayServer/Services/Invoices/InvoiceRepository.cs index 34d78ebd6..bccba17f6 100644 --- a/BTCPayServer/Services/Invoices/InvoiceRepository.cs +++ b/BTCPayServer/Services/Invoices/InvoiceRepository.cs @@ -340,7 +340,7 @@ namespace BTCPayServer.Services.Invoices await context.SaveChangesAsync().ConfigureAwait(false); } } - public async Task GetInvoice(string storeId, string id, bool inludeAddressData = false) + public async Task GetInvoice(string id, bool inludeAddressData = false) { using (var context = _ContextFactory.CreateContext()) { @@ -353,9 +353,6 @@ namespace BTCPayServer.Services.Invoices query = query.Include(o => o.HistoricalAddressInvoices).Include(o => o.AddressInvoices); query = query.Where(i => i.Id == id); - if (storeId != null) - query = query.Where(i => i.StoreDataId == storeId); - var invoice = await query.FirstOrDefaultAsync().ConfigureAwait(false); if (invoice == null) return null;