btcpayserver/BTCPayServer/Views/Shared/Lightning/ViewLightningLikePaymentData.cshtml

67 lines
2.3 KiB
Text
Raw Normal View History

@using BTCPayServer.Payments
@using BTCPayServer.Payments.Lightning
@using BTCPayServer.Services
@using BTCPayServer.Components.TruncateCenter
@using BTCPayServer.Lightning
@using BTCPayServer.Services.Invoices
@inject DisplayFormatter DisplayFormatter
@inject PaymentMethodHandlerDictionary handlers
@inject PrettyNameProvider prettyName
@model IEnumerable<BTCPayServer.Services.Invoices.PaymentEntity>
@{
var payments = Model
.Select(payment =>
{
if (handlers.TryGet(payment.PaymentMethodId) is not ILightningPaymentHandler handler)
return null;
var offChainPaymentData = handler.ParsePaymentDetails(payment.Details);
return new OffChainPaymentViewModel
{
Type = prettyName.PrettyName(payment.PaymentMethodId),
BOLT11 = offChainPaymentData.BOLT11,
PaymentProof = offChainPaymentData.Preimage?.ToString(),
Amount = DisplayFormatter.Currency(payment.Value, handler.Network.CryptoCode)
};
})
.Where(model => model != null)
.ToList();
}
@if (payments.Any())
{
<section>
<h5>Off-Chain Payments</h5>
<div class="invoice-payments table-responsive mt-0">
<table class="table table-hover mb-0">
<thead>
<tr>
<th class="w-75px">Type</th>
<th class="w-175px">Destination</th>
<th class="text-nowrap">Payment Proof</th>
<th class="w-150px text-end">Paid</th>
</tr>
</thead>
<tbody>
@foreach (var payment in payments)
{
<tr>
<td>@payment.Type</td>
<td>
<vc:truncate-center text="@payment.BOLT11" classes="truncate-center-id" />
</td>
<td>
<vc:truncate-center text="@payment.PaymentProof" classes="truncate-center-id" />
</td>
<td class="payment-value text-end text-nowrap">
<span data-sensitive class="text-success">@payment.Amount</span>
</td>
</tr>
}
</tbody>
</table>
</div>
</section>
}