btcpayserver/BTCPayServer/Services/Altcoins/Monero/Payments/MoneroLikePaymentData.cs
Nicolas Dorier 516efe56f4
Refactor: Dot not make LNURLPaymentMethodDetails depends on BTCPayInvoiceId (#4864)
* Refactor: Dot not make LNURLPaymentMethodDetails depends on BTCPayInvoiceId

* Abstract PaymentProof

* fix bug

* Make the selenium container resolves the btcpay host name
2023-04-10 16:38:49 +09:00

81 lines
2.3 KiB
C#

#if ALTCOINS
using BTCPayServer.Client.Models;
using BTCPayServer.Payments;
using BTCPayServer.Services.Altcoins.Monero.Utils;
using BTCPayServer.Services.Invoices;
namespace BTCPayServer.Services.Altcoins.Monero.Payments
{
public class MoneroLikePaymentData : CryptoPaymentData
{
public long Amount { get; set; }
public string Address { get; set; }
public long SubaddressIndex { get; set; }
public long SubaccountIndex { get; set; }
public long BlockHeight { get; set; }
public long ConfirmationCount { get; set; }
public string TransactionId { get; set; }
public BTCPayNetworkBase Network { get; set; }
public long LockTime { get; set; } = 0;
public string GetPaymentId()
{
return $"{TransactionId}#{SubaccountIndex}#{SubaddressIndex}";
}
public string[] GetSearchTerms()
{
return new[] { TransactionId };
}
public decimal GetValue()
{
return MoneroMoney.Convert(Amount);
}
public bool PaymentCompleted(PaymentEntity entity)
{
return
ConfirmationCount >= LockTime &&
ConfirmationCount >= (Network as MoneroLikeSpecificBtcPayNetwork).MaxTrackedConfirmation;
}
public bool PaymentConfirmed(PaymentEntity entity, SpeedPolicy speedPolicy)
{
if (ConfirmationCount < LockTime)
{
return false;
}
switch (speedPolicy)
{
case SpeedPolicy.HighSpeed:
return ConfirmationCount >= 0;
case SpeedPolicy.MediumSpeed:
return ConfirmationCount >= 1;
case SpeedPolicy.LowMediumSpeed:
return ConfirmationCount >= 2;
case SpeedPolicy.LowSpeed:
return ConfirmationCount >= 6;
default:
return false;
}
}
public PaymentType GetPaymentType()
{
return MoneroPaymentType.Instance;
}
public string GetDestination()
{
return Address;
}
public string GetPaymentProof()
{
return null;
}
}
}
#endif