2019-08-24 16:10:13 +02:00
@using System.Globalization
@using BTCPayServer.Payments
@using BTCPayServer.Payments.Bitcoin
@model IEnumerable<BTCPayServer.Services.Invoices.PaymentEntity>
@{
2020-04-05 22:44:34 +09:00
PayjoinInformation payjoinIformation = null;
2020-08-09 14:43:13 +02:00
var onchainPayments = Model.Where(entity => entity.GetPaymentMethodId()?.PaymentType == BitcoinPaymentType.Instance).Select(payment =>
2019-08-24 16:10:13 +02:00
{
var m = new OnchainPaymentViewModel();
var onChainPaymentData = payment.GetCryptoPaymentData() as BitcoinLikePaymentData;
2020-08-09 14:43:13 +02:00
if (onChainPaymentData is null)
{
return null;
}
2019-08-24 16:10:13 +02:00
m.Crypto = payment.GetPaymentMethodId().CryptoCode;
m.DepositAddress = onChainPaymentData.GetDestination();
2022-04-05 14:46:42 +09:00
long confirmationCount = onChainPaymentData.ConfirmationCount;
2019-09-21 16:39:44 +02:00
var network = payment.Network as BTCPayNetwork;
if (confirmationCount >= network.MaxTrackedConfirmation)
2019-08-24 16:10:13 +02:00
{
2019-09-21 16:39:44 +02:00
m.Confirmations = "At least " + (network.MaxTrackedConfirmation);
2019-08-24 16:10:13 +02:00
}
else
{
m.Confirmations = confirmationCount.ToString(CultureInfo.InvariantCulture);
}
2020-04-05 22:44:34 +09:00
if (onChainPaymentData?.PayjoinInformation is PayjoinInformation pj)
{
payjoinIformation = pj;
2020-04-20 01:47:27 +09:00
m.AdditionalInformation = "Original transaction";
2020-04-05 22:44:34 +09:00
}
if (payjoinIformation is PayjoinInformation &&
payjoinIformation.CoinjoinTransactionHash == onChainPaymentData?.Outpoint.Hash)
{
m.AdditionalInformation = "Payjoin transaction";
}
2019-08-24 16:10:13 +02:00
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;
2020-02-19 09:35:23 +01:00
m.CryptoPaymentData = onChainPaymentData;
2021-07-06 00:18:14 +02:00
m.NetworkFee = payment.NetworkFee;
2019-08-24 16:10:13 +02:00
return m;
2020-08-09 14:43:13 +02:00
}).Where(model => model != null);
2019-08-24 16:10:13 +02:00
}
@if (onchainPayments.Any())
{
2021-07-06 00:18:14 +02:00
var hasNetworkFee = onchainPayments.Sum(a => a.NetworkFee) > 0;
2022-06-12 18:47:26 -07:00
<h5>On-Chain Payments</h5>
<table class="table table-hover mt-3 mb-0">
2022-06-03 17:33:22 +02:00
<thead class="thead-inverse">
2022-06-12 18:47:26 -07:00
<tr>
<th>Crypto</th>
<th>Index</th>
<th>Deposit address</th>
<th>Amount</th>
2022-06-03 17:33:22 +02:00
@if (hasNetworkFee)
2019-08-24 16:10:13 +02:00
{
2022-06-12 18:47:26 -07:00
<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>
2022-06-03 17:33:22 +02:00
</a>
2022-06-12 18:47:26 -07:00
</th>
}
<th>Transaction Id</th>
<th class="text-end">Confirmations</th>
2022-06-03 17:33:22 +02:00
</tr>
2022-06-12 18:47:26 -07:00
</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>
}
2022-06-03 17:33:22 +02:00
</tbody>
</table>
2022-06-12 18:47:26 -07:00
2019-08-24 16:10:13 +02:00
}