1
0

Merge branch 'master' into tray_tip_wallet

This commit is contained in:
Neil Booth
2015-04-30 13:28:13 +09:00
9 changed files with 80 additions and 321 deletions

View File

@@ -343,7 +343,7 @@ class Commands:
balance = 0
out = []
for item in self.wallet.get_history():
tx_hash, conf, is_mine, value, fee, balance, timestamp = item
tx_hash, conf, value, timestamp, balance = item
try:
time_str = datetime.datetime.fromtimestamp( timestamp).isoformat(' ')[:-3]
except Exception:

View File

@@ -108,28 +108,24 @@ def user_dir():
def format_satoshis(x, is_diff=False, num_zeros = 0, decimal_point = 8, whitespaces=False):
from decimal import Decimal
if x is None:
return 'unknown'
s = Decimal(x)
sign, digits, exp = s.as_tuple()
digits = map(str, digits)
while len(digits) < decimal_point + 1:
digits.insert(0,'0')
digits.insert(-decimal_point,'.')
s = ''.join(digits).rstrip('0')
if sign:
s = '-' + s
from locale import localeconv
x = int(x) # Some callers pass Decimal
scale_factor = pow (10, decimal_point)
integer_part = "{:n}".format(int(abs(x) / float(scale_factor)))
if x < 0:
integer_part = '-' + integer_part
elif is_diff:
s = "+" + s
p = s.find('.')
s += "0"*( 1 + num_zeros - ( len(s) - p ))
integer_part = '+' + integer_part
dp = localeconv()['decimal_point']
fract_part = ("{:0" + str(decimal_point) + "}").format(abs(x) % scale_factor)
fract_part = fract_part.rstrip('0')
if len(fract_part) < num_zeros:
fract_part += "0" * (num_zeros - len(fract_part))
result = integer_part + dp + fract_part
if whitespaces:
s += " "*( 1 + decimal_point - ( len(s) - p ))
s = " "*( 13 - decimal_point - ( p )) + s
return s
result += " " * (decimal_point - len(fract_part))
result = " " * (15 - len(result)) + result
return result
def format_time(timestamp):
import datetime