tMerge branch 'master' of git://github.com/spesmilo/electrum - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 3fc96b547f86b146557ecfb4ec57937eee3b384b DIR parent d196c9d0a18a9892139d20eb9a8537ed0678b0a9 HTML Author: ThomasV <thomasv@gitorious> Date: Wed, 27 May 2015 10:19:21 +0200 Merge branch 'master' of git://github.com/spesmilo/electrum Diffstat: M gui/qt/amountedit.py | 8 +++----- M lib/util.py | 11 ++++++----- 2 files changed, 9 insertions(+), 10 deletions(-) --- DIR diff --git a/gui/qt/amountedit.py b/gui/qt/amountedit.py t@@ -4,6 +4,7 @@ from PyQt4.QtCore import * from PyQt4.QtGui import * from decimal import Decimal +from electrum.util import format_satoshis_plain class MyLineEdit(QLineEdit): frozen = pyqtSignal() t@@ -93,8 +94,5 @@ class BTCAmountEdit(AmountEdit): def setAmount(self, amount): if amount is None: self.setText("") - return - - p = pow(10, self.decimal_point()) - x = amount / Decimal(p) - self.setText(str(x)) + else: + self.setText(format_satoshis_plain(amount, self.decimal_point())) DIR diff --git a/lib/util.py b/lib/util.py t@@ -2,6 +2,7 @@ import os, sys, re, json import platform import shutil from datetime import datetime +from decimal import Decimal import urlparse import urllib import threading t@@ -104,10 +105,11 @@ def user_dir(): #raise Exception("No home directory found in environment variables.") return -def format_satoshis_plain(x): - '''Display a satoshi amount in BTC with 8 decimal places. Always - uses a '.' as a decimal point and has no thousands separator''' - return "{:.8f}".format(x / 100000000.0) +def format_satoshis_plain(x, decimal_point = 8): + '''Display a satoshi amount scaled. Always uses a '.' as a decimal + point and has no thousands separator''' + scale_factor = pow(10, decimal_point) + return "{:.8f}".format(Decimal(x) / scale_factor).rstrip('0').rstrip('.') def format_satoshis(x, is_diff=False, num_zeros = 0, decimal_point = 8, whitespaces=False): from locale import localeconv t@@ -223,7 +225,6 @@ def block_explorer_URL(config, kind, item): def parse_URI(uri): import bitcoin - from decimal import Decimal if ':' not in uri: assert bitcoin.is_address(uri)