mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 14:34:23 +01:00
* Make Invoice Create Faster And Fix Gap Limit Issue This make address reserve only when user "activate" paymet method in ui. optional setting in store checkout ui. * Fix swagger documentation around Lazy payment methods * fix changed code signature * Add missing GreenField API for activate feature * Fix checkout experience styling for activate feature * Fix issue with Checkout activate button * Make lightning also work with activation * Make sure PreparePaymentModel is still called on payment handlers even when unactivated * Make payment link return empty if not activated * Add activate payment method method to client and add test * remove debugger * add e2e test * Rearranging lazy payments position in UI to be near dependent Unified QR code * fix rebase conflicts * Make lazy payment method mode activate on UI load. Co-authored-by: Kukks <evilkukka@gmail.com> Co-authored-by: rockstardev <rockstardev@users.noreply.github.com> Co-authored-by: Andrew Camilleri <kukks@btcpayserver.org>
72 lines
2.7 KiB
C#
72 lines
2.7 KiB
C#
using System;
|
|
using BTCPayServer.Payments.Lightning;
|
|
using BTCPayServer.Services.Invoices;
|
|
using NBitcoin;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
namespace BTCPayServer.Payments
|
|
{
|
|
public class LightningPaymentType : PaymentType
|
|
{
|
|
public static LightningPaymentType Instance { get; } = new LightningPaymentType();
|
|
|
|
private LightningPaymentType() { }
|
|
|
|
public override string ToPrettyString() => "Off-Chain";
|
|
public override string GetId() => "LightningLike";
|
|
public override string GetBadge() => "⚡";
|
|
public override string ToStringNormalized() => "LightningNetwork";
|
|
|
|
public override CryptoPaymentData DeserializePaymentData(BTCPayNetworkBase network, string str)
|
|
{
|
|
return ((BTCPayNetwork)network)?.ToObject<LightningLikePaymentData>(str);
|
|
}
|
|
|
|
public override string SerializePaymentData(BTCPayNetworkBase network, CryptoPaymentData paymentData)
|
|
{
|
|
return ((BTCPayNetwork)network).ToString(paymentData);
|
|
}
|
|
|
|
public override IPaymentMethodDetails DeserializePaymentMethodDetails(BTCPayNetworkBase network, string str)
|
|
{
|
|
return JsonConvert.DeserializeObject<LightningLikePaymentMethodDetails>(str);
|
|
}
|
|
|
|
public override string SerializePaymentMethodDetails(BTCPayNetworkBase network, IPaymentMethodDetails details)
|
|
{
|
|
return JsonConvert.SerializeObject(details);
|
|
}
|
|
|
|
public override ISupportedPaymentMethod DeserializeSupportedPaymentMethod(BTCPayNetworkBase network,
|
|
JToken value)
|
|
{
|
|
return JsonConvert.DeserializeObject<LightningSupportedPaymentMethod>(value.ToString());
|
|
}
|
|
|
|
public override string GetTransactionLink(BTCPayNetworkBase network, string txId)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
public override string GetPaymentLink(BTCPayNetworkBase network, IPaymentMethodDetails paymentMethodDetails,
|
|
Money cryptoInfoDue, string serverUri)
|
|
{
|
|
if (!paymentMethodDetails.Activated)
|
|
{
|
|
return string.Empty;
|
|
}
|
|
var lnInvoiceTrimmedOfScheme = paymentMethodDetails.GetPaymentDestination().ToLowerInvariant()
|
|
.Replace("lightning:", "", StringComparison.InvariantCultureIgnoreCase);
|
|
|
|
return $"lightning:{lnInvoiceTrimmedOfScheme}";
|
|
}
|
|
|
|
public override string InvoiceViewPaymentPartialName { get; } = "Lightning/ViewLightningLikePaymentData";
|
|
public override bool IsPaymentType(string paymentType)
|
|
{
|
|
return paymentType?.Equals("offchain", StringComparison.InvariantCultureIgnoreCase) is true || base.IsPaymentType(paymentType);
|
|
}
|
|
}
|
|
}
|