mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-20 10:40:29 +01:00
31 lines
1.0 KiB
C#
31 lines
1.0 KiB
C#
using BTCPayServer.Services.Invoices;
|
|
using Microsoft.AspNetCore.Authorization.Infrastructure;
|
|
|
|
namespace BTCPayServer.Data
|
|
{
|
|
public static class InvoiceDataExtensions
|
|
{
|
|
public static InvoiceEntity GetBlob(this Data.InvoiceData invoiceData, BTCPayNetworkProvider networks)
|
|
{
|
|
var entity = NBitcoin.JsonConverters.Serializer.ToObject<InvoiceEntity>(ZipUtils.Unzip(invoiceData.Blob), null);
|
|
entity.Networks = networks;
|
|
if (entity.Metadata is null)
|
|
{
|
|
if (entity.Version < InvoiceEntity.GreenfieldInvoices_Version)
|
|
{
|
|
entity.MigrateLegacyInvoice();
|
|
}
|
|
else
|
|
{
|
|
entity.Metadata = new InvoiceMetadata();
|
|
}
|
|
}
|
|
return entity;
|
|
}
|
|
public static InvoiceState GetInvoiceState(this InvoiceData invoiceData)
|
|
{
|
|
return new InvoiceState(invoiceData.Status, invoiceData.ExceptionStatus);
|
|
}
|
|
}
|
|
}
|