From a3255921062dc339fb7622d57879d30fcd8bc021 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Sat, 5 May 2018 01:00:19 +0900 Subject: [PATCH 1/4] Can match exact reverse --- BTCPayServer/Rating/RateRules.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/BTCPayServer/Rating/RateRules.cs b/BTCPayServer/Rating/RateRules.cs index b7c7f20bc..617a24447 100644 --- a/BTCPayServer/Rating/RateRules.cs +++ b/BTCPayServer/Rating/RateRules.cs @@ -149,9 +149,10 @@ namespace BTCPayServer.Rating (Pair: p, Priority: 0, Inverse: false), (Pair: new CurrencyPair(p.Left, "X"), Priority: 1, Inverse: false), (Pair: new CurrencyPair("X", p.Right), Priority: 1, Inverse: false), - (Pair: new CurrencyPair(invP.Left, "X"), Priority: 2, Inverse: true), - (Pair: new CurrencyPair("X", invP.Right), Priority: 2, Inverse: true), - (Pair: new CurrencyPair("X", "X"), Priority: 3, Inverse: false) + (Pair: invP, Priority: 2, Inverse: true), + (Pair: new CurrencyPair(invP.Left, "X"), Priority: 3, Inverse: true), + (Pair: new CurrencyPair("X", invP.Right), Priority: 3, Inverse: true), + (Pair: new CurrencyPair("X", "X"), Priority: 4, Inverse: false) }) { if (ruleList.ExpressionsByPair.TryGetValue(pair.Pair, out var expression)) From 322574511534f3ca5650c33941cdceae6b7c12f4 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Sat, 5 May 2018 01:01:39 +0900 Subject: [PATCH 2/4] bump --- BTCPayServer/BTCPayServer.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BTCPayServer/BTCPayServer.csproj b/BTCPayServer/BTCPayServer.csproj index 2b36f82d5..ce03eb9b7 100644 --- a/BTCPayServer/BTCPayServer.csproj +++ b/BTCPayServer/BTCPayServer.csproj @@ -2,7 +2,7 @@ Exe netcoreapp2.0 - 1.0.2.3 + 1.0.2.4 NU1701,CA1816,CA1308,CA1810,CA2208 From 4458e63c1a6a03302bd194a967c456b5a3f6cb4b Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Sat, 5 May 2018 01:34:08 +0900 Subject: [PATCH 3/4] Break default DOGE rules in two, add some documentation about inverses --- BTCPayServer/BTCPayNetworkProvider.Dogecoin.cs | 6 +++++- BTCPayServer/Views/Stores/Rates.cshtml | 14 +++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/BTCPayServer/BTCPayNetworkProvider.Dogecoin.cs b/BTCPayServer/BTCPayNetworkProvider.Dogecoin.cs index 9fbff33a9..e12ceaff7 100644 --- a/BTCPayServer/BTCPayNetworkProvider.Dogecoin.cs +++ b/BTCPayServer/BTCPayNetworkProvider.Dogecoin.cs @@ -20,7 +20,11 @@ namespace BTCPayServer NBitcoinNetwork = nbxplorerNetwork.NBitcoinNetwork, NBXplorerNetwork = nbxplorerNetwork, UriScheme = "dogecoin", - DefaultRateRules = new[] { "DOGE_X = bittrex(DOGE_BTC) * BTC_X" }, + DefaultRateRules = new[] + { + "DOGE_X = DOGE_BTC * BTC_X", + "DOGE_BTC = bittrex(DOGE_BTC)" + }, CryptoImagePath = "imlegacy/dogecoin.png", DefaultSettings = BTCPayDefaultSettings.GetDefaultSettings(NetworkType), CoinType = NetworkType == NetworkType.Mainnet ? new KeyPath("3'") : new KeyPath("1'") diff --git a/BTCPayServer/Views/Stores/Rates.cshtml b/BTCPayServer/Views/Stores/Rates.cshtml index 4aca36b81..9a2f7efbc 100644 --- a/BTCPayServer/Views/Stores/Rates.cshtml +++ b/BTCPayServer/Views/Stores/Rates.cshtml @@ -93,7 +93,19 @@ X_X = gdax(X_X); -

With DOGE_USD will be expanded to bittrex(DOGE_BTC) * gdax(BTC_USD). And DOGE_CAD will be expanded to bittrex(DOGE_BTC) * quadrigacx(BTC_CAD)

+

With DOGE_USD will be expanded to bittrex(DOGE_BTC) * gdax(BTC_USD). And DOGE_CAD will be expanded to bittrex(DOGE_BTC) * quadrigacx(BTC_CAD).
+ However, we advise you to write it that way to increase coverage so that DOGE_BTC is also supported:

+
+                        
+                            DOGE_X = DOGE_BTC * BTC_X
+                            DOGE_BTC = bittrex(DOGE_BTC)
+                            X_CAD = quadrigacx(X_CAD);
+                            X_X = gdax(X_X);
+                        
+                    
+

It is worth noting that the inverses of those pairs are automatically supported as well.
+ It means that the rule USD_DOGE = 1 / DOGE_USD implicitely exists.

+
From efdc99b9d137dd53f071c407463b1136bebd2303 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Sat, 5 May 2018 01:42:42 +0900 Subject: [PATCH 4/4] Do not spam the logs about failed mail --- BTCPayServer/Controllers/ServerController.cs | 5 +---- BTCPayServer/Services/Mails/EmailSender.cs | 8 ++++---- BTCPayServer/Services/Mails/EmailSettings.cs | 12 ++++++++++++ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/BTCPayServer/Controllers/ServerController.cs b/BTCPayServer/Controllers/ServerController.cs index 54ec88151..2c10440d0 100644 --- a/BTCPayServer/Controllers/ServerController.cs +++ b/BTCPayServer/Controllers/ServerController.cs @@ -243,10 +243,7 @@ namespace BTCPayServer.Controllers { try { - if(string.IsNullOrWhiteSpace(model.Settings.From) - || string.IsNullOrWhiteSpace(model.TestEmail) - || string.IsNullOrWhiteSpace(model.Settings.Login) - || string.IsNullOrWhiteSpace(model.Settings.Server)) + if(!model.Settings.IsComplete()) { model.StatusMessage = "Error: Required fields missing"; return View(model); diff --git a/BTCPayServer/Services/Mails/EmailSender.cs b/BTCPayServer/Services/Mails/EmailSender.cs index c97c2cbbd..2e51db317 100644 --- a/BTCPayServer/Services/Mails/EmailSender.cs +++ b/BTCPayServer/Services/Mails/EmailSender.cs @@ -24,8 +24,8 @@ namespace BTCPayServer.Services.Mails } public async Task SendEmailAsync(string email, string subject, string message) { - var settings = await _Repository.GetSettingAsync(); - if (settings == null) + var settings = await _Repository.GetSettingAsync() ?? new EmailSettings(); + if (!settings.IsComplete()) { Logs.Configuration.LogWarning("Should have sent email, but email settings are not configured"); return; @@ -36,8 +36,8 @@ namespace BTCPayServer.Services.Mails public async Task SendMailCore(string email, string subject, string message) { - var settings = await _Repository.GetSettingAsync(); - if (settings == null) + var settings = await _Repository.GetSettingAsync() ?? new EmailSettings(); + if (!settings.IsComplete()) throw new InvalidOperationException("Email settings not configured"); var smtp = settings.CreateSmtpClient(); MailMessage mail = new MailMessage(settings.From, email, subject, message); diff --git a/BTCPayServer/Services/Mails/EmailSettings.cs b/BTCPayServer/Services/Mails/EmailSettings.cs index 22840cc36..93b062eec 100644 --- a/BTCPayServer/Services/Mails/EmailSettings.cs +++ b/BTCPayServer/Services/Mails/EmailSettings.cs @@ -40,6 +40,18 @@ namespace BTCPayServer.Services.Mails get; set; } + public bool IsComplete() + { + SmtpClient smtp = null; + try + { + smtp = CreateSmtpClient(); + return true; + } + catch { } + return false; + } + public SmtpClient CreateSmtpClient() { SmtpClient client = new SmtpClient(Server, Port.Value);