mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-20 02:28:31 +01:00
0bc6967dbc
* 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
60 lines
1.6 KiB
C#
60 lines
1.6 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using BTCPayServer.Lightning;
|
|
using BTCPayServer.Services.Invoices;
|
|
using NBitcoin;
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
namespace BTCPayServer.Payments.Lightning
|
|
{
|
|
public class LightningLikePaymentMethodDetails : IPaymentMethodDetails
|
|
{
|
|
public string BOLT11 { get; set; }
|
|
public uint256 PaymentHash { get; set; }
|
|
public uint256 Preimage { get; set; }
|
|
public string InvoiceId { get; set; }
|
|
public string NodeInfo { get; set; }
|
|
|
|
public virtual string GetPaymentDestination()
|
|
{
|
|
return BOLT11;
|
|
}
|
|
|
|
public uint256 GetPaymentHash(Network network)
|
|
{
|
|
return PaymentHash ?? BOLT11PaymentRequest.Parse(BOLT11, network).PaymentHash;
|
|
}
|
|
|
|
public virtual PaymentType GetPaymentType()
|
|
{
|
|
return PaymentTypes.LightningLike;
|
|
}
|
|
|
|
public decimal GetNextNetworkFee()
|
|
{
|
|
return 0.0m;
|
|
}
|
|
|
|
public decimal GetFeeRate()
|
|
{
|
|
return 0.0m;
|
|
}
|
|
public bool Activated { get; set; }
|
|
|
|
public virtual string GetAdditionalDataPartialName()
|
|
{
|
|
return null;
|
|
}
|
|
|
|
public virtual JObject GetAdditionalData()
|
|
{
|
|
var result = new JObject();
|
|
if (PaymentHash != null && PaymentHash != default)
|
|
result.Add("paymentHash", new JValue(PaymentHash.ToString()));
|
|
if (Preimage != null && Preimage != default)
|
|
result.Add("preimage", new JValue(Preimage.ToString()));
|
|
return result;
|
|
}
|
|
}
|
|
}
|