eth/obj.py,eth/tw.py,obj.py,tw.py: small fixes

This commit is contained in:
The MMGen Project 2018-06-01 17:55:53 +00:00
commit 840d96b05f
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
4 changed files with 11 additions and 9 deletions

View file

@ -27,7 +27,7 @@ from mmgen.color import *
from mmgen.obj import *
class ETHAmt(BTCAmt):
max_prec = 18
max_amt = 999999999 # TODO
max_amt = None
wei = Decimal('0.000000000000000001')
Kwei = Decimal('0.000000000000001')
Mwei = Decimal('0.000000000001')

View file

@ -106,8 +106,8 @@ class EthereumTwUnspentOutputs(TwUnspentOutputs):
show_txid = False
can_group = False
hdr_fmt = 'TRACKED ACCOUNTS (sort order: {})\nTotal {}: {}'
wide_hdr_title = 'Account balances'
dump_fn = 'balances-' + g.coin
desc = 'account balances'
dump_fn_pfx = 'balances'
prompt = """
Sort options: [a]mount, a[d]dress, [A]ge, [r]everse, [M]mgen addr
Display options: show [D]ays, show [m]mgen addr, r[e]draw screen

View file

@ -328,7 +328,8 @@ class BTCAmt(Decimal,Hilite,InitErrors):
assert type(num) is not t,"number is of forbidden type '{}'".format(t.__name__)
me = Decimal.__new__(cls,str(num))
assert me.normalize().as_tuple()[-1] >= -cls.max_prec,'too many decimal places in coin amount'
assert me <= cls.max_amt,'coin amount too large (>{})'.format(cls.max_amt)
if cls.max_amt:
assert me <= cls.max_amt,'{}: coin amount too large (>{})'.format(me,cls.max_amt)
assert me >= 0,'coin amount cannot be negative'
return me
except Exception as e:

View file

@ -32,8 +32,8 @@ class TwUnspentOutputs(MMGenObject):
show_txid = True
can_group = True
hdr_fmt = 'UNSPENT OUTPUTS (sort order: {}) Total {}: {}'
wide_hdr_title = 'Unspent outputs'
dump_fn = 'listunspent-' + g.coin
desc = 'unspent outputs'
dump_fn_pfx = 'listunspent'
prompt = """
Sort options: [t]xid, [a]mount, a[d]dress, [A]ge, [r]everse, [M]mgen addr
Display options: show [D]ays, [g]roup, show [m]mgen addr, r[e]draw screen
@ -256,7 +256,7 @@ watch-only wallet using '{}-addrimport' and then re-run this program.
fs = '{} ({} UTC)\nSort order: {}\n{}\n\nTotal {}: {}\n'
self.fmt_print = fs.format(
self.wide_hdr_title,
capfirst(self.desc),
make_timestr(),
' '.join(self.sort_info(include_group=False)),
'\n'.join(out),
@ -324,8 +324,9 @@ watch-only wallet using '{}-addrimport' and then re-run this program.
elif reply == 'm': self.show_mmid = not self.show_mmid
elif reply == 'p':
msg('')
of = '{}[{}].out'.format(self.dump_fn,','.join(self.sort_info(include_group=False)).lower())
write_data_to_file(of,self.format_for_printing(),'unspent outputs listing')
of = '{}-{}[{}].out'.format(self.dump_fn_pfx,g.coin,
','.join(self.sort_info(include_group=False)).lower())
write_data_to_file(of,self.format_for_printing(),'{} listing'.format(self.desc))
m = yellow("Data written to '{}'".format(of))
msg('\n{}\n{}\n\n{}'.format(self.fmt_display,m,prompt))
continue