Fix bug: Paying a lightning invoice might miss 1 satoshi due to rounding error

This commit is contained in:
nicolas.dorier
2018-03-18 02:26:33 +09:00
parent b8a4f0c012
commit acb2407654
7 changed files with 40 additions and 24 deletions

View File

@@ -30,6 +30,19 @@ namespace BTCPayServer
{
public static class Extensions
{
public static decimal RoundUp(decimal value, int precision)
{
for (int i = 0; i < precision; i++)
{
value = value * 10m;
}
value = Math.Ceiling(value);
for (int i = 0; i < precision; i++)
{
value = value / 10m;
}
return value;
}
public static PaymentMethodId GetpaymentMethodId(this InvoiceCryptoInfo info)
{
return new PaymentMethodId(info.CryptoCode, Enum.Parse<PaymentTypes>(info.PaymentType));