mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-19 18:11:36 +01:00
34 lines
1.5 KiB
C#
34 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace BTCPayServer.Data
|
|
{
|
|
public static class HistoricalAddressInvoiceDataExtensions
|
|
{
|
|
#pragma warning disable CS0618
|
|
public static Payments.PaymentMethodId GetPaymentMethodId(this HistoricalAddressInvoiceData historicalAddressInvoiceData)
|
|
{
|
|
return string.IsNullOrEmpty(historicalAddressInvoiceData.CryptoCode) ? new Payments.PaymentMethodId("BTC", Payments.PaymentTypes.BTCLike)
|
|
: Payments.PaymentMethodId.Parse(historicalAddressInvoiceData.CryptoCode);
|
|
}
|
|
public static string GetAddress(this HistoricalAddressInvoiceData historicalAddressInvoiceData)
|
|
{
|
|
if (historicalAddressInvoiceData.Address == null)
|
|
return null;
|
|
var index = historicalAddressInvoiceData.Address.IndexOf("#", StringComparison.InvariantCulture);
|
|
if (index == -1)
|
|
return historicalAddressInvoiceData.Address;
|
|
return historicalAddressInvoiceData.Address.Substring(0, index);
|
|
}
|
|
public static HistoricalAddressInvoiceData SetAddress(this HistoricalAddressInvoiceData historicalAddressInvoiceData, string depositAddress, string cryptoCode)
|
|
{
|
|
historicalAddressInvoiceData.Address = depositAddress + "#" + cryptoCode;
|
|
historicalAddressInvoiceData.CryptoCode = cryptoCode;
|
|
return historicalAddressInvoiceData;
|
|
}
|
|
#pragma warning restore CS0618
|
|
}
|
|
}
|