Fix bug with LN payment method API endpoint throwing 500 (#2567)

close #2566
This commit is contained in:
Umar Bolatov
2021-06-14 02:19:52 -07:00
committed by GitHub
parent df64a93808
commit 3d21d2724e
2 changed files with 12 additions and 9 deletions

View File

@@ -1,3 +1,4 @@
#nullable enable
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
@@ -11,7 +12,6 @@ using BTCPayServer.Lightning;
using BTCPayServer.Payments;
using BTCPayServer.Payments.Lightning;
using BTCPayServer.Security;
using BTCPayServer.Services;
using BTCPayServer.Services.Stores;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@@ -56,8 +56,12 @@ namespace BTCPayServer.Controllers.GreenField
.Where((method) => method.PaymentId.PaymentType == PaymentTypes.LightningLike)
.OfType<LightningSupportedPaymentMethod>()
.Select(paymentMethod =>
new LightningNetworkPaymentMethodData(paymentMethod.PaymentId.CryptoCode,
paymentMethod.GetExternalLightningUrl().ToString(), !excludedPaymentMethods.Match(paymentMethod.PaymentId)))
new LightningNetworkPaymentMethodData(
paymentMethod.PaymentId.CryptoCode,
paymentMethod.GetExternalLightningUrl()?.ToString() ?? paymentMethod.GetDisplayableConnectionString(),
!excludedPaymentMethods.Match(paymentMethod.PaymentId)
)
)
.Where((result) => !enabledOnly || result.Enabled)
.ToList()
);