mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 14:34:23 +01:00
Better explanation for the price source
This commit is contained in:
@@ -166,7 +166,7 @@ namespace BTCPayServer.Controllers
|
|||||||
vm.MonitoringExpiration = storeBlob.MonitoringExpiration;
|
vm.MonitoringExpiration = storeBlob.MonitoringExpiration;
|
||||||
vm.InvoiceExpiration = storeBlob.InvoiceExpiration;
|
vm.InvoiceExpiration = storeBlob.InvoiceExpiration;
|
||||||
vm.RateMultiplier = (double)storeBlob.GetRateMultiplier();
|
vm.RateMultiplier = (double)storeBlob.GetRateMultiplier();
|
||||||
vm.PreferredExchange = storeBlob.PreferredExchange;
|
vm.PreferredExchange = storeBlob.PreferredExchange.IsCoinAverage() ? "coinaverage" : storeBlob.PreferredExchange;
|
||||||
return View(vm);
|
return View(vm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,14 +322,14 @@ namespace BTCPayServer.Controllers
|
|||||||
needUpdate = true;
|
needUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(blob.PreferredExchange) && newExchange)
|
if (!blob.PreferredExchange.IsCoinAverage() && newExchange)
|
||||||
{
|
{
|
||||||
using (HttpClient client = new HttpClient())
|
using (HttpClient client = new HttpClient())
|
||||||
{
|
{
|
||||||
var rate = await client.GetAsync(model.RateSource);
|
var rate = await client.GetAsync(model.RateSource);
|
||||||
if (rate.StatusCode == System.Net.HttpStatusCode.NotFound)
|
if (rate.StatusCode == System.Net.HttpStatusCode.NotFound)
|
||||||
{
|
{
|
||||||
ModelState.AddModelError(nameof(model.PreferredExchange), $"Invalid exchange ({model.RateSource})");
|
ModelState.AddModelError(nameof(model.PreferredExchange), $"Unsupported exchange ({model.RateSource})");
|
||||||
return View(model);
|
return View(model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ namespace BTCPayServer.Data
|
|||||||
|
|
||||||
public IRateProvider ApplyRateRules(BTCPayNetwork network, IRateProvider rateProvider)
|
public IRateProvider ApplyRateRules(BTCPayNetwork network, IRateProvider rateProvider)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(PreferredExchange))
|
if (!PreferredExchange.IsCoinAverage())
|
||||||
{
|
{
|
||||||
// If the original rateProvider is a cache, use the same inner provider as fallback, and same memory cache to wrap it all
|
// If the original rateProvider is a cache, use the same inner provider as fallback, and same memory cache to wrap it all
|
||||||
if (rateProvider is CachedRateProvider cachedRateProvider)
|
if (rateProvider is CachedRateProvider cachedRateProvider)
|
||||||
|
|||||||
@@ -31,6 +31,12 @@ namespace BTCPayServer
|
|||||||
return activeProvider != "Microsoft.EntityFrameworkCore.Sqlite";
|
return activeProvider != "Microsoft.EntityFrameworkCore.Sqlite";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool IsCoinAverage(this string exchangeName)
|
||||||
|
{
|
||||||
|
string[] coinAverages = new[] { "coinaverage", "bitcoinaverage" };
|
||||||
|
return String.IsNullOrWhiteSpace(exchangeName) ? true : coinAverages.Contains(exchangeName, StringComparer.OrdinalIgnoreCase) ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
public static async Task<Dictionary<uint256, TransactionResult>> GetTransactions(this BTCPayWallet client, uint256[] hashes, CancellationToken cts = default(CancellationToken))
|
public static async Task<Dictionary<uint256, TransactionResult>> GetTransactions(this BTCPayWallet client, uint256[] hashes, CancellationToken cts = default(CancellationToken))
|
||||||
{
|
{
|
||||||
hashes = hashes.Distinct().ToArray();
|
hashes = hashes.Distinct().ToArray();
|
||||||
|
|||||||
@@ -47,14 +47,14 @@ namespace BTCPayServer.Models.StoreViewModels
|
|||||||
|
|
||||||
public List<StoreViewModel.DerivationScheme> DerivationSchemes { get; set; } = new List<StoreViewModel.DerivationScheme>();
|
public List<StoreViewModel.DerivationScheme> DerivationSchemes { get; set; } = new List<StoreViewModel.DerivationScheme>();
|
||||||
|
|
||||||
[Display(Name = "Preferred exchange rate...")]
|
[Display(Name = "Preferred price source (eg. bitfinex, bitstamp...)")]
|
||||||
public string PreferredExchange { get; set; }
|
public string PreferredExchange { get; set; }
|
||||||
|
|
||||||
public string RateSource
|
public string RateSource
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return string.IsNullOrEmpty(PreferredExchange) ? "https://apiv2.bitcoinaverage.com/indices/global/ticker/short" : $"https://apiv2.bitcoinaverage.com/exchanges/{PreferredExchange}";
|
return PreferredExchange.IsCoinAverage() ? "https://apiv2.bitcoinaverage.com/indices/global/ticker/short" : $"https://apiv2.bitcoinaverage.com/exchanges/{PreferredExchange}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
<input asp-for="PreferredExchange" class="form-control" />
|
<input asp-for="PreferredExchange" class="form-control" />
|
||||||
<span asp-validation-for="PreferredExchange" class="text-danger"></span>
|
<span asp-validation-for="PreferredExchange" class="text-danger"></span>
|
||||||
<p id="PreferredExchangeHelpBlock" class="form-text text-muted">
|
<p id="PreferredExchangeHelpBlock" class="form-text text-muted">
|
||||||
Current rate source is <a href="@Model.RateSource" target="_blank">@Model.RateSource</a>.<small> (using 1 minute cache)</small>
|
Current rate source is <a href="@Model.RateSource" target="_blank">@Model.PreferredExchange</a>.<small> (using 1 minute cache)</small>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|||||||
Reference in New Issue
Block a user