From b28b3ef4ff9041b88292cc2c9ee301285813e3aa Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Wed, 14 Mar 2018 20:10:04 +0900 Subject: [PATCH] Fix: Invoice can't be paid in lightning anymore if lightning server sent error --- BTCPayServer/BTCPayServer.csproj | 2 +- BTCPayServer/Payments/Lightning/ChargeListener.cs | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/BTCPayServer/BTCPayServer.csproj b/BTCPayServer/BTCPayServer.csproj index 74ef8db49..95181a9e3 100644 --- a/BTCPayServer/BTCPayServer.csproj +++ b/BTCPayServer/BTCPayServer.csproj @@ -2,7 +2,7 @@ Exe netcoreapp2.0 - 1.0.1.48 + 1.0.1.49 NU1701,CA1816,CA1308,CA1810,CA2208 diff --git a/BTCPayServer/Payments/Lightning/ChargeListener.cs b/BTCPayServer/Payments/Lightning/ChargeListener.cs index a3e1fe964..c2b7f6e6c 100644 --- a/BTCPayServer/Payments/Lightning/ChargeListener.cs +++ b/BTCPayServer/Payments/Lightning/ChargeListener.cs @@ -60,9 +60,6 @@ namespace BTCPayServer.Payments.Lightning private async Task EnsureListening(string invoiceId, bool poll) { - if (Listening(invoiceId)) - return; - var invoice = await _InvoiceRepository.GetInvoice(null, invoiceId); foreach (var paymentMethod in invoice.GetPaymentMethods(_NetworkProvider) .Where(c => c.GetId().PaymentType == PaymentTypes.LightningLike)) @@ -98,7 +95,10 @@ namespace BTCPayServer.Payments.Lightning continue; } - StartListening(listenedInvoice); + if (!Listening(invoiceId)) + { + StartListening(listenedInvoice); + } } } @@ -232,10 +232,7 @@ namespace BTCPayServer.Payments.Lightning _ListeningLightning.Add(listen); listen.ContinueWith(_ => { - lock (_ListenedInvoiceByLightningUrl) - { - _ListeningLightning.Remove(listen); - } + DoneListening(listenedInvoice); }, TaskScheduler.Default); } _ListenedInvoiceByLightningUrl.Add(listenedInvoice.Uri, listenedInvoice);