btcpayserver/BTCPayServer/Views/Shared/Lightning/ViewLightningLikePaymentData.cshtml
2023-05-11 10:35:51 +02:00

63 lines
2.6 KiB
Text

@using BTCPayServer.Payments
@using BTCPayServer.Payments.Lightning
@using BTCPayServer.Services
@using BTCPayServer.Components.TruncateCenter
@using BTCPayServer.Lightning
@inject DisplayFormatter DisplayFormatter
@model IEnumerable<BTCPayServer.Services.Invoices.PaymentEntity>
@{
var payments = Model
.Where(entity => entity.GetPaymentMethodId()?.PaymentType == LightningPaymentType.Instance ||
entity.GetPaymentMethodId()?.PaymentType == LNURLPayPaymentType.Instance)
.Select(payment => payment.GetCryptoPaymentData() is LightningLikePaymentData offChainPaymentData
? new OffChainPaymentViewModel
{
Crypto = payment.Network.CryptoCode,
BOLT11 = offChainPaymentData.BOLT11,
Type = payment.GetCryptoPaymentData().GetPaymentType(),
PaymentProof = offChainPaymentData.Preimage?.ToString(),
Amount = DisplayFormatter.Currency(offChainPaymentData.Amount.ToDecimal(LightMoneyUnit.BTC), payment.Network.CryptoCode)
}
: null)
.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 class="thead-inverse">
<tr>
<th class="w-75px">Crypto</th>
<th class="w-100px">Type</th>
<th class="w-175px">Destination</th>
<th class="text-nowrap">Payment Proof</th>
<th class="w-150px text-end">Amount</th>
</tr>
</thead>
<tbody>
@foreach (var payment in payments)
{
<tr>
<td>@payment.Crypto</td>
<td>@payment.Type.ToPrettyString()</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>@payment.Amount</span>
</td>
</tr>
}
</tbody>
</table>
</div>
</section>
}