btcpayserver/BTCPayServer/Views/Shared/Bitcoin/ViewBitcoinLikePaymentData.cshtml
Dennis Reimann e1ea7200cf
Fix FAQ links
Once more (and for the last time ;)) those linsk changed in btcpayserver/btcpayserver-doc#967
2021-10-04 13:42:31 +02:00

102 lines
4.5 KiB
Plaintext

@using System.Globalization
@using BTCPayServer.Payments
@using BTCPayServer.Payments.Bitcoin
@model IEnumerable<BTCPayServer.Services.Invoices.PaymentEntity>
@{
PayjoinInformation payjoinIformation = null;
var onchainPayments = Model.Where(entity => entity.GetPaymentMethodId()?.PaymentType == BitcoinPaymentType.Instance).Select(payment =>
{
var m = new OnchainPaymentViewModel();
var onChainPaymentData = payment.GetCryptoPaymentData() as BitcoinLikePaymentData;
if (onChainPaymentData is null)
{
return null;
}
m.Crypto = payment.GetPaymentMethodId().CryptoCode;
m.DepositAddress = onChainPaymentData.GetDestination();
int confirmationCount = onChainPaymentData.ConfirmationCount;
var network = payment.Network as BTCPayNetwork;
if (confirmationCount >= network.MaxTrackedConfirmation)
{
m.Confirmations = "At least " + (network.MaxTrackedConfirmation);
}
else
{
m.Confirmations = confirmationCount.ToString(CultureInfo.InvariantCulture);
}
if (onChainPaymentData?.PayjoinInformation is PayjoinInformation pj)
{
payjoinIformation = pj;
m.AdditionalInformation = "Original transaction";
}
if (payjoinIformation is PayjoinInformation &&
payjoinIformation.CoinjoinTransactionHash == onChainPaymentData?.Outpoint.Hash)
{
m.AdditionalInformation = "Payjoin transaction";
}
m.TransactionId = onChainPaymentData.Outpoint.Hash.ToString();
m.ReceivedTime = payment.ReceivedTime;
m.TransactionLink = string.Format(CultureInfo.InvariantCulture, payment.Network.BlockExplorerLink, m.TransactionId);
m.Replaced = !payment.Accounted;
m.CryptoPaymentData = onChainPaymentData;
m.NetworkFee = payment.NetworkFee;
return m;
}).Where(model => model != null);
}
@if (onchainPayments.Any())
{
var hasNetworkFee = onchainPayments.Sum(a => a.NetworkFee) > 0;
<div class="row">
<div class="col-md-12 invoice-payments">
<h3>On-Chain payments</h3>
<table class="table table-hover table-responsive-lg">
<thead class="thead-inverse">
<tr>
<th>Crypto</th>
<th>Index</th>
<th>Deposit address</th>
<th>Amount</th>
@if (hasNetworkFee)
{
<th>
Network Fee
<a href="https://docs.btcpayserver.org/FAQ/Stores/#allow-anyone-to-create-invoice" target="_blank" rel="noreferrer noopener">
<span class="fa fa-question-circle-o text-secondary" title="More information..."></span>
</a>
</th>
}
<th>Transaction Id</th>
<th class="text-end">Confirmations</th>
</tr>
</thead>
<tbody>
@foreach (var payment in onchainPayments)
{
<tr style="@(payment.Replaced ? "text-decoration: line-through" : "")">
<td>@payment.Crypto</td>
<td>@(payment.CryptoPaymentData.KeyPath?.ToString()?? "Unknown")</td>
<td style="max-width:300px;" data-bs-toggle="tooltip" class="text-truncate" title="@payment.DepositAddress">@payment.DepositAddress</td>
<td class="payment-value">@payment.CryptoPaymentData.GetValue() @Safe.Raw(payment.AdditionalInformation is string i ? $"<br/>({i})" : string.Empty)</td>
@if (hasNetworkFee)
{
<td>@payment.NetworkFee</td>
}
<td style="max-width:200px;" data-bs-toggle="tooltip" class="text-truncate" title="@payment.TransactionId">
<div class="wraptextAuto">
<a href="@payment.TransactionLink" target="_blank" rel="noreferrer noopener">
@payment.TransactionId
</a>
</div>
</td>
<td class="text-end">@payment.Confirmations</td>
</tr>
}
</tbody>
</table>
</div>
</div>
}