/
ViewBitcoinLikePaymentData.cshtml
104 lines (100 loc) · 4.3 KB
/
ViewBitcoinLikePaymentData.cshtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
@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();
long 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;
<h5>On-Chain Payments</h5>
<table class="table table-hover mt-3 mb-0">
<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" title="More information...">
<vc:icon symbol="info" />
</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()
@if (!string.IsNullOrEmpty(payment.AdditionalInformation))
{
<div>(@payment.AdditionalInformation)</div>
}
</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>
}