2020-05-23 21:13:18 +02:00
|
|
|
using BTCPayServer.Client.Models;
|
2018-08-30 11:50:39 +09:00
|
|
|
using BTCPayServer.Lightning;
|
|
|
|
using BTCPayServer.Lightning.JsonConverters;
|
2018-02-26 00:48:12 +09:00
|
|
|
using BTCPayServer.Services.Invoices;
|
2019-01-27 13:06:55 +09:00
|
|
|
using NBitcoin;
|
2018-02-26 00:48:12 +09:00
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
|
|
namespace BTCPayServer.Payments.Lightning
|
|
|
|
{
|
|
|
|
public class LightningLikePaymentData : CryptoPaymentData
|
|
|
|
{
|
2019-06-07 13:24:36 +09:00
|
|
|
[JsonIgnore]
|
|
|
|
public BTCPayNetworkBase Network { get; set; }
|
2023-01-13 09:29:41 +01:00
|
|
|
|
2018-02-26 00:48:12 +09:00
|
|
|
[JsonConverter(typeof(LightMoneyJsonConverter))]
|
|
|
|
public LightMoney Amount { get; set; }
|
2023-01-13 09:29:41 +01:00
|
|
|
|
2018-02-26 00:48:12 +09:00
|
|
|
public string BOLT11 { get; set; }
|
2023-01-13 09:29:41 +01:00
|
|
|
|
2019-01-27 13:06:55 +09:00
|
|
|
[JsonConverter(typeof(NBitcoin.JsonConverters.UInt256JsonConverter))]
|
|
|
|
public uint256 PaymentHash { get; set; }
|
2023-01-13 09:29:41 +01:00
|
|
|
|
|
|
|
[JsonConverter(typeof(NBitcoin.JsonConverters.UInt256JsonConverter))]
|
|
|
|
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
|
|
|
public uint256 Preimage { get; set; }
|
|
|
|
|
2021-10-25 08:18:02 +02:00
|
|
|
public string PaymentType { get; set; }
|
2018-12-18 21:35:52 +09:00
|
|
|
|
2019-06-07 13:24:36 +09:00
|
|
|
public string GetDestination()
|
2018-12-18 21:35:52 +09:00
|
|
|
{
|
2019-01-27 13:06:55 +09:00
|
|
|
return BOLT11;
|
2018-12-18 21:35:52 +09:00
|
|
|
}
|
|
|
|
|
2019-01-05 13:31:05 +09:00
|
|
|
public decimal NetworkFee { get; set; }
|
|
|
|
|
2018-02-26 00:48:12 +09:00
|
|
|
public string GetPaymentId()
|
|
|
|
{
|
2019-01-27 13:06:55 +09:00
|
|
|
// Legacy, some old payments don't have the PaymentHash set
|
|
|
|
return PaymentHash?.ToString() ?? BOLT11;
|
2018-02-26 00:48:12 +09:00
|
|
|
}
|
|
|
|
|
2019-06-04 09:40:36 +09:00
|
|
|
public PaymentType GetPaymentType()
|
2018-02-26 00:48:12 +09:00
|
|
|
{
|
2021-10-25 08:18:02 +02:00
|
|
|
return string.IsNullOrEmpty(PaymentType) ? PaymentTypes.LightningLike : PaymentTypes.Parse(PaymentType);
|
2018-02-26 00:48:12 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
public string[] GetSearchTerms()
|
|
|
|
{
|
|
|
|
return new[] { BOLT11 };
|
|
|
|
}
|
|
|
|
|
|
|
|
public decimal GetValue()
|
|
|
|
{
|
|
|
|
return Amount.ToDecimal(LightMoneyUnit.BTC);
|
|
|
|
}
|
|
|
|
|
2019-06-07 13:24:36 +09:00
|
|
|
public bool PaymentCompleted(PaymentEntity entity)
|
2018-02-26 00:48:12 +09:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-06-07 13:24:36 +09:00
|
|
|
public bool PaymentConfirmed(PaymentEntity entity, SpeedPolicy speedPolicy)
|
2018-02-26 00:48:12 +09:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|