Support onchain for prism

This commit is contained in:
Kukks
2023-10-31 14:35:47 +01:00
parent 64dc8501ae
commit 49cbc37e49
11 changed files with 382 additions and 105 deletions

View File

@@ -0,0 +1,49 @@
using System;
using System.Threading.Tasks;
using BTCPayServer.Abstractions.Contracts;
using BTCPayServer.Payments;
namespace BTCPayServer.Plugins.Prism;
public class LNURLPrismDestinationValidator : IPluginHookFilter
{
public string Hook => "prism-destination-validate";
public Task<object> Execute(object args)
{
if (args is not string args1) return Task.FromResult(args);
try
{
LNURL.LNURL.ExtractUriFromInternetIdentifier(args1);
return Task.FromResult<object>(new PrismDestinationValidationResult()
{
Success = true,
PaymentMethod = new PaymentMethodId("BTC", PaymentTypes.LNURLPay)
});
}
catch (Exception e)
{
try
{
LNURL.LNURL.Parse(args1, out var tag);
return Task.FromResult<object>(new PrismDestinationValidationResult()
{
Success = true,
PaymentMethod = new PaymentMethodId("BTC", PaymentTypes.LNURLPay)
});
}
catch (Exception)
{
}
}
return Task.FromResult(args);
}
}
public class PrismDestinationValidationResult
{
public bool Success { get; set; }
public PaymentMethodId PaymentMethod { get; set; }
}