mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-03-03 09:29:10 +01:00
Fix crash when sat is negative (liquid only) (#2418)
This commit is contained in:
parent
f94e8c9719
commit
3e985d8554
1 changed files with 5 additions and 3 deletions
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue