mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 22:14:26 +01:00
Do not crash if some of the altcoins are unavailable
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||||
<Version>1.0.1.13</Version>
|
<Version>1.0.1.14</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Remove="Build\dockerfiles\**" />
|
<Compile Remove="Build\dockerfiles\**" />
|
||||||
|
|||||||
@@ -80,9 +80,9 @@ namespace BTCPayServer.Controllers
|
|||||||
|
|
||||||
internal async Task<DataWrapper<InvoiceResponse>> CreateInvoiceCore(Invoice invoice, StoreData store, string serverUrl)
|
internal async Task<DataWrapper<InvoiceResponse>> CreateInvoiceCore(Invoice invoice, StoreData store, string serverUrl)
|
||||||
{
|
{
|
||||||
var derivationStrategies = store.GetDerivationStrategies(_NetworkProvider).ToList();
|
var derivationStrategies = store.GetDerivationStrategies(_NetworkProvider).Where(c => _ExplorerClients.IsAvailable(c.Network.CryptoCode)).ToList();
|
||||||
if (derivationStrategies.Count == 0)
|
if (derivationStrategies.Count == 0)
|
||||||
throw new BitpayHttpException(400, "This store has not configured the derivation strategy");
|
throw new BitpayHttpException(400, "No derivation strategy are available now for this store");
|
||||||
var entity = new InvoiceEntity
|
var entity = new InvoiceEntity
|
||||||
{
|
{
|
||||||
InvoiceTime = DateTimeOffset.UtcNow
|
InvoiceTime = DateTimeOffset.UtcNow
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
|||||||
using BTCPayServer.Configuration;
|
using BTCPayServer.Configuration;
|
||||||
using BTCPayServer.Logging;
|
using BTCPayServer.Logging;
|
||||||
using NBXplorer;
|
using NBXplorer;
|
||||||
|
using BTCPayServer.HostedServices;
|
||||||
|
|
||||||
namespace BTCPayServer
|
namespace BTCPayServer
|
||||||
{
|
{
|
||||||
@@ -15,9 +16,10 @@ namespace BTCPayServer
|
|||||||
BTCPayServerOptions _Options;
|
BTCPayServerOptions _Options;
|
||||||
|
|
||||||
public BTCPayNetworkProvider NetworkProviders => _NetworkProviders;
|
public BTCPayNetworkProvider NetworkProviders => _NetworkProviders;
|
||||||
|
NBXplorerDashboard _Dashboard;
|
||||||
public ExplorerClientProvider(BTCPayNetworkProvider networkProviders, BTCPayServerOptions options)
|
public ExplorerClientProvider(BTCPayNetworkProvider networkProviders, BTCPayServerOptions options, NBXplorerDashboard dashboard)
|
||||||
{
|
{
|
||||||
|
_Dashboard = dashboard;
|
||||||
_NetworkProviders = networkProviders;
|
_NetworkProviders = networkProviders;
|
||||||
_Options = options;
|
_Options = options;
|
||||||
|
|
||||||
@@ -68,6 +70,16 @@ namespace BTCPayServer
|
|||||||
return GetExplorerClient(network.CryptoCode);
|
return GetExplorerClient(network.CryptoCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsAvailable(BTCPayNetwork network)
|
||||||
|
{
|
||||||
|
return IsAvailable(network.CryptoCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsAvailable(string cryptoCode)
|
||||||
|
{
|
||||||
|
return _Clients.ContainsKey(cryptoCode) && _Dashboard.IsFullySynched(cryptoCode);
|
||||||
|
}
|
||||||
|
|
||||||
public BTCPayNetwork GetNetwork(string cryptoCode)
|
public BTCPayNetwork GetNetwork(string cryptoCode)
|
||||||
{
|
{
|
||||||
var network = _NetworkProviders.GetNetwork(cryptoCode);
|
var network = _NetworkProviders.GetNetwork(cryptoCode);
|
||||||
|
|||||||
@@ -278,7 +278,7 @@ namespace BTCPayServer.HostedServices
|
|||||||
private IEnumerable<Task<NetworkCoins>> GetCoinsPerNetwork(UpdateInvoiceContext context, InvoiceEntity invoice, DerivationStrategy[] strategies)
|
private IEnumerable<Task<NetworkCoins>> GetCoinsPerNetwork(UpdateInvoiceContext context, InvoiceEntity invoice, DerivationStrategy[] strategies)
|
||||||
{
|
{
|
||||||
return strategies
|
return strategies
|
||||||
.Select(d => (Wallet: _WalletProvider.GetWallet(d.Network),
|
.Select(d => (Wallet: _WalletProvider.IsAvailable(d.Network) ? _WalletProvider.GetWallet(d.Network) : null,
|
||||||
Network: d.Network,
|
Network: d.Network,
|
||||||
Strategy: d.DerivationStrategyBase))
|
Strategy: d.DerivationStrategyBase))
|
||||||
.Where(d => d.Wallet != null)
|
.Where(d => d.Wallet != null)
|
||||||
@@ -445,8 +445,8 @@ namespace BTCPayServer.HostedServices
|
|||||||
leases.Add(_EventAggregator.Subscribe<Events.TxOutReceivedEvent>(async b => { await NotifyReceived(b.ScriptPubKey, b.Network); }));
|
leases.Add(_EventAggregator.Subscribe<Events.TxOutReceivedEvent>(async b => { await NotifyReceived(b.ScriptPubKey, b.Network); }));
|
||||||
leases.Add(_EventAggregator.Subscribe<Events.InvoiceEvent>(async b =>
|
leases.Add(_EventAggregator.Subscribe<Events.InvoiceEvent>(async b =>
|
||||||
{
|
{
|
||||||
if(b.Name == "invoice_created")
|
if (b.Name == "invoice_created")
|
||||||
{
|
{
|
||||||
await Watch(b.InvoiceId);
|
await Watch(b.InvoiceId);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -41,6 +41,11 @@ namespace BTCPayServer.HostedServices
|
|||||||
return _Summaries.All(s => s.Value.Status != null && s.Value.Status.IsFullySynched);
|
return _Summaries.All(s => s.Value.Status != null && s.Value.Status.IsFullySynched);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsFullySynched(string cryptoCode)
|
||||||
|
{
|
||||||
|
return _Summaries.Any(s => s.Key.Equals(cryptoCode, StringComparison.OrdinalIgnoreCase) && s.Value.Status != null && s.Value.Status.IsFullySynched);
|
||||||
|
}
|
||||||
|
|
||||||
public IEnumerable<NBXplorerSummary> GetAll()
|
public IEnumerable<NBXplorerSummary> GetAll()
|
||||||
{
|
{
|
||||||
return _Summaries.Values;
|
return _Summaries.Values;
|
||||||
|
|||||||
@@ -38,5 +38,10 @@ namespace BTCPayServer.Services.Wallets
|
|||||||
return null;
|
return null;
|
||||||
return new BTCPayWallet(client, _TransactionCacheProvider.GetTransactionCache(network), network);
|
return new BTCPayWallet(client, _TransactionCacheProvider.GetTransactionCache(network), network);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsAvailable(BTCPayNetwork network)
|
||||||
|
{
|
||||||
|
return _Client.IsAvailable(network);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user