diff --git a/BTCPayServer.Tests/TestAccount.cs b/BTCPayServer.Tests/TestAccount.cs index bfe337b52..5ef6b0b08 100644 --- a/BTCPayServer.Tests/TestAccount.cs +++ b/BTCPayServer.Tests/TestAccount.cs @@ -99,10 +99,6 @@ namespace BTCPayServer.Tests var store = parent.PayTester.GetController(UserId, StoreId); ExtKey = new ExtKey().GetWif(SupportedNetwork.NBitcoinNetwork); DerivationScheme = new DerivationStrategyFactory(SupportedNetwork.NBitcoinNetwork).Parse(ExtKey.Neuter().ToString() + (segwit ? "" : "-[legacy]")); - var vm = (StoreViewModel)((ViewResult)store.UpdateStore()).Model; - vm.SpeedPolicy = SpeedPolicy.MediumSpeed; - await store.UpdateStore(vm); - await store.AddDerivationScheme(StoreId, new DerivationSchemeViewModel() { DerivationScheme = DerivationScheme.ToString(), diff --git a/BTCPayServer.Tests/UnitTest1.cs b/BTCPayServer.Tests/UnitTest1.cs index f2f42dc50..4667e8ce4 100644 --- a/BTCPayServer.Tests/UnitTest1.cs +++ b/BTCPayServer.Tests/UnitTest1.cs @@ -51,6 +51,7 @@ using RatesViewModel = BTCPayServer.Models.StoreViewModels.RatesViewModel; using NBitpayClient.Extensions; using BTCPayServer.Services; using System.Text.RegularExpressions; +using BTCPayServer.Events; namespace BTCPayServer.Tests { @@ -521,22 +522,22 @@ namespace BTCPayServer.Tests var evtName = request["event"]["name"].Value(); switch (evtName) { - case "invoice_created": + case InvoiceEvent.Created: tester.ExplorerNode.SendToAddress(url.Address, url.Amount); break; - case "invoice_receivedPayment": + case InvoiceEvent.ReceivedPayment: receivedPayment = true; break; - case "invoice_paidInFull": + case InvoiceEvent.PaidInFull: Assert.True(receivedPayment); tester.ExplorerNode.Generate(6); paid = true; break; - case "invoice_confirmed": + case InvoiceEvent.Confirmed: Assert.True(paid); confirmed = true; break; - case "invoice_completed": + case InvoiceEvent.Completed: Assert.True(paid); //TODO: Fix, out of order event mean we can receive invoice_confirmed after invoice_complete completed = true; break; diff --git a/BTCPayServer/Controllers/InvoiceController.API.cs b/BTCPayServer/Controllers/InvoiceController.API.cs index b44e51469..03435a8d6 100644 --- a/BTCPayServer/Controllers/InvoiceController.API.cs +++ b/BTCPayServer/Controllers/InvoiceController.API.cs @@ -73,10 +73,10 @@ namespace BTCPayServer.Controllers Skip = offset, EndDate = dateEnd, StartDate = dateStart, - OrderId = orderId == null ? null : new[] {orderId}, - ItemCode = itemCode == null ? null : new[] {itemCode}, - Status = status == null ? null : new[] {status}, - StoreId = new[] {this.HttpContext.GetStoreData().Id} + OrderId = orderId == null ? null : new[] { orderId }, + ItemCode = itemCode == null ? null : new[] { itemCode }, + Status = status == null ? null : new[] { status }, + StoreId = new[] { this.HttpContext.GetStoreData().Id } }; var entities = (await _InvoiceRepository.GetInvoices(query)) diff --git a/BTCPayServer/Controllers/InvoiceController.cs b/BTCPayServer/Controllers/InvoiceController.cs index de58dc171..47c46a615 100644 --- a/BTCPayServer/Controllers/InvoiceController.cs +++ b/BTCPayServer/Controllers/InvoiceController.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using BTCPayServer.Data; +using BTCPayServer.Events; using BTCPayServer.Logging; using BTCPayServer.Models; using BTCPayServer.Payments; @@ -159,7 +160,7 @@ namespace BTCPayServer.Controllers entity.PosData = invoice.PosData; entity = await _InvoiceRepository.CreateInvoiceAsync(store.Id, entity, logs, _NetworkProvider); await fetchingAll; - _EventAggregator.Publish(new Events.InvoiceEvent(entity.EntityToDTO(_NetworkProvider), 1001, "invoice_created")); + _EventAggregator.Publish(new Events.InvoiceEvent(entity.EntityToDTO(_NetworkProvider), 1001, InvoiceEvent.Created)); var resp = entity.EntityToDTO(_NetworkProvider); return new DataWrapper(resp) { Facade = "pos/invoice" }; } diff --git a/BTCPayServer/HostedServices/InvoiceNotificationManager.cs b/BTCPayServer/HostedServices/InvoiceNotificationManager.cs index 455050373..b63d5d5d8 100644 --- a/BTCPayServer/HostedServices/InvoiceNotificationManager.cs +++ b/BTCPayServer/HostedServices/InvoiceNotificationManager.cs @@ -341,14 +341,14 @@ namespace BTCPayServer.HostedServices // we need to use the status in the event and not in the invoice. The invoice might now be in another status. if (invoice.FullNotifications) { - if (e.Name == "invoice_expired" || - e.Name == "invoice_paidInFull" || - e.Name == "invoice_failedToConfirm" || - e.Name == "invoice_markedInvalid" || - e.Name == "invoice_markedComplete" || - e.Name == "invoice_failedToConfirm" || - e.Name == "invoice_completed" || - e.Name == "invoice_expiredPaidPartial" + if (e.Name == InvoiceEvent.Expired || + e.Name == InvoiceEvent.PaidInFull || + e.Name == InvoiceEvent.FailedToConfirm || + e.Name == InvoiceEvent.MarkedInvalid || + e.Name == InvoiceEvent.MarkedCompleted || + e.Name == InvoiceEvent.FailedToConfirm || + e.Name == InvoiceEvent.Completed || + e.Name == InvoiceEvent.ExpiredPaidPartial ) tasks.Add(Notify(invoice)); } diff --git a/BTCPayServer/Services/Invoices/InvoiceRepository.cs b/BTCPayServer/Services/Invoices/InvoiceRepository.cs index cf98e8212..ba9f5bd19 100644 --- a/BTCPayServer/Services/Invoices/InvoiceRepository.cs +++ b/BTCPayServer/Services/Invoices/InvoiceRepository.cs @@ -467,7 +467,7 @@ retry: { var statusSet = queryObject.OrderId.ToHashSet(); query = query.Where(i => statusSet.Contains(i.OrderId)); - } + } if (queryObject.ItemCode != null && queryObject.ItemCode.Length > 0) { var statusSet = queryObject.ItemCode.ToHashSet();