electrum

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

commit a35a945b0bf9193a4e5149fe5d2972c449c2e25f
parent 705fd76767862d4cfe800a41c290f8d9bb2faa59
Author: ThomasV <thomasv@gitorious>
Date:   Sat, 19 May 2012 17:34:59 +0200

fix format_satoshis

Diffstat:
Mlib/version.py | 2+-
Mlib/wallet.py | 14+++++++++++---
2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/lib/version.py b/lib/version.py @@ -1,2 +1,2 @@ -ELECTRUM_VERSION = "0.51" +ELECTRUM_VERSION = "0.52" SEED_VERSION = 4 # bump this everytime the seed generation is modified diff --git a/lib/wallet.py b/lib/wallet.py @@ -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 ))