MMGenPasswordType: initialize all unused fields with 'None'

This commit is contained in:
The MMGen Project 2019-10-18 16:59:24 +00:00
commit c1ba807502
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
2 changed files with 11 additions and 10 deletions

View file

@ -311,6 +311,7 @@ class AddrListChksum(str,Hilite):
def __new__(cls,addrlist):
ea = addrlist.al_id.mmtype.extra_attrs # add viewkey and passwd to the mix, if present
if ea == None: ea = ()
lines = [' '.join(
addrlist.chksum_rec_f(e) +
tuple(getattr(e,a) for a in ea if getattr(e,a))

View file

@ -732,17 +732,17 @@ class PrivKey(str,Hilite,InitErrors,MMGenObject):
return cls.init_fail(e,s,objname='{} WIF key'.format(g.coin))
else:
try:
assert s,'private key hex data missing'
assert compressed is not None, "'compressed' arg missing"
assert s,'private key bin data missing'
assert pubkey_type is not None,"'pubkey_type' arg missing"
assert type(compressed) == bool,"{!r}: 'compressed' not of type 'bool'".format(compressed)
assert len(s) == cls.width // 2,'key length must be {}'.format(cls.width // 2)
if pubkey_type == 'password': # skip WIF creation and pre-processing for passwds
me = str.__new__(cls,s.hex())
else:
assert compressed is not None, "'compressed' arg missing"
assert type(compressed) == bool,"{!r}: 'compressed' not of type 'bool'".format(compressed)
me = str.__new__(cls,g.proto.preprocess_key(s.hex(),pubkey_type))
me.wif = WifKey(g.proto.hex2wif(me,pubkey_type,compressed),on_fail='raise')
me.compressed = compressed
me.compressed = compressed
me.pubkey_type = pubkey_type
me.orig_hex = s.hex() # save the non-preprocessed key
return me
@ -858,11 +858,11 @@ class MMGenAddrType(str,Hilite,InitErrors,MMGenObject):
name = MMGenImmutableAttr('name',str)
pubkey_type = MMGenImmutableAttr('pubkey_type',str)
compressed = MMGenImmutableAttr('compressed',bool)
gen_method = MMGenImmutableAttr('gen_method',str)
addr_fmt = MMGenImmutableAttr('addr_fmt',str)
wif_label = MMGenImmutableAttr('wif_label',str)
extra_attrs = MMGenImmutableAttr('extra_attrs',tuple)
compressed = MMGenImmutableAttr('compressed',bool,set_none_ok=True)
gen_method = MMGenImmutableAttr('gen_method',str,set_none_ok=True)
addr_fmt = MMGenImmutableAttr('addr_fmt',str,set_none_ok=True)
wif_label = MMGenImmutableAttr('wif_label',str,set_none_ok=True)
extra_attrs = MMGenImmutableAttr('extra_attrs',tuple,set_none_ok=True)
desc = MMGenImmutableAttr('desc',str)
mmtypes = {
@ -900,5 +900,5 @@ class MMGenAddrType(str,Hilite,InitErrors,MMGenObject):
class MMGenPasswordType(MMGenAddrType):
mmtypes = {
'P': ati('password', 'password', False, None, None, None, (), 'Password generated from MMGen seed')
'P': ati('password', 'password', None, None, None, None, None, 'Password generated from MMGen seed')
}