electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 70cca3bad9a40b5b5230e13c0d2fce7ae1312b53
parent b37695f9c8a6f3ea57c829209a14027c6ad11e60
Author: SomberNight <somber.night@protonmail.com>
Date:   Sun,  7 Oct 2018 17:50:52 +0200

fix #4759

Diffstat:
Melectrum/util.py | 12+++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/electrum/util.py b/electrum/util.py @@ -511,15 +511,21 @@ def format_satoshis(x, num_zeros=0, decimal_point=8, precision=None, is_diff=Fal return 'unknown' if precision is None: precision = decimal_point + # format string decimal_format = ".0" + str(precision) if precision > 0 else "" if is_diff: decimal_format = '+' + decimal_format - result = ("{:" + decimal_format + "f}").format(x / pow (10, decimal_point)).rstrip('0') + # initial result + scale_factor = pow(10, decimal_point) + result = ("{:" + decimal_format + "f}").format(Decimal(x) / scale_factor) + if "." not in result: result += "." + result = result.rstrip('0') + # extra decimal places integer_part, fract_part = result.split(".") - dp = DECIMAL_POINT if len(fract_part) < num_zeros: fract_part += "0" * (num_zeros - len(fract_part)) - result = integer_part + dp + fract_part + result = integer_part + DECIMAL_POINT + fract_part + # leading/trailing whitespaces if whitespaces: result += " " * (decimal_point - len(fract_part)) result = " " * (15 - len(result)) + result