mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-03-03 17:36:59 +01:00
Fix layout_cshtml
This commit is contained in:
parent
e3a1eed8b3
commit
6ae6335c6d
7 changed files with 98 additions and 96 deletions
|
@ -22,7 +22,7 @@
|
|||
<PackageReference Include="Hangfire.PostgreSql" Version="1.4.8.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Filter" Version="1.1.2" />
|
||||
<PackageReference Include="NBitcoin" Version="4.0.0.51" />
|
||||
<PackageReference Include="NBitpayClient" Version="1.0.0.13" />
|
||||
<PackageReference Include="NBitpayClient" Version="1.0.0.14" />
|
||||
<PackageReference Include="DBreeze" Version="1.87.0" />
|
||||
<PackageReference Include="NBXplorer.Client" Version="1.0.0.24" />
|
||||
<PackageReference Include="NicolasDorier.CommandLine" Version="1.0.0.1" />
|
||||
|
|
|
@ -98,7 +98,8 @@ namespace BTCPayServer.Controllers
|
|||
entity.MonitoringExpiration = entity.ExpirationTime + TimeSpan.FromMinutes(storeBlob.MonitoringExpiration);
|
||||
entity.OrderId = invoice.OrderId;
|
||||
entity.ServerUrl = serverUrl;
|
||||
entity.FullNotifications = invoice.FullNotifications;
|
||||
entity.FullNotifications = invoice.FullNotifications || invoice.ExtendedNotifications;
|
||||
entity.ExtendedNotifications = invoice.ExtendedNotifications;
|
||||
entity.NotificationURL = notificationUri?.AbsoluteUri;
|
||||
entity.BuyerInformation = Map<Invoice, BuyerInformation>(invoice);
|
||||
//Another way of passing buyer info to support
|
||||
|
|
|
@ -223,10 +223,9 @@ namespace BTCPayServer.HostedServices
|
|||
if (invoice.Status == "paid")
|
||||
{
|
||||
var transactions = await GetPaymentsWithTransaction(network, invoice);
|
||||
var chainConfirmedTransactions = transactions.Where(t => t.Confirmations >= 1);
|
||||
if (invoice.SpeedPolicy == SpeedPolicy.HighSpeed)
|
||||
{
|
||||
transactions = transactions.Where(t => !t.Transaction.RBF);
|
||||
transactions = transactions.Where(t => t.Confirmations >= 1 || !t.Transaction.RBF);
|
||||
}
|
||||
else if (invoice.SpeedPolicy == SpeedPolicy.MediumSpeed)
|
||||
{
|
||||
|
@ -237,23 +236,20 @@ namespace BTCPayServer.HostedServices
|
|||
transactions = transactions.Where(t => t.Confirmations >= 6);
|
||||
}
|
||||
|
||||
var chainTotalConfirmed = chainConfirmedTransactions.Select(t => t.Payment.GetValue(cryptoDataAll, cryptoData.CryptoCode)).Sum();
|
||||
var totalConfirmed = transactions.Select(t => t.Payment.GetValue(cryptoDataAll, cryptoData.CryptoCode)).Sum();
|
||||
|
||||
if (// Is after the monitoring deadline
|
||||
(invoice.MonitoringExpiration < DateTimeOffset.UtcNow)
|
||||
&&
|
||||
// And not enough amount confirmed
|
||||
(chainTotalConfirmed < accounting.TotalDue))
|
||||
(totalConfirmed < accounting.TotalDue))
|
||||
{
|
||||
await _InvoiceRepository.UnaffectAddress(invoice.Id);
|
||||
context.Events.Add(new InvoiceStatusChangedEvent(invoice, "invalid"));
|
||||
invoice.Status = "invalid";
|
||||
context.MarkDirty();
|
||||
}
|
||||
else
|
||||
{
|
||||
var totalConfirmed = transactions.Select(t => t.Payment.GetValue(cryptoDataAll, cryptoData.CryptoCode)).Sum();
|
||||
if (totalConfirmed >= accounting.TotalDue)
|
||||
else if (totalConfirmed >= accounting.TotalDue)
|
||||
{
|
||||
await _InvoiceRepository.UnaffectAddress(invoice.Id);
|
||||
context.Events.Add(new InvoiceStatusChangedEvent(invoice, "confirmed"));
|
||||
|
@ -261,7 +257,6 @@ namespace BTCPayServer.HostedServices
|
|||
context.MarkDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (invoice.Status == "confirmed")
|
||||
{
|
||||
|
|
|
@ -20,14 +20,40 @@ namespace BTCPayServer.HostedServices
|
|||
Ready
|
||||
}
|
||||
|
||||
public class NBXplorerDashboard
|
||||
{
|
||||
public class NBXplorerSummary
|
||||
{
|
||||
public BTCPayNetwork Network { get; set; }
|
||||
public NBXplorerState State { get; set; }
|
||||
public StatusResult Status { get; set; }
|
||||
}
|
||||
ConcurrentDictionary<string, NBXplorerSummary> _Summaries = new ConcurrentDictionary<string, NBXplorerSummary>();
|
||||
public void Publish(BTCPayNetwork network, NBXplorerState state, StatusResult status)
|
||||
{
|
||||
var summary = new NBXplorerSummary() { Network = network, State = state, Status = status };
|
||||
_Summaries.AddOrUpdate(network.CryptoCode, summary, (k, v) => summary);
|
||||
}
|
||||
|
||||
public bool IsFullySynched()
|
||||
{
|
||||
return _Summaries.All(s => s.Value.Status != null && s.Value.Status.IsFullySynched);
|
||||
}
|
||||
|
||||
public IEnumerable<NBXplorerSummary> GetAll()
|
||||
{
|
||||
return _Summaries.Values;
|
||||
}
|
||||
}
|
||||
|
||||
public class NBXplorerWaiters : IHostedService
|
||||
{
|
||||
List<NBXplorerWaiter> _Waiters = new List<NBXplorerWaiter>();
|
||||
public NBXplorerWaiters(ExplorerClientProvider explorerClientProvider, EventAggregator eventAggregator)
|
||||
public NBXplorerWaiters(NBXplorerDashboard dashboard, ExplorerClientProvider explorerClientProvider, EventAggregator eventAggregator)
|
||||
{
|
||||
foreach (var explorer in explorerClientProvider.GetAll())
|
||||
{
|
||||
_Waiters.Add(new NBXplorerWaiter(explorer.Item1, explorer.Item2, eventAggregator));
|
||||
_Waiters.Add(new NBXplorerWaiter(dashboard, explorer.Item1, explorer.Item2, eventAggregator));
|
||||
}
|
||||
}
|
||||
public Task StartAsync(CancellationToken cancellationToken)
|
||||
|
@ -44,13 +70,15 @@ namespace BTCPayServer.HostedServices
|
|||
public class NBXplorerWaiter : IHostedService
|
||||
{
|
||||
|
||||
public NBXplorerWaiter(BTCPayNetwork network, ExplorerClient client, EventAggregator aggregator)
|
||||
public NBXplorerWaiter(NBXplorerDashboard dashboard, BTCPayNetwork network, ExplorerClient client, EventAggregator aggregator)
|
||||
{
|
||||
_Network = network;
|
||||
_Client = client;
|
||||
_Aggregator = aggregator;
|
||||
_Dashboard = dashboard;
|
||||
}
|
||||
|
||||
NBXplorerDashboard _Dashboard;
|
||||
BTCPayNetwork _Network;
|
||||
EventAggregator _Aggregator;
|
||||
ExplorerClient _Client;
|
||||
|
@ -134,7 +162,6 @@ namespace BTCPayServer.HostedServices
|
|||
break;
|
||||
}
|
||||
|
||||
LastStatus = status;
|
||||
if (oldState != State)
|
||||
{
|
||||
if (State == NBXplorerState.Synching)
|
||||
|
@ -147,6 +174,7 @@ namespace BTCPayServer.HostedServices
|
|||
}
|
||||
_Aggregator.Publish(new NBXplorerStateChangedEvent(_Network, oldState, State));
|
||||
}
|
||||
_Dashboard.Publish(_Network, State, status);
|
||||
return oldState != State;
|
||||
}
|
||||
|
||||
|
@ -181,8 +209,6 @@ namespace BTCPayServer.HostedServices
|
|||
|
||||
public NBXplorerState State { get; private set; }
|
||||
|
||||
public StatusResult LastStatus { get; private set; }
|
||||
|
||||
public Task StopAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
_Timer.Dispose();
|
||||
|
|
|
@ -132,6 +132,7 @@ namespace BTCPayServer.Hosting
|
|||
return new BTCPayNetworkProvider(opts.Network);
|
||||
});
|
||||
|
||||
services.TryAddSingleton<NBXplorerDashboard>();
|
||||
services.TryAddSingleton<StoreRepository>();
|
||||
services.TryAddSingleton<BTCPayWallet>();
|
||||
services.TryAddSingleton<CurrencyNameTable>();
|
||||
|
|
|
@ -282,6 +282,7 @@ namespace BTCPayServer.Services.Invoices
|
|||
get;
|
||||
set;
|
||||
}
|
||||
public bool ExtendedNotifications { get; set; }
|
||||
|
||||
public bool IsExpired()
|
||||
{
|
||||
|
|
|
@ -2,13 +2,7 @@
|
|||
@inject UserManager<ApplicationUser> UserManager
|
||||
@inject RoleManager<IdentityRole> RoleManager
|
||||
@inject BTCPayServer.Services.BTCPayServerEnvironment env
|
||||
@inject BTCPayServer.NBXplorerWaiterAccessor waiter
|
||||
|
||||
@{
|
||||
var waiterState = waiter.Instance.State;
|
||||
var lastStatus = waiter.Instance.LastStatus;
|
||||
var verificationProgress = waiter.Instance.LastStatus?.BitcoinStatus != null ? waiter.Instance.LastStatus.BitcoinStatus.VerificationProgress * 100 : 0.0;
|
||||
}
|
||||
@inject BTCPayServer.HostedServices.NBXplorerDashboard dashboard
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
@ -87,31 +81,7 @@
|
|||
@RenderBody()
|
||||
|
||||
|
||||
@if(waiterState == NBXplorerState.NotConnected)
|
||||
{
|
||||
<!-- Modal -->
|
||||
<div id="no-nbxplorer" class="modal fade" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
|
||||
<!-- Modal content-->
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">NBXplorer is not running</h4>
|
||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>NBXplorer is not running, BTCPay Server will not be functional.</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if(waiterState == NBXplorerState.Synching && lastStatus.BitcoinStatus != null)
|
||||
@if(!dashboard.IsFullySynched())
|
||||
{
|
||||
<!-- Modal -->
|
||||
<div id="synching-modal" class="modal fade" role="dialog">
|
||||
|
@ -120,41 +90,57 @@
|
|||
<!-- Modal content-->
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">Bitcoin Core node is synching...</h4>
|
||||
<h4 class="modal-title">Your nodes are synching...</h4>
|
||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>Bitcoin Core is synching (Chain height: @lastStatus.BitcoinStatus.Headers, Block height: @lastStatus.BitcoinStatus.Blocks)</p>
|
||||
<p>BTCPay Server will not work correctly until it is over.</p>
|
||||
<p>
|
||||
Some of your nodes are still synching...<br />
|
||||
BTCPay Server will not work correctly until it is over.
|
||||
</p>
|
||||
@foreach(var line in dashboard.GetAll())
|
||||
{
|
||||
<h4>@line.Network.CryptoCode</h4>
|
||||
@if(line.Status == null)
|
||||
{
|
||||
<p>NBXplorer is offline</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<ul>
|
||||
<li>NBXplorer headers height: @line.Status.ChainHeight</li>
|
||||
@if(line.Status.BitcoinStatus == null)
|
||||
{
|
||||
if(line.State == BTCPayServer.HostedServices.NBXplorerState.Synching)
|
||||
{
|
||||
<li>The node is starting...</li>
|
||||
}
|
||||
else
|
||||
{
|
||||
<li>The node is offline</li>
|
||||
}
|
||||
}
|
||||
else if(line.Status.BitcoinStatus.IsSynched)
|
||||
{
|
||||
<li>The node is synched</li>
|
||||
}
|
||||
else
|
||||
{
|
||||
<li>Node headers height: @line.Status.BitcoinStatus.Headers</li>
|
||||
<li>Validated blocks: @line.Status.BitcoinStatus.Blocks</li>
|
||||
}
|
||||
</ul>
|
||||
@if(!line.Status.IsFullySynched && line.Status.BitcoinStatus != null)
|
||||
{
|
||||
<div class="progress">
|
||||
<div class="progress-bar" role="progressbar" aria-valuenow="@((int)verificationProgress)"
|
||||
aria-valuemin="0" aria-valuemax="100" style="width:@((int)verificationProgress)%">
|
||||
@((int)verificationProgress)%
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="progress-bar" role="progressbar" aria-valuenow="@((int)line.Status.BitcoinStatus.VerificationProgress * 100)"
|
||||
aria-valuemin="0" aria-valuemax="100" style="width:@((int)line.Status.BitcoinStatus.VerificationProgress * 100)%">
|
||||
@((int)line.Status.BitcoinStatus.VerificationProgress * 100)%
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
else if(waiterState == NBXplorerState.Synching && lastStatus.BitcoinStatus == null)
|
||||
{
|
||||
<!-- Modal -->
|
||||
<div id="synching-modal" class="modal fade" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
|
||||
<!-- Modal content-->
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">Bitcoin Core node is starting...</h4>
|
||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>Satoshi is rolling the blocks forward... Time to drink a cup of tea?</p>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||
|
@ -182,15 +168,7 @@
|
|||
<!-- Custom scripts for this template -->
|
||||
<script src="~/js/creative.js"></script>
|
||||
|
||||
@if(waiterState == NBXplorerState.NotConnected)
|
||||
{
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
$("#no-nbxplorer").modal();
|
||||
});
|
||||
</script>
|
||||
}
|
||||
@if(waiterState == NBXplorerState.Synching)
|
||||
@if(!dashboard.IsFullySynched())
|
||||
{
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
|
|
Loading…
Add table
Reference in a new issue