Liquid & Liquid Assets Support (#1118)

This commit is contained in:
Andrew Camilleri
2019-12-24 08:20:44 +01:00
committed by Nicolas Dorier
parent 0485a9178d
commit 4d7480db15
51 changed files with 546 additions and 111 deletions

View File

@@ -33,23 +33,24 @@ namespace BTCPayServer
Logs.Configuration.LogInformation($"{setting.CryptoCode}: Cookie file is {(setting.CookieFile ?? "not set")}");
if (setting.ExplorerUri != null)
{
_Clients.TryAdd(setting.CryptoCode, CreateExplorerClient(httpClientFactory.CreateClient(nameof(ExplorerClientProvider)), _NetworkProviders.GetNetwork<BTCPayNetwork>(setting.CryptoCode), setting.ExplorerUri, setting.CookieFile));
_Clients.TryAdd(setting.CryptoCode.ToUpperInvariant(), CreateExplorerClient(httpClientFactory.CreateClient(nameof(ExplorerClientProvider)), _NetworkProviders.GetNetwork<BTCPayNetwork>(setting.CryptoCode), setting.ExplorerUri, setting.CookieFile));
}
}
}
private static ExplorerClient CreateExplorerClient(HttpClient httpClient, BTCPayNetwork n, Uri uri, string cookieFile)
{
var explorer = new ExplorerClient(n.NBXplorerNetwork, uri);
var explorer = n.NBXplorerNetwork.CreateExplorerClient(uri);
explorer.SetClient(httpClient);
if (cookieFile == null)
{
Logs.Configuration.LogWarning($"{n.CryptoCode}: Not using cookie authentication");
Logs.Configuration.LogWarning($"{explorer.CryptoCode}: Not using cookie authentication");
explorer.SetNoAuth();
}
if(!explorer.SetCookieAuth(cookieFile))
{
Logs.Configuration.LogWarning($"{n.CryptoCode}: Using cookie auth against NBXplorer, but {cookieFile} is not found");
Logs.Configuration.LogWarning($"{explorer.CryptoCode}: Using cookie auth against NBXplorer, but {cookieFile} is not found");
}
return explorer;
}
@@ -61,7 +62,7 @@ namespace BTCPayServer
var network = _NetworkProviders.GetNetwork<BTCPayNetwork>(cryptoCode);
if (network == null)
return null;
_Clients.TryGetValue(network.CryptoCode, out ExplorerClient client);
_Clients.TryGetValue(network.NBXplorerNetwork.CryptoCode, out ExplorerClient client);
return client;
}
@@ -79,6 +80,7 @@ namespace BTCPayServer
public bool IsAvailable(string cryptoCode)
{
cryptoCode = cryptoCode.ToUpperInvariant();
return _Clients.ContainsKey(cryptoCode) && _Dashboard.IsFullySynched(cryptoCode, out var unused);
}
@@ -87,7 +89,7 @@ namespace BTCPayServer
var network = _NetworkProviders.GetNetwork<BTCPayNetwork>(cryptoCode);
if (network == null)
return null;
if (_Clients.ContainsKey(network.CryptoCode))
if (_Clients.ContainsKey(network.NBXplorerNetwork.CryptoCode))
return network;
return null;
}
@@ -96,7 +98,7 @@ namespace BTCPayServer
{
foreach (var net in _NetworkProviders.GetAll().OfType<BTCPayNetwork>())
{
if (_Clients.TryGetValue(net.CryptoCode, out ExplorerClient explorer))
if (_Clients.TryGetValue(net.NBXplorerNetwork.CryptoCode, out ExplorerClient explorer))
{
yield return (net, explorer);
}