mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 14:22:40 +01:00
* Greenfield: Add payment hash and preimage to Lightning invoices Closes #4475. * Greenfield: Add payment hash and preimage to invoice payment method details * Refactor LN payment method details retrieval
49 lines
1.6 KiB
C#
49 lines
1.6 KiB
C#
using System.Collections.Generic;
|
|
using BTCPayServer.Client.JsonConverters;
|
|
using BTCPayServer.Lightning;
|
|
using BTCPayServer.Payments.Lightning;
|
|
using BTCPayServer.Services.Invoices;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
namespace BTCPayServer.Payments
|
|
{
|
|
public class LNURLPayPaymentMethodDetails : LightningLikePaymentMethodDetails
|
|
{
|
|
public LightningSupportedPaymentMethod LightningSupportedPaymentMethod { get; set; }
|
|
|
|
[JsonConverter(typeof(LightMoneyJsonConverter))]
|
|
public LightMoney GeneratedBoltAmount { get; set; }
|
|
|
|
public string BTCPayInvoiceId { get; set; }
|
|
public bool Bech32Mode { get; set; }
|
|
|
|
public string ProvidedComment { get; set; }
|
|
public string ConsumedLightningAddress { get; set; }
|
|
|
|
public override PaymentType GetPaymentType()
|
|
{
|
|
return LNURLPayPaymentType.Instance;
|
|
}
|
|
|
|
public override string GetAdditionalDataPartialName()
|
|
{
|
|
if (string.IsNullOrEmpty(ProvidedComment) && string.IsNullOrEmpty(ConsumedLightningAddress))
|
|
{
|
|
return null;
|
|
}
|
|
|
|
return "LNURL/AdditionalPaymentMethodDetails";
|
|
}
|
|
|
|
public override JObject GetAdditionalData()
|
|
{
|
|
var result = base.GetAdditionalData();
|
|
if (!string.IsNullOrEmpty(ProvidedComment))
|
|
result.Add("providedComment", new JValue(ProvidedComment));
|
|
if (!string.IsNullOrEmpty(ConsumedLightningAddress))
|
|
result.Add("consumedLightningAddress", new JValue(ConsumedLightningAddress));
|
|
return result;
|
|
}
|
|
}
|
|
}
|