From 6eb7bbf853aed12cea93920929a9baf09df40dd2 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Mon, 23 Jul 2018 12:01:20 +0900 Subject: [PATCH] Fix some invoice failing to create because of rounding issues --- BTCPayServer/BTCPayServer.csproj | 2 +- BTCPayServer/Services/Invoices/InvoiceEntity.cs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/BTCPayServer/BTCPayServer.csproj b/BTCPayServer/BTCPayServer.csproj index 541c8b988..2b9bf2fbc 100644 --- a/BTCPayServer/BTCPayServer.csproj +++ b/BTCPayServer/BTCPayServer.csproj @@ -2,7 +2,7 @@ Exe netcoreapp2.1 - 1.0.2.56 + 1.0.2.57 NU1701,CA1816,CA1308,CA1810,CA2208 diff --git a/BTCPayServer/Services/Invoices/InvoiceEntity.cs b/BTCPayServer/Services/Invoices/InvoiceEntity.cs index c770e4a27..f0d3826c0 100644 --- a/BTCPayServer/Services/Invoices/InvoiceEntity.cs +++ b/BTCPayServer/Services/Invoices/InvoiceEntity.cs @@ -709,7 +709,8 @@ namespace BTCPayServer.Services.Invoices accounting.Due = Money.Max(accounting.TotalDue - accounting.Paid, Money.Zero); accounting.DueUncapped = accounting.TotalDue - accounting.Paid; accounting.NetworkFee = accounting.TotalDue - totalDueNoNetworkCost; - accounting.MinimumTotalDue = Money.Max(Money.Satoshis(1), Money.Satoshis(accounting.TotalDue.Satoshi * (1.0m - ((decimal)ParentEntity.PaymentTolerance / 100.0m)))); + var minimumTotalDueSatoshi = Math.Max(1.0m, accounting.TotalDue.Satoshi * (1.0m - ((decimal)ParentEntity.PaymentTolerance / 100.0m))); + accounting.MinimumTotalDue = Money.Satoshis(minimumTotalDueSatoshi); return accounting; }