diff --git a/BTCPayServer/BTCPayServer.csproj b/BTCPayServer/BTCPayServer.csproj
index 92486cf04..4f1a0083e 100644
--- a/BTCPayServer/BTCPayServer.csproj
+++ b/BTCPayServer/BTCPayServer.csproj
@@ -2,7 +2,7 @@
Exe
netcoreapp2.0
- 1.0.1.13
+ 1.0.1.14
diff --git a/BTCPayServer/Controllers/InvoiceController.cs b/BTCPayServer/Controllers/InvoiceController.cs
index e6de51232..797869b13 100644
--- a/BTCPayServer/Controllers/InvoiceController.cs
+++ b/BTCPayServer/Controllers/InvoiceController.cs
@@ -80,9 +80,9 @@ namespace BTCPayServer.Controllers
internal async Task> 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)
- 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
{
InvoiceTime = DateTimeOffset.UtcNow
diff --git a/BTCPayServer/ExplorerClientProvider.cs b/BTCPayServer/ExplorerClientProvider.cs
index 60b6c7a77..b377ac84b 100644
--- a/BTCPayServer/ExplorerClientProvider.cs
+++ b/BTCPayServer/ExplorerClientProvider.cs
@@ -6,6 +6,7 @@ using System.Threading.Tasks;
using BTCPayServer.Configuration;
using BTCPayServer.Logging;
using NBXplorer;
+using BTCPayServer.HostedServices;
namespace BTCPayServer
{
@@ -15,9 +16,10 @@ namespace BTCPayServer
BTCPayServerOptions _Options;
public BTCPayNetworkProvider NetworkProviders => _NetworkProviders;
-
- public ExplorerClientProvider(BTCPayNetworkProvider networkProviders, BTCPayServerOptions options)
+ NBXplorerDashboard _Dashboard;
+ public ExplorerClientProvider(BTCPayNetworkProvider networkProviders, BTCPayServerOptions options, NBXplorerDashboard dashboard)
{
+ _Dashboard = dashboard;
_NetworkProviders = networkProviders;
_Options = options;
@@ -68,6 +70,16 @@ namespace BTCPayServer
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)
{
var network = _NetworkProviders.GetNetwork(cryptoCode);
diff --git a/BTCPayServer/HostedServices/InvoiceWatcher.cs b/BTCPayServer/HostedServices/InvoiceWatcher.cs
index 41c6fdf45..b813726b2 100644
--- a/BTCPayServer/HostedServices/InvoiceWatcher.cs
+++ b/BTCPayServer/HostedServices/InvoiceWatcher.cs
@@ -278,7 +278,7 @@ namespace BTCPayServer.HostedServices
private IEnumerable> GetCoinsPerNetwork(UpdateInvoiceContext context, InvoiceEntity invoice, DerivationStrategy[] 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,
Strategy: d.DerivationStrategyBase))
.Where(d => d.Wallet != null)
@@ -445,8 +445,8 @@ namespace BTCPayServer.HostedServices
leases.Add(_EventAggregator.Subscribe(async b => { await NotifyReceived(b.ScriptPubKey, b.Network); }));
leases.Add(_EventAggregator.Subscribe(async b =>
{
- if(b.Name == "invoice_created")
- {
+ if (b.Name == "invoice_created")
+ {
await Watch(b.InvoiceId);
}
}));
diff --git a/BTCPayServer/HostedServices/NBXplorerWaiter.cs b/BTCPayServer/HostedServices/NBXplorerWaiter.cs
index e25731f91..e6d7faf9c 100644
--- a/BTCPayServer/HostedServices/NBXplorerWaiter.cs
+++ b/BTCPayServer/HostedServices/NBXplorerWaiter.cs
@@ -41,6 +41,11 @@ namespace BTCPayServer.HostedServices
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 GetAll()
{
return _Summaries.Values;
diff --git a/BTCPayServer/Services/Wallets/BTCPayWalletProvider.cs b/BTCPayServer/Services/Wallets/BTCPayWalletProvider.cs
index 0c1971a4f..f62426e98 100644
--- a/BTCPayServer/Services/Wallets/BTCPayWalletProvider.cs
+++ b/BTCPayServer/Services/Wallets/BTCPayWalletProvider.cs
@@ -38,5 +38,10 @@ namespace BTCPayServer.Services.Wallets
return null;
return new BTCPayWallet(client, _TransactionCacheProvider.GetTransactionCache(network), network);
}
+
+ public bool IsAvailable(BTCPayNetwork network)
+ {
+ return _Client.IsAvailable(network);
+ }
}
}