mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2026-02-23 15:14:49 +01:00
Move back GetCryptoPaymentData logic inside PaymentEntity
This commit is contained in:
@@ -99,32 +99,6 @@ namespace BTCPayServer.Payments.Bitcoin
|
||||
.Select(network => new PaymentMethodId(network.CryptoCode, PaymentTypes.BTCLike));
|
||||
}
|
||||
|
||||
public override CryptoPaymentData GetCryptoPaymentData(PaymentEntity paymentEntity)
|
||||
{
|
||||
#pragma warning disable CS0618
|
||||
|
||||
BitcoinLikePaymentData paymentData;
|
||||
if (string.IsNullOrEmpty(paymentEntity.CryptoPaymentDataType))
|
||||
{
|
||||
// For invoices created when CryptoPaymentDataType was not existing, we just consider that it is a RBFed payment for safety
|
||||
paymentData = new BitcoinLikePaymentData();
|
||||
paymentData.Outpoint = paymentEntity.Outpoint;
|
||||
paymentData.Output = paymentEntity.Output;
|
||||
paymentData.RBF = true;
|
||||
paymentData.ConfirmationCount = 0;
|
||||
paymentData.Legacy = true;
|
||||
return paymentData;
|
||||
}
|
||||
|
||||
paymentData =
|
||||
JsonConvert.DeserializeObject<BitcoinLikePaymentData>(paymentEntity.CryptoPaymentData);
|
||||
// legacy
|
||||
paymentData.Output = paymentEntity.Output;
|
||||
paymentData.Outpoint = paymentEntity.Outpoint;
|
||||
#pragma warning restore CS0618
|
||||
return paymentData;
|
||||
}
|
||||
|
||||
private string GetPaymentMethodName(BTCPayNetworkBase network)
|
||||
{
|
||||
return network.DisplayName;
|
||||
|
||||
@@ -54,8 +54,6 @@ namespace BTCPayServer.Payments
|
||||
|
||||
IEnumerable<PaymentMethodId> GetSupportedPaymentMethods();
|
||||
|
||||
CryptoPaymentData GetCryptoPaymentData(PaymentEntity paymentEntity);
|
||||
|
||||
ISupportedPaymentMethod DeserializeSupportedPaymentMethod(PaymentMethodId paymentMethodId, JToken value);
|
||||
IPaymentMethodDetails DeserializePaymentMethodDetails(JObject jobj);
|
||||
string GetTransactionLink(PaymentMethodId paymentMethodId, params object[] args);
|
||||
@@ -91,7 +89,6 @@ namespace BTCPayServer.Payments
|
||||
Dictionary<CurrencyPair, Task<RateResult>> rate, Money amount, PaymentMethodId paymentMethodId);
|
||||
|
||||
public abstract IEnumerable<PaymentMethodId> GetSupportedPaymentMethods();
|
||||
public abstract CryptoPaymentData GetCryptoPaymentData(PaymentEntity paymentEntity);
|
||||
|
||||
public abstract ISupportedPaymentMethod DeserializeSupportedPaymentMethod(PaymentMethodId paymentMethodId, JToken value);
|
||||
public abstract IPaymentMethodDetails DeserializePaymentMethodDetails(JObject jobj);
|
||||
|
||||
@@ -167,12 +167,6 @@ namespace BTCPayServer.Payments.Lightning
|
||||
}
|
||||
return "The amount of the invoice is too high to be paid with lightning";
|
||||
}
|
||||
public override CryptoPaymentData GetCryptoPaymentData(PaymentEntity paymentEntity)
|
||||
{
|
||||
#pragma warning disable CS0618
|
||||
return JsonConvert.DeserializeObject<LightningLikePaymentData>(paymentEntity.CryptoPaymentData);
|
||||
#pragma warning restore CS0618
|
||||
}
|
||||
|
||||
public override ISupportedPaymentMethod DeserializeSupportedPaymentMethod(PaymentMethodId paymentMethodId, JToken value)
|
||||
{
|
||||
|
||||
@@ -912,7 +912,36 @@ namespace BTCPayServer.Services.Invoices
|
||||
public CryptoPaymentData GetCryptoPaymentData()
|
||||
{
|
||||
var paymentMethodId = GetPaymentMethodId();
|
||||
return PaymentMethodHandlerDictionary[paymentMethodId].GetCryptoPaymentData(this);
|
||||
if (paymentMethodId.PaymentType == PaymentTypes.LightningLike)
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
return JsonConvert.DeserializeObject<Payments.Lightning.LightningLikePaymentData>(CryptoPaymentData);
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
else
|
||||
{
|
||||
#pragma warning disable CS0618
|
||||
|
||||
BitcoinLikePaymentData paymentData;
|
||||
if (string.IsNullOrEmpty(CryptoPaymentDataType))
|
||||
{
|
||||
// For invoices created when CryptoPaymentDataType was not existing, we just consider that it is a RBFed payment for safety
|
||||
paymentData = new BitcoinLikePaymentData();
|
||||
paymentData.Outpoint = Outpoint;
|
||||
paymentData.Output = Output;
|
||||
paymentData.RBF = true;
|
||||
paymentData.ConfirmationCount = 0;
|
||||
paymentData.Legacy = true;
|
||||
return paymentData;
|
||||
}
|
||||
|
||||
paymentData =
|
||||
JsonConvert.DeserializeObject<BitcoinLikePaymentData>(CryptoPaymentData);
|
||||
// legacy
|
||||
paymentData.Output = Output;
|
||||
paymentData.Outpoint = Outpoint;
|
||||
#pragma warning restore CS0618
|
||||
return paymentData;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public PaymentEntity SetCryptoPaymentData(CryptoPaymentData cryptoPaymentData)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<Version>1.0.3.109</Version>
|
||||
<Version>1.0.3.110</Version>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user