mirror of
https://github.com/aljazceru/BTCPayServerPlugins.git
synced 2025-12-17 07:34:24 +01:00
support custodians in prism
This commit is contained in:
@@ -4,12 +4,16 @@
|
||||
@using BTCPayServer.HostedServices
|
||||
@using BTCPayServer.Payments
|
||||
@using BTCPayServer.PayoutProcessors
|
||||
@using BTCPayServer.Services.Custodian.Client
|
||||
@using Microsoft.AspNetCore.Http
|
||||
@using Microsoft.AspNetCore.Routing
|
||||
@using Microsoft.Extensions.Logging
|
||||
@using NBitcoin
|
||||
@using LightningAddressData = BTCPayServer.Data.LightningAddressData
|
||||
@using MarkPayoutRequest = BTCPayServer.HostedServices.MarkPayoutRequest
|
||||
@using System.Collections
|
||||
@using BTCPayServer.Abstractions.Custodians
|
||||
@using BTCPayServer.Abstractions.Extensions
|
||||
@inject IPluginHookService PluginHookService
|
||||
@inject LightningAddressService LightningAddressService
|
||||
@inject PayoutProcessorService PayoutProcessorService
|
||||
@@ -18,6 +22,8 @@
|
||||
@inject LinkGenerator LinkGenerator
|
||||
@inject PullPaymentHostedService PullPaymentHostedService
|
||||
@inject IHttpContextAccessor HttpContextAccessor
|
||||
@inject CustodianAccountRepository CustodianAccountRepository
|
||||
@inject IEnumerable<ICustodian> Custodians
|
||||
@inject ILogger<PrismEdit> Logger
|
||||
@implements IDisposable
|
||||
|
||||
@@ -41,6 +47,10 @@ else
|
||||
{
|
||||
<option value="@destination">@destination</option>
|
||||
}
|
||||
@foreach (var destination in CustodianDestinations)
|
||||
{
|
||||
<option value="@destination.Key">@destination.Value</option>
|
||||
}
|
||||
</datalist>
|
||||
|
||||
|
||||
@@ -205,6 +215,7 @@ else
|
||||
public PaymentMethodId pmichain { get; set; } = new("BTC", PaymentTypes.BTCLike);
|
||||
public bool NoPayoutProcessors { get; set; }
|
||||
|
||||
public Dictionary<string, string> CustodianDestinations { get; set; }
|
||||
private string PrismEditButtonsFilter { get; set; }
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
@@ -236,6 +247,35 @@ else
|
||||
await Task.WhenAll(tasks);
|
||||
Settings = await fetchSettings;
|
||||
Users = await fetchLnAddresses;
|
||||
CustodianDestinations = await FetchCustodians();
|
||||
|
||||
async Task<Dictionary<string, string>> FetchCustodians()
|
||||
{
|
||||
var result = new Dictionary<string, string>();
|
||||
var custodianConfigs = await CustodianAccountRepository.FindByStoreId(StoreId);
|
||||
foreach (var custodianConfig in custodianConfigs)
|
||||
{
|
||||
var custodian = Custodians.GetCustodianByCode(custodianConfig.CustodianCode);
|
||||
if(custodian is not ICanDeposit canDeposit)
|
||||
continue;
|
||||
foreach (var depositablePaymentMethod in canDeposit.GetDepositablePaymentMethods())
|
||||
{
|
||||
var pmi = PaymentMethodId.TryParse(depositablePaymentMethod);
|
||||
if(pmi is null || pmi.CryptoCode != "BTC")
|
||||
continue;
|
||||
|
||||
var custodianDestination = new CustodianDestinationValidator.CustodianDestination()
|
||||
{
|
||||
CustodianId = custodianConfig.Id,
|
||||
PaymentMethod = pmi.ToString()
|
||||
};
|
||||
result.TryAdd(custodianDestination.ToString(), $"{custodianConfig.Name} {pmi.ToPrettyString()} (Custodian)");
|
||||
}
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
EditContext = new EditContext(Settings);
|
||||
MessageStore = new ValidationMessageStore(EditContext);
|
||||
EditContext.OnValidationRequested += Validate;
|
||||
@@ -252,6 +292,7 @@ else
|
||||
await base.OnAfterRenderAsync(firstRender);
|
||||
}
|
||||
|
||||
|
||||
private void FieldChanged(object sender, FieldChangedEventArgs e)
|
||||
{
|
||||
StatusMessageModel = null;
|
||||
|
||||
Reference in New Issue
Block a user