diff --git a/BTCPayServer/Payments/Lightning/LightningLikePaymentData.cs b/BTCPayServer/Payments/Lightning/LightningLikePaymentData.cs index 47ed0cc4d..e7246e34a 100644 --- a/BTCPayServer/Payments/Lightning/LightningLikePaymentData.cs +++ b/BTCPayServer/Payments/Lightning/LightningLikePaymentData.cs @@ -7,6 +7,7 @@ using BTCPayServer.Lightning; using BTCPayServer.Lightning.JsonConverters; using BTCPayServer.Payments.Lightning; using BTCPayServer.Services.Invoices; +using NBitcoin; using Newtonsoft.Json; namespace BTCPayServer.Payments.Lightning @@ -16,17 +17,21 @@ namespace BTCPayServer.Payments.Lightning [JsonConverter(typeof(LightMoneyJsonConverter))] public LightMoney Amount { get; set; } public string BOLT11 { get; set; } + [JsonConverter(typeof(NBitcoin.JsonConverters.UInt256JsonConverter))] + public uint256 PaymentHash { get; set; } public string GetDestination(BTCPayNetwork network) { - return GetPaymentId(); + return BOLT11; } public decimal NetworkFee { get; set; } + public string GetPaymentId() { - return BOLT11; + // Legacy, some old payments don't have the PaymentHash set + return PaymentHash?.ToString() ?? BOLT11; } public PaymentTypes GetPaymentType() diff --git a/BTCPayServer/Payments/Lightning/LightningListener.cs b/BTCPayServer/Payments/Lightning/LightningListener.cs index 6ec855458..5179a1900 100644 --- a/BTCPayServer/Payments/Lightning/LightningListener.cs +++ b/BTCPayServer/Payments/Lightning/LightningListener.cs @@ -191,6 +191,7 @@ namespace BTCPayServer.Payments.Lightning var payment = await _InvoiceRepository.AddPayment(listenedInvoice.InvoiceId, notification.PaidAt.Value, new LightningLikePaymentData() { BOLT11 = notification.BOLT11, + PaymentHash = BOLT11PaymentRequest.Parse(notification.BOLT11, network.NBitcoinNetwork).PaymentHash, Amount = notification.Amount }, network, accounted: true); if (payment != null)