diff --git a/BTCPayServer.Tests/docker-compose.yml b/BTCPayServer.Tests/docker-compose.yml index fdd3c1c7f..bc235a1dd 100644 --- a/BTCPayServer.Tests/docker-compose.yml +++ b/BTCPayServer.Tests/docker-compose.yml @@ -37,7 +37,7 @@ services: - postgres nbxplorer: - image: nicolasdorier/nbxplorer:1.0.1.3 + image: nicolasdorier/nbxplorer:1.0.1.10 ports: - "32838:32838" expose: diff --git a/BTCPayServer/BTCPayServer.csproj b/BTCPayServer/BTCPayServer.csproj index 8361a30cd..5a076bafc 100644 --- a/BTCPayServer/BTCPayServer.csproj +++ b/BTCPayServer/BTCPayServer.csproj @@ -2,7 +2,7 @@ Exe netcoreapp2.0 - 1.0.1.18 + 1.0.1.19 @@ -21,10 +21,10 @@ - + - + diff --git a/BTCPayServer/Controllers/InvoiceController.cs b/BTCPayServer/Controllers/InvoiceController.cs index 797869b13..573f3de9b 100644 --- a/BTCPayServer/Controllers/InvoiceController.cs +++ b/BTCPayServer/Controllers/InvoiceController.cs @@ -119,7 +119,7 @@ namespace BTCPayServer.Controllers .Select(derivationStrategy => (Wallet: _WalletProvider.GetWallet(derivationStrategy.Network), DerivationStrategy: derivationStrategy.DerivationStrategyBase, Network: derivationStrategy.Network, - RateProvider: _RateProviders.GetRateProvider(derivationStrategy.Network), + RateProvider: _RateProviders.GetRateProvider(derivationStrategy.Network, false), FeeRateProvider: _FeeProviderFactory.CreateFeeProvider(derivationStrategy.Network))) .Where(_ => _.Wallet != null && _.FeeRateProvider != null && @@ -164,7 +164,7 @@ namespace BTCPayServer.Controllers #pragma warning disable CS0618 var btc = _NetworkProvider.BTC; var feeProvider = _FeeProviderFactory.CreateFeeProvider(btc); - var rateProvider = storeBlob.ApplyRateRules(btc, _RateProviders.GetRateProvider(btc)); + var rateProvider = storeBlob.ApplyRateRules(btc, _RateProviders.GetRateProvider(btc, false)); if (feeProvider != null && rateProvider != null) { var gettingFee = feeProvider.GetFeeRateAsync(); diff --git a/BTCPayServer/Controllers/RateController.cs b/BTCPayServer/Controllers/RateController.cs index 3a2170ce6..6205d2f52 100644 --- a/BTCPayServer/Controllers/RateController.cs +++ b/BTCPayServer/Controllers/RateController.cs @@ -49,7 +49,7 @@ namespace BTCPayServer.Controllers var network = _NetworkProvider.GetNetwork(cryptoCode); if (network == null) return NotFound(); - var rateProvider = _RateProviderFactory.GetRateProvider(network); + var rateProvider = _RateProviderFactory.GetRateProvider(network, true); if (rateProvider == null) return NotFound(); diff --git a/BTCPayServer/Controllers/StoresController.cs b/BTCPayServer/Controllers/StoresController.cs index 15f368008..f905973b4 100644 --- a/BTCPayServer/Controllers/StoresController.cs +++ b/BTCPayServer/Controllers/StoresController.cs @@ -258,7 +258,7 @@ namespace BTCPayServer.Controllers for (int i = 0; i < 10; i++) { var address = line.Derive((uint)i); - vm.AddressSamples.Add((line.Path.Derive((uint)i).ToString(), address.ScriptPubKey.GetDestinationAddress(network.NBitcoinNetwork).ToString())); + vm.AddressSamples.Add((DerivationStrategyBase.GetKeyPath(DerivationFeature.Deposit).Derive((uint)i).ToString(), address.ScriptPubKey.GetDestinationAddress(network.NBitcoinNetwork).ToString())); } } catch diff --git a/BTCPayServer/Services/Rates/CachedDefaultRateProviderFactory.cs b/BTCPayServer/Services/Rates/CachedDefaultRateProviderFactory.cs index 44b4dac65..9842e6bc5 100644 --- a/BTCPayServer/Services/Rates/CachedDefaultRateProviderFactory.cs +++ b/BTCPayServer/Services/Rates/CachedDefaultRateProviderFactory.cs @@ -11,6 +11,7 @@ namespace BTCPayServer.Services.Rates { IMemoryCache _Cache; ConcurrentDictionary _Providers = new ConcurrentDictionary(); + ConcurrentDictionary _LongCacheProviders = new ConcurrentDictionary(); public IMemoryCache Cache { @@ -30,9 +31,10 @@ namespace BTCPayServer.Services.Rates public IRateProvider RateProvider { get; set; } public TimeSpan CacheSpan { get; set; } = TimeSpan.FromMinutes(1.0); - public IRateProvider GetRateProvider(BTCPayNetwork network) + public TimeSpan LongCacheSpan { get; set; } = TimeSpan.FromMinutes(15.0); + public IRateProvider GetRateProvider(BTCPayNetwork network, bool longCache) { - return _Providers.GetOrAdd(network.CryptoCode, new CachedRateProvider(network.CryptoCode, RateProvider ?? network.DefaultRateProvider, _Cache) { CacheSpan = CacheSpan }); + return (longCache ? _LongCacheProviders : _Providers).GetOrAdd(network.CryptoCode, new CachedRateProvider(network.CryptoCode, RateProvider ?? network.DefaultRateProvider, _Cache) { CacheSpan = longCache ? LongCacheSpan : CacheSpan }); } } } diff --git a/BTCPayServer/Services/Rates/IRateProviderFactory.cs b/BTCPayServer/Services/Rates/IRateProviderFactory.cs index 55a364668..7c4ef413a 100644 --- a/BTCPayServer/Services/Rates/IRateProviderFactory.cs +++ b/BTCPayServer/Services/Rates/IRateProviderFactory.cs @@ -7,6 +7,6 @@ namespace BTCPayServer.Services.Rates { public interface IRateProviderFactory { - IRateProvider GetRateProvider(BTCPayNetwork network); + IRateProvider GetRateProvider(BTCPayNetwork network, bool longCache); } } diff --git a/BTCPayServer/Services/Rates/MockRateProvider.cs b/BTCPayServer/Services/Rates/MockRateProvider.cs index c735c980a..b2a091724 100644 --- a/BTCPayServer/Services/Rates/MockRateProvider.cs +++ b/BTCPayServer/Services/Rates/MockRateProvider.cs @@ -18,7 +18,7 @@ namespace BTCPayServer.Services.Rates { _Mocks.Add(mock); } - public IRateProvider GetRateProvider(BTCPayNetwork network) + public IRateProvider GetRateProvider(BTCPayNetwork network, bool longCache) { return _Mocks.FirstOrDefault(m => m.CryptoCode == network.CryptoCode); }