mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2026-01-01 13:14:30 +01:00
Fix: The current preimage of a invoice's lightning payment method should be available via API (#5111)
This commit is contained in:
@@ -2631,7 +2631,7 @@ namespace BTCPayServer.Tests
|
||||
for (int i = 0; i < invoices.Length; i++)
|
||||
{
|
||||
pm[i] = Assert.Single(await client.GetInvoicePaymentMethods(user.StoreId, (await invoices[i]).Id));
|
||||
Assert.False(pm[i].AdditionalData.HasValues);
|
||||
Assert.True(pm[i].AdditionalData.HasValues);
|
||||
}
|
||||
|
||||
// Pay them all at once
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Linq;
|
||||
using BTCPayServer.Lightning;
|
||||
using BTCPayServer.Services.Invoices;
|
||||
using NBitcoin;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace BTCPayServer.Payments.Lightning
|
||||
@@ -10,7 +11,9 @@ namespace BTCPayServer.Payments.Lightning
|
||||
public class LightningLikePaymentMethodDetails : IPaymentMethodDetails
|
||||
{
|
||||
public string BOLT11 { get; set; }
|
||||
[JsonConverter(typeof(NBitcoin.JsonConverters.UInt256JsonConverter))]
|
||||
public uint256 PaymentHash { get; set; }
|
||||
[JsonConverter(typeof(NBitcoin.JsonConverters.UInt256JsonConverter))]
|
||||
public uint256 Preimage { get; set; }
|
||||
public string InvoiceId { get; set; }
|
||||
public string NodeInfo { get; set; }
|
||||
|
||||
@@ -1007,6 +1007,11 @@ namespace BTCPayServer.Services.Invoices
|
||||
};
|
||||
}
|
||||
|
||||
// A bug in previous version of BTCPay Server wasn't properly serializing those fields
|
||||
if (PaymentMethodDetails["PaymentHash"] is JObject)
|
||||
PaymentMethodDetails["PaymentHash"] = null;
|
||||
if (PaymentMethodDetails["Preimage"] is JObject)
|
||||
PaymentMethodDetails["Preimage"] = null;
|
||||
IPaymentMethodDetails details = GetId().PaymentType.DeserializePaymentMethodDetails(Network, PaymentMethodDetails.ToString());
|
||||
switch (details)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user