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();
int 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;
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())
{
<div class="row">
<div class="col-md-12 invoice-payments">
<h3>On-Chain payments</h3>
<table class="table table-sm table-responsive-lg">
<thead class="thead-inverse">
<tr>
<th>Crypto</th>
2020-08-09 16:00:58 +02:00
<th>Index</th>
2019-08-24 16:10:13 +02:00
<th>Deposit address</th>
2020-02-19 09:35:23 +01:00
<th>Amount</th>
2019-08-24 16:10:13 +02:00
<th>Transaction Id</th>
2021-05-19 04:39:27 +02:00
<th class="text-end">Confirmations</th>
2019-08-24 16:10:13 +02:00
</tr>
</thead>
<tbody>
@foreach (var payment in onchainPayments)
{
2020-05-21 01:50:25 +09:00
<tr style="@(payment.Replaced ? "text-decoration: line-through" : "")">
2019-08-24 16:10:13 +02:00
<td>@payment.Crypto</td>
2020-09-17 11:39:34 +02:00
<td>@(payment.CryptoPaymentData.KeyPath?.ToString()?? "Unknown")</td>
2021-05-19 04:39:27 +02:00
<td style="max-width:300px;" data-bs-toggle="tooltip" class="text-truncate" title="@payment.DepositAddress">@payment.DepositAddress</td>
2020-04-05 22:44:34 +09:00
<td class="payment-value">@payment.CryptoPaymentData.GetValue() @Safe.Raw(payment.AdditionalInformation is string i ? $"<br/>({i})" : string.Empty)</td>
2021-05-19 04:39:27 +02:00
<td style="max-width:300px;" data-bs-toggle="tooltip" class="text-truncate" title="@payment.TransactionId">
2019-08-24 16:10:13 +02:00
<div class="wraptextAuto">
2021-07-06 10:35:42 +02:00
<a href="@payment.TransactionLink" target="_blank" rel="noreferrer noopener">
2019-08-24 16:10:13 +02:00
@payment.TransactionId
</a>
</div>
</td>
2021-05-19 04:39:27 +02:00
<td class="text-end">@payment.Confirmations</td>
2019-08-24 16:10:13 +02:00
</tr>
}
</tbody>
</table>
</div>
</div>
}