tfix format_satoshis - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit a35a945b0bf9193a4e5149fe5d2972c449c2e25f DIR parent 705fd76767862d4cfe800a41c290f8d9bb2faa59 HTML Author: ThomasV <thomasv@gitorious> Date: Sat, 19 May 2012 17:34:59 +0200 fix format_satoshis Diffstat: M lib/version.py | 2 +- M lib/wallet.py | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) --- DIR diff --git a/lib/version.py b/lib/version.py t@@ -1,2 +1,2 @@ -ELECTRUM_VERSION = "0.51" +ELECTRUM_VERSION = "0.52" SEED_VERSION = 4 # bump this everytime the seed generation is modified DIR diff --git a/lib/wallet.py b/lib/wallet.py t@@ -213,10 +213,18 @@ def raw_tx( inputs, outputs, for_sig = None ): def format_satoshis(x, is_diff=False, num_zeros = 0): from decimal import Decimal - s = str( Decimal(x) /100000000 ) - if is_diff and x>0: + s = Decimal(x) + sign, digits, exp = s.as_tuple() + digits = map(str, digits) + while len(digits) < 9: + digits.insert(0,'0') + digits.insert(-8,'.') + s = ''.join(digits).rstrip('0') + if sign: + s = '-' + s + elif is_diff: s = "+" + s - if not '.' in s: s += '.' + p = s.find('.') s += "0"*( 1 + num_zeros - ( len(s) - p )) s += " "*( 9 - ( len(s) - p ))