diff --git a/BTCPayServer/Data/Payouts/LightningLike/UILightningLikePayoutController.cs b/BTCPayServer/Data/Payouts/LightningLike/UILightningLikePayoutController.cs index ed866f6a5..90d24d194 100644 --- a/BTCPayServer/Data/Payouts/LightningLike/UILightningLikePayoutController.cs +++ b/BTCPayServer/Data/Payouts/LightningLike/UILightningLikePayoutController.cs @@ -192,7 +192,7 @@ namespace BTCPayServer.Data.Payouts.LightningLike return new ResultVM { PayoutId = payoutData.Id, - Result = PayResult.Error, + Success = false, Destination = blob.Destination, Message = message }; @@ -216,7 +216,7 @@ namespace BTCPayServer.Data.Payouts.LightningLike { public string PayoutId { get; set; } public string Destination { get; set; } - public PayResult Result { get; set; } + public bool? Success { get; set; } public string Message { get; set; } } diff --git a/BTCPayServer/Payments/Lightning/LightningPendingPayoutListener.cs b/BTCPayServer/Payments/Lightning/LightningPendingPayoutListener.cs index 8577e7fca..7cc17f40f 100644 --- a/BTCPayServer/Payments/Lightning/LightningPendingPayoutListener.cs +++ b/BTCPayServer/Payments/Lightning/LightningPendingPayoutListener.cs @@ -100,25 +100,25 @@ public class LightningPendingPayoutListener : BaseAsyncService if (proof is not null) payment = await client.GetPayment(proof.PaymentHash, CancellationToken); } - catch + catch (OperationCanceledException) { + // Do not mark as cancelled if the operation was cancelled. + // This can happen with Nostr GetPayment if the connection to relay is too slow. + continue; } - if (payment is null) - { - payoutData.State = PayoutState.Cancelled; - continue; - } - switch (payment.Status) - { - case LightningPaymentStatus.Complete: - payoutData.State = PayoutState.Completed; - proof.Preimage = payment.Preimage; - payoutData.SetProofBlob(proof, null); - break; - case LightningPaymentStatus.Failed: - payoutData.State = PayoutState.Cancelled; - break; - } + payoutData.State = payment?.Status switch + { + LightningPaymentStatus.Complete => PayoutState.Completed, + LightningPaymentStatus.Failed => PayoutState.Cancelled, + LightningPaymentStatus.Unknown or LightningPaymentStatus.Pending => PayoutState.InProgress, + _ => PayoutState.Cancelled + }; + + if (payment is { Status: LightningPaymentStatus.Complete }) + { + proof.Preimage = payment.Preimage; + payoutData.SetProofBlob(proof, null); + } } foreach (PayoutData payoutData in payoutByStoreByPaymentMethod) diff --git a/BTCPayServer/PayoutProcessors/Lightning/LightningAutomatedPayoutProcessor.cs b/BTCPayServer/PayoutProcessors/Lightning/LightningAutomatedPayoutProcessor.cs index 557a0c73e..253f28a11 100644 --- a/BTCPayServer/PayoutProcessors/Lightning/LightningAutomatedPayoutProcessor.cs +++ b/BTCPayServer/PayoutProcessors/Lightning/LightningAutomatedPayoutProcessor.cs @@ -110,7 +110,7 @@ public class LightningAutomatedPayoutProcessor : BaseAutomatedPayoutProcessor