mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2026-02-05 22:34:25 +01:00
Fix crash when sat is negative (liquid only) (#2418)
This commit is contained in:
@@ -33,10 +33,12 @@ namespace BTCPayServer
|
||||
|
||||
public static decimal Convert(long sats, int divisibility = 8)
|
||||
{
|
||||
var amt = sats.ToString(CultureInfo.InvariantCulture).PadLeft(divisibility, '0');
|
||||
var negative = sats < 0;
|
||||
var amt = sats.ToString(CultureInfo.InvariantCulture)
|
||||
.Replace("-", "")
|
||||
.PadLeft(divisibility, '0');
|
||||
amt = amt.Length == divisibility ? $"0.{amt}" : amt.Insert(amt.Length - divisibility, ".");
|
||||
|
||||
return decimal.Parse(amt, CultureInfo.InvariantCulture);
|
||||
return decimal.Parse($"{(negative? "-": string.Empty)}{amt}", CultureInfo.InvariantCulture);
|
||||
}
|
||||
public static string ShowMoney(this IMoney money, BTCPayNetwork network)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user