2020-07-29 18:55:28 +09:00
|
|
|
#if ALTCOINS
|
2020-05-23 21:13:18 +02:00
|
|
|
using BTCPayServer.Client.Models;
|
2019-09-30 10:32:43 +02:00
|
|
|
using BTCPayServer.Payments;
|
2023-11-29 18:51:40 +09:00
|
|
|
using BTCPayServer.Plugins.Altcoins;
|
2020-06-28 17:55:27 +09:00
|
|
|
using BTCPayServer.Services.Altcoins.Monero.Utils;
|
2019-09-30 10:32:43 +02:00
|
|
|
using BTCPayServer.Services.Invoices;
|
|
|
|
|
2019-10-02 22:41:53 -05:00
|
|
|
namespace BTCPayServer.Services.Altcoins.Monero.Payments
|
2019-09-30 10:32:43 +02:00
|
|
|
{
|
|
|
|
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; }
|
2024-03-14 17:31:27 +08:00
|
|
|
public long? InvoiceSettledConfirmationThreshold { get; set; }
|
2019-09-30 10:32:43 +02:00
|
|
|
|
|
|
|
public BTCPayNetworkBase Network { get; set; }
|
2022-11-21 19:55:13 +01:00
|
|
|
public long LockTime { get; set; } = 0;
|
2019-09-30 10:32:43 +02:00
|
|
|
|
|
|
|
public string GetPaymentId()
|
|
|
|
{
|
|
|
|
return $"{TransactionId}#{SubaccountIndex}#{SubaddressIndex}";
|
|
|
|
}
|
|
|
|
|
|
|
|
public string[] GetSearchTerms()
|
|
|
|
{
|
2020-06-28 17:55:27 +09:00
|
|
|
return new[] { TransactionId };
|
2019-09-30 10:32:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public decimal GetValue()
|
|
|
|
{
|
2020-06-28 17:55:27 +09:00
|
|
|
return MoneroMoney.Convert(Amount);
|
2019-09-30 10:32:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public bool PaymentCompleted(PaymentEntity entity)
|
|
|
|
{
|
2022-11-21 19:55:13 +01:00
|
|
|
return
|
|
|
|
ConfirmationCount >= LockTime &&
|
|
|
|
ConfirmationCount >= (Network as MoneroLikeSpecificBtcPayNetwork).MaxTrackedConfirmation;
|
2019-09-30 10:32:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public bool PaymentConfirmed(PaymentEntity entity, SpeedPolicy speedPolicy)
|
|
|
|
{
|
2022-11-21 19:55:13 +01:00
|
|
|
if (ConfirmationCount < LockTime)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2024-03-14 17:31:27 +08:00
|
|
|
|
|
|
|
if (InvoiceSettledConfirmationThreshold.HasValue)
|
|
|
|
{
|
|
|
|
return ConfirmationCount >= InvoiceSettledConfirmationThreshold;
|
|
|
|
}
|
|
|
|
|
2019-09-30 10:32:43 +02:00
|
|
|
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;
|
|
|
|
}
|
2023-04-10 16:38:49 +09:00
|
|
|
|
|
|
|
public string GetPaymentProof()
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
2019-09-30 10:32:43 +02:00
|
|
|
}
|
|
|
|
}
|
2020-07-28 22:48:51 +02:00
|
|
|
#endif
|