mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-27 16:44:53 +01:00
* (bug) treat xmr wallet directory as required The wallet directory configuration setting is required because the `UIMoneroLikeStoreController`'s `GetMoneroLikePaymentMethodViewModel` method checks if the wallet file exists, and to do that in needs the directory. * (feat) xmr settlement thresholds Adds the ability to select zero, 1, 10, or a custom number of confirmations as the payment settlement threshold. * (review) fix validation message not showing --------- Co-authored-by: Henry Hollingworth <henry.hollingworth@alcoa.com>
89 lines
2.6 KiB
C#
89 lines
2.6 KiB
C#
#if ALTCOINS
|
|
using BTCPayServer.Client.Models;
|
|
using BTCPayServer.Payments;
|
|
using BTCPayServer.Plugins.Altcoins;
|
|
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 long? InvoiceSettledConfirmationThreshold { 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;
|
|
}
|
|
|
|
if (InvoiceSettledConfirmationThreshold.HasValue)
|
|
{
|
|
return ConfirmationCount >= InvoiceSettledConfirmationThreshold;
|
|
}
|
|
|
|
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
|