mirror of
https://github.com/aljazceru/BTCPayServerPlugins.git
synced 2025-12-17 07:34:24 +01:00
make prism extendable in a different way
This commit is contained in:
@@ -26,7 +26,7 @@ else
|
|||||||
@if (NoPayoutProcessors)
|
@if (NoPayoutProcessors)
|
||||||
{
|
{
|
||||||
<div class="alert alert-warning mb-5" role="alert">
|
<div class="alert alert-warning mb-5" role="alert">
|
||||||
An automated payout procesor for Lightning is required in order to automate prism payouts.
|
An automated payout processor for Lightning is required in order to automate prism payouts.
|
||||||
<a class="alert-link p-0" href="@PayoutProcessorLink">Configure now</a>
|
<a class="alert-link p-0" href="@PayoutProcessorLink">Configure now</a>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@@ -133,6 +133,10 @@ else
|
|||||||
<button type="button" class="btn btn-primary mx-2" id="add-prism" @onclick="CreateNewPrism">Add Prism</button>
|
<button type="button" class="btn btn-primary mx-2" id="add-prism" @onclick="CreateNewPrism">Add Prism</button>
|
||||||
<button type="button" class="btn btn-primary mx-2" id="add-destination" @onclick="AddDestination">Add Destination</button>
|
<button type="button" class="btn btn-primary mx-2" id="add-destination" @onclick="AddDestination">Add Destination</button>
|
||||||
<button type="submit" class="btn btn-primary mx-2">Save</button>
|
<button type="submit" class="btn btn-primary mx-2">Save</button>
|
||||||
|
@if (PrismEditButtonsFilter is not null)
|
||||||
|
{
|
||||||
|
@((MarkupString)PrismEditButtonsFilter)
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</EditForm>
|
</EditForm>
|
||||||
@@ -181,10 +185,12 @@ else
|
|||||||
public PaymentMethodId pmi { get; set; } = new("BTC", LightningPaymentType.Instance);
|
public PaymentMethodId pmi { get; set; } = new("BTC", LightningPaymentType.Instance);
|
||||||
public bool NoPayoutProcessors { get; set; }
|
public bool NoPayoutProcessors { get; set; }
|
||||||
|
|
||||||
|
private string PrismEditButtonsFilter { get; set; }
|
||||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
{
|
{
|
||||||
if (firstRender)
|
if (firstRender)
|
||||||
{
|
{
|
||||||
|
PrismEditButtonsFilter = (await PluginHookService.ApplyFilter("prism-edit-buttons", "")) as string;
|
||||||
PayoutProcessorLink = LinkGenerator.GetUriByAction(HttpContextAccessor.HttpContext, "ConfigureStorePayoutProcessors", "UIPayoutProcessors", new {StoreId});
|
PayoutProcessorLink = LinkGenerator.GetUriByAction(HttpContextAccessor.HttpContext, "ConfigureStorePayoutProcessors", "UIPayoutProcessors", new {StoreId});
|
||||||
LNAddressLink = LinkGenerator.GetUriByAction(HttpContextAccessor.HttpContext, "EditLightningAddress", "UILNURL", new {StoreId});
|
LNAddressLink = LinkGenerator.GetUriByAction(HttpContextAccessor.HttpContext, "EditLightningAddress", "UILNURL", new {StoreId});
|
||||||
PayoutsLink = LinkGenerator.GetUriByAction(HttpContextAccessor.HttpContext, "Payouts", "UIStorePullPayments", new {StoreId, payoutState = PayoutState.AwaitingPayment, paymentMethodId = pmi.ToString()});
|
PayoutsLink = LinkGenerator.GetUriByAction(HttpContextAccessor.HttpContext, "Payouts", "UIStorePullPayments", new {StoreId, payoutState = PayoutState.AwaitingPayment, paymentMethodId = pmi.ToString()});
|
||||||
|
|||||||
@@ -406,36 +406,34 @@ namespace BTCPayServer.Plugins.Prism
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
IClaimDestination dest = null;
|
|
||||||
var dest2 = await _pluginHookService.ApplyFilter("prism-claim-destination", destinationSettings?.Destination??destination);
|
|
||||||
|
|
||||||
dest = dest2 switch
|
|
||||||
{
|
|
||||||
IClaimDestination claimDestination => claimDestination,
|
|
||||||
string destStr when !string.IsNullOrEmpty(destStr) => new LNURLPayClaimDestinaton(destStr),
|
|
||||||
_ => null
|
|
||||||
};
|
|
||||||
|
|
||||||
if (dest is null)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
var pmi = string.IsNullOrEmpty(destinationSettings?.PaymentMethodId) ||
|
var pmi = string.IsNullOrEmpty(destinationSettings?.PaymentMethodId) ||
|
||||||
!PaymentMethodId.TryParse(destinationSettings?.PaymentMethodId, out var pmi2)
|
!PaymentMethodId.TryParse(destinationSettings?.PaymentMethodId, out var pmi2)
|
||||||
? new PaymentMethodId("BTC", LightningPaymentType.Instance)
|
? new PaymentMethodId("BTC", LightningPaymentType.Instance)
|
||||||
: pmi2;
|
: pmi2;
|
||||||
var payout = await _pullPaymentHostedService.Claim(new ClaimRequest()
|
|
||||||
|
var claimRequest = new ClaimRequest()
|
||||||
{
|
{
|
||||||
Destination = dest,
|
Destination = new LNURLPayClaimDestinaton(destinationSettings?.Destination??destination),
|
||||||
PreApprove = true,
|
PreApprove = true,
|
||||||
StoreId = storeId,
|
StoreId = storeId,
|
||||||
PaymentMethodId = pmi,
|
PaymentMethodId = pmi,
|
||||||
Value = Money.Satoshis(payoutAmount).ToDecimal(MoneyUnit.BTC),
|
Value = Money.Satoshis(payoutAmount).ToDecimal(MoneyUnit.BTC),
|
||||||
});
|
Metadata = JObject.FromObject(new
|
||||||
if (payout.Result == ClaimRequest.ClaimResult.Ok)
|
|
||||||
{
|
{
|
||||||
prismSettings.PendingPayouts ??= new();
|
Source = "Prism"
|
||||||
|
})
|
||||||
|
};
|
||||||
|
claimRequest = (await _pluginHookService.ApplyFilter("prism-claim-create", claimRequest)) as ClaimRequest;
|
||||||
|
|
||||||
|
if (claimRequest is null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var payout = await _pullPaymentHostedService.Claim(claimRequest);
|
||||||
|
if (payout.Result != ClaimRequest.ClaimResult.Ok) continue;
|
||||||
|
prismSettings.PendingPayouts ??= new Dictionary<string, PendingPayout>();
|
||||||
prismSettings.PendingPayouts.Add(payout.PayoutData.Id,
|
prismSettings.PendingPayouts.Add(payout.PayoutData.Id,
|
||||||
new PendingPayout(payoutAmount, reserveFee));
|
new PendingPayout(payoutAmount, reserveFee));
|
||||||
var newAmount = amtMsats - (payoutAmount + reserveFee) * 1000;
|
var newAmount = amtMsats - (payoutAmount + reserveFee) * 1000;
|
||||||
@@ -448,7 +446,6 @@ namespace BTCPayServer.Plugins.Prism
|
|||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user