mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-20 13:34:37 +01:00
Fix bug with LN payment method API endpoint throwing 500 (#2567)
close #2566
This commit is contained in:
parent
df64a93808
commit
3d21d2724e
2 changed files with 12 additions and 9 deletions
|
@ -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()
|
||||
);
|
||||
|
|
|
@ -1,24 +1,23 @@
|
|||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using BTCPayServer.Lightning;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace BTCPayServer.Payments.Lightning
|
||||
{
|
||||
public class LightningSupportedPaymentMethod : ISupportedPaymentMethod
|
||||
{
|
||||
public const string InternalNode = "Internal Node";
|
||||
public string CryptoCode { get; set; }
|
||||
public string? CryptoCode { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public PaymentMethodId PaymentId => new PaymentMethodId(CryptoCode, PaymentTypes.LightningLike);
|
||||
|
||||
[Obsolete("Use Get/SetLightningUrl")]
|
||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public string LightningConnectionString { get; set; }
|
||||
public string? LightningConnectionString { get; set; }
|
||||
|
||||
public LightningConnectionString GetExternalLightningUrl()
|
||||
public LightningConnectionString? GetExternalLightningUrl()
|
||||
{
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
if (!string.IsNullOrEmpty(LightningConnectionString))
|
||||
|
@ -64,7 +63,7 @@ namespace BTCPayServer.Payments.Lightning
|
|||
}
|
||||
|
||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public string InternalNodeRef { get; set; }
|
||||
public string? InternalNodeRef { get; set; }
|
||||
[JsonIgnore]
|
||||
public bool IsInternalNode
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue