From eb85b1a7b40d298c17975d8784933720dad6129a Mon Sep 17 00:00:00 2001 From: Matt Pazar Date: Wed, 4 Dec 2019 14:21:33 -0600 Subject: [PATCH] Fixing sats exchange rate display Fixed #1147 --- BTCPayServer/Controllers/InvoiceController.UI.cs | 4 ++++ BTCPayServer/Models/InvoicingModels/PaymentModel.cs | 1 - .../Payments/Lightning/LightningLikePaymentHandler.cs | 1 - BTCPayServer/Views/Invoice/Checkout-Body.cshtml | 3 ++- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/BTCPayServer/Controllers/InvoiceController.UI.cs b/BTCPayServer/Controllers/InvoiceController.UI.cs index e5ef213e8..95bc3e728 100644 --- a/BTCPayServer/Controllers/InvoiceController.UI.cs +++ b/BTCPayServer/Controllers/InvoiceController.UI.cs @@ -294,6 +294,10 @@ namespace BTCPayServer.Controllers }; paymentMethodHandler.PreparePaymentModel(model, dto, storeBlob); + if (model.IsLightning && storeBlob.LightningAmountInSatoshi && model.CryptoCode == "Sats") + { + model.Rate = _CurrencyNameTable.DisplayFormatCurrency(paymentMethod.Rate / 100_000_000, paymentMethod.ParentEntity.ProductInformation.Currency); + } model.UISettings = paymentMethodHandler.GetCheckoutUISettings(); model.PaymentMethodId = paymentMethodId.ToString(); var expiration = TimeSpan.FromSeconds(model.ExpirationSeconds); diff --git a/BTCPayServer/Models/InvoicingModels/PaymentModel.cs b/BTCPayServer/Models/InvoicingModels/PaymentModel.cs index 2e25f36e8..280a98e80 100644 --- a/BTCPayServer/Models/InvoicingModels/PaymentModel.cs +++ b/BTCPayServer/Models/InvoicingModels/PaymentModel.cs @@ -78,6 +78,5 @@ namespace BTCPayServer.Models.InvoicingModels public string RootPath { get; set; } public decimal CoinSwitchAmountMarkupPercentage { get; set; } public bool RedirectAutomatically { get; set; } - public string RateBaseAmount { get; set; } = "1"; } } diff --git a/BTCPayServer/Payments/Lightning/LightningLikePaymentHandler.cs b/BTCPayServer/Payments/Lightning/LightningLikePaymentHandler.cs index a6b224e74..ca085c4f6 100644 --- a/BTCPayServer/Payments/Lightning/LightningLikePaymentHandler.cs +++ b/BTCPayServer/Payments/Lightning/LightningLikePaymentHandler.cs @@ -185,7 +185,6 @@ namespace BTCPayServer.Payments.Lightning model.BtcPaid = Money.Parse(model.BtcPaid).ToUnit(MoneyUnit.Satoshi).ToString(CultureInfo.InvariantCulture); model.NetworkFee = new Money(model.NetworkFee, MoneyUnit.BTC).ToUnit(MoneyUnit.Satoshi); model.OrderAmount = Money.Parse(model.OrderAmount).ToUnit(MoneyUnit.Satoshi).ToString(CultureInfo.InvariantCulture); - model.RateBaseAmount = Money.FromUnit(1, MoneyUnit.BTC).Satoshi.ToString(CultureInfo.InvariantCulture); } } public override string GetCryptoImage(PaymentMethodId paymentMethodId) diff --git a/BTCPayServer/Views/Invoice/Checkout-Body.cshtml b/BTCPayServer/Views/Invoice/Checkout-Body.cshtml index b577e27d1..c17c81f70 100644 --- a/BTCPayServer/Views/Invoice/Checkout-Body.cshtml +++ b/BTCPayServer/Views/Invoice/Checkout-Body.cshtml @@ -100,7 +100,8 @@ {{ srvModel.btcDue }} {{ srvModel.cryptoCode }}
- {{srvModel.rateBaseAmount}} {{ srvModel.cryptoCodeSrv }} = {{ srvModel.rate }} + 1 Sat = {{ srvModel.rate }} + 1 {{ srvModel.cryptoCodeSrv }} = {{ srvModel.rate }}