|
|
|
@ -659,6 +659,7 @@ def format_satoshis( |
|
|
|
precision: int = 0, # extra digits after satoshi precision |
|
|
|
precision: int = 0, # extra digits after satoshi precision |
|
|
|
is_diff: bool = False, # if True, enforce a leading sign (+/-) |
|
|
|
is_diff: bool = False, # if True, enforce a leading sign (+/-) |
|
|
|
whitespaces: bool = False, # if True, add whitespaces, to align numbers in a column |
|
|
|
whitespaces: bool = False, # if True, add whitespaces, to align numbers in a column |
|
|
|
|
|
|
|
add_thousands_sep: bool = False, # if True, add whitespaces, for better readability of the numbers |
|
|
|
) -> str: |
|
|
|
) -> str: |
|
|
|
if x is None: |
|
|
|
if x is None: |
|
|
|
return 'unknown' |
|
|
|
return 'unknown' |
|
|
|
@ -681,6 +682,14 @@ def format_satoshis( |
|
|
|
integer_part, fract_part = result.split(".") |
|
|
|
integer_part, fract_part = result.split(".") |
|
|
|
if len(fract_part) < num_zeros: |
|
|
|
if len(fract_part) < num_zeros: |
|
|
|
fract_part += "0" * (num_zeros - len(fract_part)) |
|
|
|
fract_part += "0" * (num_zeros - len(fract_part)) |
|
|
|
|
|
|
|
# add whitespaces as thousands' separator for better readability of numbers |
|
|
|
|
|
|
|
if add_thousands_sep: |
|
|
|
|
|
|
|
sign = integer_part[0] if integer_part[0] in ("+", "-") else "" |
|
|
|
|
|
|
|
if sign == "-": |
|
|
|
|
|
|
|
integer_part = integer_part[1:] |
|
|
|
|
|
|
|
integer_part = "{:,}".format(int(integer_part)).replace(',', " ") |
|
|
|
|
|
|
|
integer_part = sign + integer_part |
|
|
|
|
|
|
|
fract_part = " ".join(fract_part[i:i+3] for i in range(0, len(fract_part), 3)) |
|
|
|
result = integer_part + DECIMAL_POINT + fract_part |
|
|
|
result = integer_part + DECIMAL_POINT + fract_part |
|
|
|
# add leading/trailing whitespaces so that numbers can be aligned in a column |
|
|
|
# add leading/trailing whitespaces so that numbers can be aligned in a column |
|
|
|
if whitespaces: |
|
|
|
if whitespaces: |
|
|
|
|