mirror of
https://github.com/aljazceru/BTCPayServerPlugins.git
synced 2025-12-17 07:34:24 +01:00
breez fixes
This commit is contained in:
@@ -417,6 +417,11 @@ public class BreezController : Controller
|
||||
var client = _breezService.GetClient(storeId);
|
||||
existing.SetLightningUrl(client);
|
||||
store.SetSupportedPaymentMethod(existing);
|
||||
var lnurl = new LNURLPaySupportedPaymentMethod()
|
||||
{
|
||||
CryptoCode = "BTC",
|
||||
};
|
||||
store.SetSupportedPaymentMethod(lnurl);
|
||||
await _storeRepository.UpdateStore(store);
|
||||
}
|
||||
|
||||
@@ -438,7 +443,6 @@ public class BreezController : Controller
|
||||
}
|
||||
|
||||
viewModel ??= new PaymentsViewModel();
|
||||
|
||||
viewModel.Payments = client.Sdk.ListPayments(new ListPaymentsRequest(null, null, null,null,true,
|
||||
(uint?) viewModel.Skip, (uint?) viewModel.Count));
|
||||
|
||||
|
||||
@@ -114,6 +114,7 @@ public class BreezLightningClient : ILightningClient, IDisposable, EventListener
|
||||
BOLT11 = lnPaymentDetails.data.bolt11,
|
||||
Status = p.status switch
|
||||
{
|
||||
PaymentStatus.PENDING => LightningInvoiceStatus.Unpaid,
|
||||
PaymentStatus.FAILED => LightningInvoiceStatus.Expired,
|
||||
PaymentStatus.COMPLETE => LightningInvoiceStatus.Paid,
|
||||
_ => LightningInvoiceStatus.Unpaid
|
||||
@@ -132,7 +133,7 @@ public class BreezLightningClient : ILightningClient, IDisposable, EventListener
|
||||
{
|
||||
Id = paymentHash.ToString(),
|
||||
PaymentHash = paymentHash.ToString(),
|
||||
Status = LightningInvoiceStatus.Expired,
|
||||
Status = LightningInvoiceStatus.Unpaid
|
||||
};
|
||||
|
||||
return FromPayment(p);
|
||||
@@ -328,7 +329,7 @@ public class BreezLightningClient : ILightningClient, IDisposable, EventListener
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Sdk.Dispose();
|
||||
Sdk.Dispose();
|
||||
Sdk.Dispose();
|
||||
}
|
||||
|
||||
@@ -345,13 +346,14 @@ public class BreezLightningClient : ILightningClient, IDisposable, EventListener
|
||||
breezLightningClient.EventReceived += BreezLightningClientOnEventReceived;
|
||||
}
|
||||
|
||||
private readonly ConcurrentQueue<Task<LightningInvoice>> _invoices = new();
|
||||
private readonly ConcurrentQueue<Payment> _invoices = new();
|
||||
|
||||
private void BreezLightningClientOnEventReceived(object sender, BreezEvent e)
|
||||
{
|
||||
if (e is BreezEvent.InvoicePaid pre)
|
||||
if (e is BreezEvent.InvoicePaid pre && pre.details.payment is {})
|
||||
{
|
||||
_invoices.Enqueue(_breezLightningClient.GetInvoice(pre.details.paymentHash, _cancellationToken));
|
||||
|
||||
_invoices.Enqueue(pre.details.payment);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -364,9 +366,9 @@ public class BreezLightningClient : ILightningClient, IDisposable, EventListener
|
||||
{
|
||||
while (cancellation.IsCancellationRequested is not true)
|
||||
{
|
||||
if (_invoices.TryDequeue(out var task))
|
||||
if (_invoices.TryDequeue(out var payment))
|
||||
{
|
||||
return await task.WithCancellation(cancellation);
|
||||
return _breezLightningClient.FromPayment(payment);
|
||||
}
|
||||
|
||||
await Task.Delay(100, cancellation);
|
||||
|
||||
@@ -160,6 +160,8 @@ public class BreezService:EventHostedServiceBase
|
||||
|
||||
public BreezLightningClient? GetClient(string? storeId)
|
||||
{
|
||||
|
||||
tcs.Task.GetAwaiter().GetResult();
|
||||
if(storeId is null)
|
||||
return null;
|
||||
_clients.TryGetValue(storeId, out var client);
|
||||
@@ -167,6 +169,7 @@ public class BreezService:EventHostedServiceBase
|
||||
}
|
||||
public BreezLightningClient? GetClientByPaymentKey(string? paymentKey)
|
||||
{
|
||||
tcs.Task.GetAwaiter().GetResult();
|
||||
if(paymentKey is null)
|
||||
return null;
|
||||
var match = _settings.FirstOrDefault(pair => pair.Value.PaymentKey == paymentKey).Key;
|
||||
|
||||
@@ -16,5 +16,5 @@ public class BreezSettings
|
||||
|
||||
|
||||
[JsonIgnore]
|
||||
public IFormFile GreenlightCredentials { get; set; }
|
||||
public IFormFile? GreenlightCredentials { get; set; }
|
||||
}
|
||||
@@ -12,24 +12,25 @@
|
||||
string s => s,
|
||||
StoreDashboardViewModel dashboardModel => dashboardModel.StoreId,
|
||||
_ => Context.GetImplicitStoreId()
|
||||
};
|
||||
};
|
||||
var sdk = BreezService.GetClient(storeId)?.Sdk;
|
||||
|
||||
}
|
||||
|
||||
<div class="sticky-header-setup"></div>
|
||||
<div class="sticky-header mb-l">
|
||||
<h2 class="mt-1 mb-2 mb-lg-4">Breez</h2>
|
||||
<nav id="SectionNav">
|
||||
<div class="nav">
|
||||
@if (sdk is not null)
|
||||
{
|
||||
<h2 class="mt-1 mb-2 mb-lg-4">Breez / Greenlight</h2>
|
||||
@if (sdk is not null)
|
||||
{
|
||||
<nav id="SectionNav">
|
||||
<div class="nav">
|
||||
|
||||
<a permission="@Policies.CanViewStoreSettings" asp-action="Info" asp-route-storeId="@storeId" class="nav-link @ViewData.IsActivePage("Breez", null, "Info")">Info</a>
|
||||
<a permission="@Policies.CanViewStoreSettings" asp-action="Payments" asp-route-storeId="@storeId" class="nav-link @ViewData.IsActivePage("Breez", null, "Payments")">Payments</a>
|
||||
<a permission="@Policies.CanCreateInvoice" asp-action="SwapIn" asp-route-storeId="@storeId" class="nav-link @ViewData.IsActivePage("Breez", null, "SwapIn")">Swap In</a>
|
||||
<a permission="@Policies.CanModifyStoreSettings" asp-action="SwapOut" asp-route-storeId="@storeId" class="nav-link @ViewData.IsActivePage("Breez", null, "SwapOut")">Swap Out</a>
|
||||
}
|
||||
<a permission="@Policies.CanModifyStoreSettings" asp-action="Configure" asp-route-storeId="@storeId" class="nav-link @ViewData.IsActivePage("Breez", null, "Configure")">Configuration</a>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<a permission="@Policies.CanModifyStoreSettings" asp-action="Configure" asp-route-storeId="@storeId" class="nav-link @ViewData.IsActivePage("Breez", null, "Configure")">Configuration</a>
|
||||
</div>
|
||||
</nav>
|
||||
}
|
||||
</div>
|
||||
@@ -24,7 +24,17 @@
|
||||
var nodeState = sdk.NodeInfo();
|
||||
var lspInfo = sdk.LspInfo();
|
||||
}
|
||||
<div class="widget store-numbers" id="Breez-Info" style="grid-column-start: 1; grid-column-end: 4;">
|
||||
<style>
|
||||
#Breez-Info{
|
||||
order: -3;
|
||||
}
|
||||
@@media (min-width: 1200px) {
|
||||
#Breez-Info{
|
||||
grid-column-start: 1; grid-column-end: 6; order: -1;
|
||||
}}
|
||||
</style>
|
||||
|
||||
<div class="widget store-numbers" id="Breez-Info" style="">
|
||||
@if (Model is StoreDashboardViewModel)
|
||||
{
|
||||
<header>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
@using Breez.Sdk
|
||||
@using BTCPayServer.Abstractions.Extensions
|
||||
@using BTCPayServer.Lightning
|
||||
@using BTCPayServer.Models.StoreViewModels
|
||||
@using BTCPayServer.Plugins.Breez
|
||||
@@ -20,8 +19,16 @@
|
||||
|
||||
var isDashboard = Model is StoreDashboardViewModel;
|
||||
}
|
||||
|
||||
<div class="@(isDashboard ? "widget store-wallet-balance" : "")" style="@(isDashboard ? "grid-column-start: 4;grid-column-end: 13;" : "")">
|
||||
@if (isDashboard)
|
||||
{
|
||||
<style>
|
||||
@@media (min-width: 1200px) {
|
||||
#breez-payments{
|
||||
grid-column-start: 6; grid-column-end: 13;
|
||||
}}
|
||||
</style>
|
||||
}
|
||||
<div id="breez-payments" class="@(isDashboard ? "widget store-wallet-balance" : "")">
|
||||
@if (isDashboard)
|
||||
{
|
||||
<header>
|
||||
@@ -47,7 +54,7 @@
|
||||
<th class="w-125px">Id</th>
|
||||
<th class="w-125px">Timestamp</th>
|
||||
<th class="w-125px">Type</th>
|
||||
<th class="w-125px">Amount</th>a
|
||||
<th class="w-125px">Amount</th>
|
||||
<th class="text-nowrap">Fee</th>
|
||||
<th class="text-nowrap">Status</th>
|
||||
<th class="text-nowrap">Description</th>
|
||||
|
||||
Reference in New Issue
Block a user