rename class: SeedSource -> Wallet

This commit is contained in:
The MMGen Project 2020-04-09 16:38:26 +00:00
commit 4fbe2d6574
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
21 changed files with 99 additions and 99 deletions

View file

@ -29,7 +29,7 @@ from mmgen.util import *
def help_notes(k):
from mmgen.obj import SubSeedIdxRange,SeedShareIdx,SeedShareCount,MasterShareIdx
from mmgen.seed import SeedSource
from mmgen.seed import Wallet
from mmgen.tx import MMGenTX
def fee_spec_letters(use_quotes=False):
cu = g.proto.coin_amt.units

View file

@ -39,22 +39,22 @@ class Filename(MMGenObject):
self.ctime = None
self.atime = None
from mmgen.seed import SeedSource
from mmgen.seed import Wallet
from mmgen.tx import MMGenTX
if ftype:
if isinstance(ftype,type):
if issubclass(ftype,(SeedSource,MMGenTX)):
if issubclass(ftype,(Wallet,MMGenTX)):
self.ftype = ftype
# elif: # other MMGen file types
else:
die(3,"'{}': not a recognized file type for SeedSource".format(ftype))
die(3,"'{}': not a recognized file type for Wallet".format(ftype))
else:
die(3,"'{}': not a class".format(ftype))
else:
# TODO: other file types
self.ftype = SeedSource.ext_to_type(self.ext)
self.ftype = Wallet.ext_to_type(self.ext)
if not self.ftype:
m = "'{}': not a recognized SeedSource file extension".format(self.ext)
m = "'{}': not a recognized Wallet file extension".format(self.ext)
raise BadFileExtension(m)
try:
@ -99,8 +99,8 @@ def find_files_in_dir(ftype,fdir,no_dups=False):
if not isinstance(ftype,type):
die(3,"'{}': is of type {} (not a subclass of type 'type')".format(ftype,type(ftype)))
from mmgen.seed import SeedSource
if not issubclass(ftype,SeedSource):
from mmgen.seed import Wallet
if not issubclass(ftype,Wallet):
die(3,"'{}': not a recognized file type".format(ftype))
try: dirlist = os.listdir(fdir)

View file

@ -24,7 +24,7 @@ mmgen-addrgen: Generate a series or range of addresses from an MMGen
from mmgen.common import *
from mmgen.crypto import *
from mmgen.addr import *
from mmgen.seed import SeedSource
from mmgen.seed import Wallet
if g.prog_name == 'mmgen-keygen':
gen_what = 'keys'
@ -116,7 +116,7 @@ FMT CODES:
n_sw=help_notes('subwallet')+'\n\n',
n_pw=help_notes('passwd')+'\n\n',
n_bw=help_notes('brainwallet'),
n_fmt='\n '.join(SeedSource.format_fmt_codes().splitlines()),
n_fmt='\n '.join(Wallet.format_fmt_codes().splitlines()),
n_at='\n '.join(["'{}','{:<12} - {}".format(
k,v.name+"'",v.desc) for k,v in MMGenAddrType.mmtypes.items()])
)
@ -139,7 +139,7 @@ sf = get_seed_file(cmd_args,1)
do_license_msg()
ss = SeedSource(sf)
ss = Wallet(sf)
ss_seed = ss.seed if opt.subwallet is None else ss.seed.subseed(opt.subwallet,print_msg=True)

View file

@ -249,12 +249,12 @@ def decrypt_wallets():
opt.set_by_user = ['hash_preset']
opt.passwd_file = os.path.join(tx_dir,key_fn)
# opt.passwd_file = '/tmp/key'
from mmgen.seed import SeedSource
from mmgen.seed import Wallet
msg("Unlocking wallet{} with key from '{}'".format(suf(wfs),opt.passwd_file))
fails = 0
for wf in wfs:
try:
SeedSource(wf)
Wallet(wf)
except SystemExit as e:
if e.code != 0:
fails += 1
@ -352,11 +352,11 @@ def create_wallet_dir():
def setup():
remove_wallet_dir()
gen_key(no_unmount=True)
from mmgen.seed import SeedSource
from mmgen.seed import Wallet
opt.hidden_incog_input_params = None
opt.quiet = True
opt.in_fmt = 'words'
ss_in = SeedSource()
ss_in = Wallet()
opt.out_fmt = 'wallet'
opt.usr_randchars = 0
opt.hash_preset = '1'
@ -364,7 +364,7 @@ def setup():
opt.passwd_file = os.path.join(tx_dir,key_fn)
from mmgen.obj import MMGenWalletLabel
opt.label = MMGenWalletLabel('Autosign Wallet')
ss_out = SeedSource(ss=ss_in)
ss_out = Wallet(ss=ss_in)
ss_out.write_to_file(desc='autosign wallet',outdir=wallet_dir)
def ev_sleep(secs):

View file

@ -24,7 +24,7 @@ mmgen-passgen: Generate a series or range of passwords from an MMGen
from mmgen.common import *
from mmgen.crypto import *
from mmgen.addr import PasswordList,AddrIdxList
from mmgen.seed import SeedSource
from mmgen.seed import Wallet
from mmgen.obj import MMGenPWIDString
pwi = PasswordList.pw_info
@ -129,7 +129,7 @@ FMT CODES:
pfi='\n '.join(
[pwi_fs.format('Code','','Description','Min Len','Max Len','Default Len')] +
[pwi_fs.format(k,'-',v.desc,v.min_len,v.max_len,v.dfl_len) for k,v in pwi.items()]),
n_fmt='\n '.join(SeedSource.format_fmt_codes().splitlines())
n_fmt='\n '.join(Wallet.format_fmt_codes().splitlines())
)
}
}
@ -150,7 +150,7 @@ pw_len = pwi[pw_fmt].dfl_len // 2 if opt.passwd_len in ('h','H') else opt.passwd
PasswordList(pw_id_str=pw_id_str,pw_len=pw_len,pw_fmt=pw_fmt,chk_params_only=True)
do_license_msg()
ss = SeedSource(sf)
ss = Wallet(sf)
al = PasswordList(seed=ss.seed,pw_idxs=pw_idxs,pw_id_str=pw_id_str,pw_len=pw_len,pw_fmt=pw_fmt)

View file

@ -23,7 +23,7 @@ mmgen/main_seedjoin: Regenerate an MMGen deterministic wallet from seed shares
from mmgen.common import *
from mmgen.obj import MasterShareIdx,SeedSplitIDString,MMGenWalletLabel
from mmgen.seed import Seed,SeedSource,SeedShareMasterJoining
from mmgen.seed import Seed,Wallet,SeedShareMasterJoining
opts_data = {
'text': {
@ -82,7 +82,7 @@ FMT CODES:
g=g,
),
'notes': lambda s: s.format(
f='\n '.join(SeedSource.format_fmt_codes().splitlines()),
f='\n '.join(Wallet.format_fmt_codes().splitlines()),
n_pw=help_notes('passwd'),
)
}
@ -127,8 +127,8 @@ do_license_msg()
qmsg('Input files:\n {}\n'.format('\n '.join(cmd_args)))
shares = [SeedSource().seed] if opt.hidden_incog_input_params else []
shares += [SeedSource(fn).seed for fn in cmd_args]
shares = [Wallet().seed] if opt.hidden_incog_input_params else []
shares += [Wallet(fn).seed for fn in cmd_args]
if opt.master_share:
share1 = SeedShareMasterJoining(master_idx,shares[0],id_str,len(shares)).derived_seed
@ -143,4 +143,4 @@ seed_out = Seed.join_shares([share1]+shares[1:])
msg('OK\nJoined Seed ID: {}'.format(seed_out.sid.hl()))
SeedSource(seed=seed_out).write_to_file()
Wallet(seed=seed_out).write_to_file()

View file

@ -22,7 +22,7 @@ mmgen-txbump: Increase the fee on a replaceable (replace-by-fee) MMGen
"""
from mmgen.common import *
from mmgen.seed import SeedSource
from mmgen.seed import Wallet
opts_data = {
'sets': [('yes', True, 'quiet', True)],
@ -90,7 +90,7 @@ column below:
'notes': lambda s: s.format(
help_notes('fee'),
help_notes('txsign'),
f='\n '.join(SeedSource.format_fmt_codes().splitlines()))
f='\n '.join(Wallet.format_fmt_codes().splitlines()))
}
}

View file

@ -21,7 +21,7 @@ mmgen-txdo: Create, sign and broadcast an online MMGen transaction
"""
from mmgen.common import *
from mmgen.seed import SeedSource
from mmgen.seed import Wallet
from mmgen.obj import SubSeedIdxRange
opts_data = {
@ -106,7 +106,7 @@ column below:
help_notes('txcreate'),
help_notes('fee'),
help_notes('txsign'),
f='\n '.join(SeedSource.format_fmt_codes().splitlines()))
f='\n '.join(Wallet.format_fmt_codes().splitlines()))
}
}

View file

@ -22,7 +22,7 @@ mmgen-txsign: Sign a transaction generated by 'mmgen-txcreate'
from mmgen.common import *
from mmgen.obj import SubSeedIdxRange
from mmgen.seed import SeedSource
from mmgen.seed import Wallet
# -w, --use-wallet-dat (keys from running coin daemon) removed: use walletdump rpc instead
opts_data = {
@ -85,7 +85,7 @@ column below:
cu=g.coin),
'notes': lambda s: s.format(
help_notes('txsign'),
f='\n '.join(SeedSource.format_fmt_codes().splitlines()))
f='\n '.join(Wallet.format_fmt_codes().splitlines()))
}
}

View file

@ -22,7 +22,7 @@ mmgen/main_wallet: Entry point for MMGen wallet-related scripts
import os
from mmgen.common import *
from mmgen.seed import SeedSource,MMGenWallet
from mmgen.seed import Wallet,MMGenWallet
from mmgen.filename import find_file_in_dir
from mmgen.obj import MMGenWalletLabel,MasterShareIdx
@ -133,7 +133,7 @@ FMT CODES:
g=g,
),
'notes': lambda s: s.format(
f='\n '.join(SeedSource.format_fmt_codes().splitlines()),
f='\n '.join(Wallet.format_fmt_codes().splitlines()),
n_ss=('',help_notes('seedsplit')+'\n\n')[do_ss_note],
n_sw=('',help_notes('subwallet')+'\n\n')[do_sw_note],
n_pw=help_notes('passwd'),
@ -182,7 +182,7 @@ if invoked_as != 'chk':
if invoked_as == 'gen':
ss_in = None
else:
ss_in = SeedSource(sf,passchg=(invoked_as=='passchg'))
ss_in = Wallet(sf,passchg=(invoked_as=='passchg'))
m1 = green('Processing input wallet ')
m2 = ss_in.seed.sid.hl()
m3 = yellow(' (default wallet)') if sf and os.path.dirname(sf) == g.data_dir else ''
@ -198,14 +198,14 @@ if invoked_as != 'gen':
gmsg_r('Processing output wallet' + ('\n',' ')[invoked_as == 'seedsplit'])
if invoked_as == 'subgen':
ss_out = SeedSource(seed_bin=ss_in.seed.subseed(ss_idx,print_msg=True).data)
ss_out = Wallet(seed_bin=ss_in.seed.subseed(ss_idx,print_msg=True).data)
elif invoked_as == 'seedsplit':
shares = ss_in.seed.split(sss.count,sss.id,master_share)
seed_out = shares.get_share_by_idx(sss.idx,base_seed=True)
msg(seed_out.get_desc(ui=True))
ss_out = SeedSource(seed=seed_out)
ss_out = Wallet(seed=seed_out)
else:
ss_out = SeedSource(ss=ss_in,passchg=invoked_as=='passchg')
ss_out = Wallet(ss=ss_in,passchg=invoked_as=='passchg')
if invoked_as == 'gen':
qmsg("This wallet's Seed ID: {}".format(ss_out.seed.sid.hl()))

View file

@ -392,8 +392,8 @@ def check_usr_opts(usr_opts): # Raises an exception if any check fails
msg_r('{} option {!r}{}'.format(beg,s,end))
def chk_in_fmt(key,val,desc):
from mmgen.seed import SeedSource,IncogWallet,Brainwallet,IncogWalletHidden
sstype = SeedSource.fmt_code_to_type(val)
from mmgen.seed import Wallet,IncogWallet,Brainwallet,IncogWalletHidden
sstype = Wallet.fmt_code_to_type(val)
if not sstype:
opt_unrecognized(key,val)
if key == 'out_fmt':

View file

@ -38,7 +38,7 @@ def _is_mnemonic(s,fmt):
oq_save = opt.quiet
opt.quiet = True
try:
SeedSource(in_data=s,in_fmt=fmt)
Wallet(in_data=s,in_fmt=fmt)
ret = True
except:
ret = False
@ -499,13 +499,13 @@ class SeedShareMasterJoining(SeedShareMaster):
self.count = count
self.derived_seed = SeedBase(self.make_derived_seed_bin(self.id_str,self.count))
class SeedSourceMeta(type):
class WalletMeta(type):
wallet_classes = set() # one-instance class, so store data in class attr
def __init__(cls,name,bases,namespace):
cls.wallet_classes.add(cls)
cls.wallet_classes -= set(bases)
class SeedSource(MMGenObject,metaclass=SeedSourceMeta):
class Wallet(MMGenObject,metaclass=WalletMeta):
desc = g.proj_name + ' seed source'
file_mode = 'text'
@ -515,7 +515,7 @@ class SeedSource(MMGenObject,metaclass=SeedSourceMeta):
op = None
_msg = {}
class SeedSourceData(MMGenObject): pass
class WalletData(MMGenObject): pass
def __new__(cls,fn=None,ss=None,seed_bin=None,seed=None,
passchg=False,in_data=None,ignore_in_fmt=False,in_fmt=None):
@ -569,7 +569,7 @@ class SeedSource(MMGenObject,metaclass=SeedSourceMeta):
def __init__(self,fn=None,ss=None,seed_bin=None,seed=None,
passchg=False,in_data=None,ignore_in_fmt=False,in_fmt=None):
self.ssdata = self.SeedSourceData()
self.ssdata = self.WalletData()
self.msg = {}
self.in_data = in_data
@ -672,7 +672,7 @@ class SeedSource(MMGenObject,metaclass=SeedSourceMeta):
of = os.path.abspath(os.path.join(outdir,self._filename()))
write_data_to_file(of if outdir else self._filename(),self.fmt_data,**kwargs)
class SeedSourceUnenc(SeedSource):
class WalletUnenc(Wallet):
def _decrypt_retry(self): pass
def _encrypt(self): pass
@ -707,7 +707,7 @@ class SeedSourceUnenc(SeedSource):
if keypress_confirm(prompt,default_yes=True,no_nl=not g.test_suite):
return usr_len
class SeedSourceEnc(SeedSource):
class WalletEnc(Wallet):
_msg = {
'choose_passphrase': """
@ -826,7 +826,7 @@ an empty passphrase, just hit ENTER twice.
d.key_id = make_chksum_8(key)
d.enc_seed = encrypt_seed(self.seed.data,key)
class Mnemonic(SeedSourceUnenc):
class Mnemonic(WalletUnenc):
stdin_ok = True
wclass = 'mnemonic'
@ -919,7 +919,7 @@ class BIP39Mnemonic(Mnemonic):
self.conv_cls = bip39
super().__init__(*args,**kwargs)
class MMGenSeedFile(SeedSourceUnenc):
class MMGenSeedFile(WalletUnenc):
stdin_ok = True
fmt_codes = ('mmseed','seed','s')
@ -969,7 +969,7 @@ class MMGenSeedFile(SeedSourceUnenc):
return True
class DieRollSeedFile(SeedSourceUnenc):
class DieRollSeedFile(WalletUnenc):
stdin_ok = True
fmt_codes = ('b6d','die','dieroll')
@ -1059,7 +1059,7 @@ class DieRollSeedFile(SeedSourceUnenc):
return ''.join(dierolls)
class PlainHexSeedFile(SeedSourceUnenc):
class PlainHexSeedFile(WalletUnenc):
stdin_ok = True
fmt_codes = ('hex','rawhex','plainhex')
@ -1088,7 +1088,7 @@ class PlainHexSeedFile(SeedSourceUnenc):
return True
class MMGenHexSeedFile(SeedSourceUnenc):
class MMGenHexSeedFile(WalletUnenc):
stdin_ok = True
fmt_codes = ('seedhex','hexseed','mmhex')
@ -1136,7 +1136,7 @@ class MMGenHexSeedFile(SeedSourceUnenc):
return True
class MMGenWallet(SeedSourceEnc):
class MMGenWallet(WalletEnc):
fmt_codes = ('wallet','w')
desc = g.proj_name + ' wallet'
@ -1298,7 +1298,7 @@ class MMGenWallet(SeedSourceEnc):
self.ext,
x='' if g.debug_utf8 else '')
class Brainwallet(SeedSourceEnc):
class Brainwallet(WalletEnc):
stdin_ok = True
fmt_codes = ('mmbrain','brainwallet','brain','bw','b')
@ -1342,7 +1342,7 @@ class Brainwallet(SeedSourceEnc):
def _encrypt(self):
raise NotImplementedError('Brainwallet not supported as an output format')
class IncogWalletBase(SeedSourceEnc):
class IncogWalletBase(WalletEnc):
_msg = {
'check_incog_id': """
@ -1568,7 +1568,7 @@ harder to find, you're advised to choose a much larger file size than this.
os.close(fh)
qmsg("Data read from file '{}' at offset {}".format(self.infile.name,d.hincog_offset))
# overrides method in SeedSource
# overrides method in Wallet
def write_to_file(self):
d = self.ssdata
self._format()

View file

@ -786,23 +786,23 @@ class MMGenToolCmdWallet(MMGenToolCmds):
"get the Seed ID of a single subseed by Subseed Index for default or specified wallet"
opt.quiet = True
sf = get_seed_file([wallet] if wallet else [],1)
from mmgen.seed import SeedSource
return SeedSource(sf).seed.subseed(subseed_idx).sid
from mmgen.seed import Wallet
return Wallet(sf).seed.subseed(subseed_idx).sid
def get_subseed_by_seed_id(self,seed_id:str,wallet='',last_idx=g.subseeds):
"get the Subseed Index of a single subseed by Seed ID for default or specified wallet"
opt.quiet = True
sf = get_seed_file([wallet] if wallet else [],1)
from mmgen.seed import SeedSource
ret = SeedSource(sf).seed.subseed_by_seed_id(seed_id,last_idx)
from mmgen.seed import Wallet
ret = Wallet(sf).seed.subseed_by_seed_id(seed_id,last_idx)
return ret.ss_idx if ret else None
def list_subseeds(self,subseed_idx_range:str,wallet=''):
"list a range of subseed Seed IDs for default or specified wallet"
opt.quiet = True
sf = get_seed_file([wallet] if wallet else [],1)
from mmgen.seed import SeedSource
return SeedSource(sf).seed.subseeds.format(*SubSeedIdxRange(subseed_idx_range))
from mmgen.seed import Wallet
return Wallet(sf).seed.subseeds.format(*SubSeedIdxRange(subseed_idx_range))
def list_shares(self,
share_count:int,
@ -812,8 +812,8 @@ class MMGenToolCmdWallet(MMGenToolCmds):
"list the Seed IDs of the shares resulting from a split of default or specified wallet"
opt.quiet = True
sf = get_seed_file([wallet] if wallet else [],1)
from mmgen.seed import SeedSource
return SeedSource(sf).seed.split(share_count,id_str,master_share).format()
from mmgen.seed import Wallet
return Wallet(sf).seed.split(share_count,id_str,master_share).format()
def gen_key(self,mmgen_addr:str,wallet=''):
"generate a single MMGen WIF key from default or specified wallet"
@ -824,8 +824,8 @@ class MMGenToolCmdWallet(MMGenToolCmds):
addr = MMGenID(mmgen_addr)
opt.quiet = True
sf = get_seed_file([wallet] if wallet else [],1)
from mmgen.seed import SeedSource
ss = SeedSource(sf)
from mmgen.seed import Wallet
ss = Wallet(sf)
if ss.seed.sid != addr.sid:
m = 'Seed ID of requested address ({}) does not match wallet ({})'
die(1,m.format(addr.sid,ss.seed.sid))

View file

@ -49,14 +49,14 @@ def get_seed_for_seed_id(sid,infiles,saved_seeds):
subseeds_checked = False
while True:
if infiles:
seed = SeedSource(infiles.pop(0),ignore_in_fmt=True).seed
seed = Wallet(infiles.pop(0),ignore_in_fmt=True).seed
elif subseeds_checked == False:
seed = saved_seeds[list(saved_seeds)[0]].subseed_by_seed_id(sid,print_msg=True)
subseeds_checked = True
if not seed: continue
elif opt.in_fmt:
qmsg('Need seed data for Seed ID {}'.format(sid))
seed = SeedSource().seed
seed = Wallet().seed
msg('User input produced Seed ID {}'.format(seed.sid))
if not seed.sid == sid: # TODO: add test
seed = seed.subseed_by_seed_id(sid,print_msg=True)
@ -117,7 +117,7 @@ def get_tx_files(opt,args):
def get_seed_files(opt,args):
# favor unencrypted seed sources first, as they don't require passwords
u,e = SeedSourceUnenc,SeedSourceEnc
u,e = WalletUnenc,WalletEnc
ret = _pop_and_return(args,u.get_extensions())
from mmgen.filename import find_file_in_dir
wf = find_file_in_dir(MMGenWallet,g.data_dir) # Make this the first encrypted ss in the list

View file

@ -470,8 +470,8 @@ def check_outfile(f,blkdev_ok=False):
def check_outdir(f):
return check_file_type_and_access(f,'output directory')
def check_wallet_extension(fn):
from mmgen.seed import SeedSource
if not SeedSource.ext_to_type(get_extension(fn)):
from mmgen.seed import Wallet
if not Wallet.ext_to_type(get_extension(fn)):
raise BadFileExtension("'{}': unrecognized seed source file extension".format(fn))
def make_full_path(outdir,outfile):
return os.path.normpath(os.path.join(outdir, os.path.basename(outfile)))

View file

@ -13,7 +13,7 @@ ts_input.py: user input tests for the MMGen test.py test suite
from ..include.common import *
from .ts_base import *
from .input import *
from mmgen.seed import SeedSource
from mmgen.seed import Wallet
class TestSuiteInput(TestSuiteBase):
'user input'
@ -76,7 +76,7 @@ class TestSuiteInput(TestSuiteBase):
return t
def _user_seed_entry(self,fmt,usr_rand=False,out_fmt=None,entry_mode='full',mn=None):
wcls = SeedSource.fmt_code_to_type(fmt)
wcls = Wallet.fmt_code_to_type(fmt)
wf = os.path.join(ref_dir,'FE3C6545.{}'.format(wcls.ext))
if wcls.wclass == 'mnemonic':
mn = mn or read_from_file(wf).strip().split()

View file

@ -22,7 +22,7 @@ ts_main.py: Basic operations tests for the test.py test suite
from mmgen.globalvars import g
from mmgen.opts import opt
from mmgen.seed import SeedSource,MMGenWallet,MMGenMnemonic,IncogWallet,MMGenSeedFile
from mmgen.seed import Wallet,MMGenWallet,MMGenMnemonic,IncogWallet,MMGenSeedFile
from ..include.common import *
from .common import *
from .ts_base import *
@ -229,7 +229,7 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared):
return t
def subwalletgen_mnemonic(self,wf):
icls = SeedSource.ext_to_type(get_extension(wf))
icls = Wallet.ext_to_type(get_extension(wf))
ocls = MMGenMnemonic
args = [self.usr_rand_arg,'-p1','-d',self.tr.trash_dir,'-o',ocls.fmt_codes[0],wf,'3L']
t = self.spawn('mmgen-subwalletgen', args)
@ -503,11 +503,11 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared):
t.license()
if not pf:
icls = SeedSource.ext_to_type(get_extension(wf))
icls = Wallet.ext_to_type(get_extension(wf))
t.passphrase(icls.desc,self.wpasswd)
ocls = SeedSource.fmt_code_to_type(out_fmt)
out_pw = issubclass(ocls,SeedSourceEnc) and ocls != Brainwallet
ocls = Wallet.fmt_code_to_type(out_fmt)
out_pw = issubclass(ocls,WalletEnc) and ocls != Brainwallet
if out_pw:
t.passphrase_new('new '+ocls.desc,self.wpasswd)
t.usr_rand(self.usr_rand_chars)
@ -528,7 +528,7 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared):
def export_seed(self,wf,out_fmt='seed',pf=None):
f,t = self._walletconv_export(wf,out_fmt=out_fmt,pf=pf)
silence()
wcls = SeedSource.fmt_code_to_type(out_fmt)
wcls = Wallet.fmt_code_to_type(out_fmt)
msg('{}: {}'.format(capfirst(wcls.desc),cyan(get_data_from_file(f,wcls.desc))))
end_silence()
return t
@ -557,7 +557,7 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared):
return self.export_incog(wf,out_fmt='hi',add_args=add_args)
def addrgen_seed(self,wf,foo,in_fmt='seed'):
wcls = SeedSource.fmt_code_to_type(in_fmt)
wcls = Wallet.fmt_code_to_type(in_fmt)
stdout = wcls == MMGenSeedFile # capture output to screen once
add_args = ([],['-S'])[bool(stdout)] + self.segwit_arg
t = self.spawn('mmgen-addrgen', add_args +
@ -584,7 +584,7 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared):
([],[wf])[bool(wf)] + [self.addr_idx_list])
t.license()
t.expect_getend('Incog Wallet ID: ')
wcls = SeedSource.fmt_code_to_type(in_fmt)
wcls = Wallet.fmt_code_to_type(in_fmt)
t.hash_preset(wcls.desc,'1')
t.passphrase('{} \w{{8}}'.format(wcls.desc),self.wpasswd)
vmsg('Comparing generated checksum with checksum from address file')
@ -626,7 +626,7 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared):
t = self.spawn('mmgen-txsign', ['-d',self.tmpdir,txf1,wf1,txf2,wf2])
t.license()
for cnum,wf in (('1',wf1),('2',wf2)):
wcls = SeedSource.ext_to_type(get_extension(wf))
wcls = Wallet.ext_to_type(get_extension(wf))
t.view_tx('n')
t.passphrase(wcls.desc,self.cfgs[cnum]['wpasswd'])
self.txsign_end(t,cnum)
@ -649,7 +649,7 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared):
t.license()
t.view_tx('n')
for cnum,wf in (('1',wf1),('3',wf2)):
wcls = SeedSource.ext_to_type(get_extension(wf))
wcls = Wallet.ext_to_type(get_extension(wf))
t.passphrase(wcls.desc,self.cfgs[cnum]['wpasswd'])
self.txsign_end(t)
return t
@ -727,7 +727,7 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared):
t = self.spawn('mmgen-txsign', add_args + ['-d',self.tmpdir,'-k',non_mm_file,txf,wf])
t.license()
t.view_tx('n')
wcls = SeedSource.ext_to_type(get_extension(wf))
wcls = Wallet.ext_to_type(get_extension(wf))
t.passphrase(wcls.desc,self.cfgs['20']['wpasswd'])
if bad_vsize:
t.expect('Estimated transaction vsize')

View file

@ -23,7 +23,7 @@ ts_ref_3seed.py: Saved and generated reference file tests for 128, 192 and
from mmgen.globalvars import g
from mmgen.opts import opt
from mmgen.seed import SeedSource
from mmgen.seed import Wallet
from ..include.common import *
from .common import *
from .ts_base import *
@ -163,7 +163,7 @@ class TestSuiteRef3Seed(TestSuiteBase,TestSuiteShared):
wf = self.get_file_with_ext('mmdat')
pf = joinpath(self.tmpdir,pwfile)
t = self.spawn('mmgen-walletconv',extra_args+['-d','test/trash','-o',ofmt,'-P'+pf,wf])
wcls = SeedSource.fmt_code_to_type(ofmt)
wcls = Wallet.fmt_code_to_type(ofmt)
fn = os.path.split(t.written_to_file(capfirst(wcls.desc)))[-1]
idx = int(self.test_name[-1]) - 1
sid = self.chk_data['sids'][idx]

View file

@ -22,7 +22,7 @@ ts_seedsplit.py: Seed split/join tests for the test.py test suite
from mmgen.globalvars import g
from mmgen.opts import opt
from mmgen.seed import SeedSource,MMGenWallet,IncogWallet,IncogWalletHex,IncogWalletHidden,SeedSourceEnc
from mmgen.seed import Wallet,MMGenWallet,IncogWallet,IncogWalletHex,IncogWalletHidden,WalletEnc
from .ts_base import *
@ -110,8 +110,8 @@ class TestSuiteSeedSplit(TestSuiteBase):
else:
pat = "master share #{}".format(master)
t.expect(pat,regex=True)
ocls = SeedSource.fmt_code_to_type(ofmt)
pw = issubclass(ocls,SeedSourceEnc)
ocls = Wallet.fmt_code_to_type(ofmt)
pw = issubclass(ocls,WalletEnc)
if pw:
t.hash_preset('new '+ocls.desc,'1')
t.passphrase_new('new '+ocls.desc,sh1_passwd)
@ -150,7 +150,7 @@ class TestSuiteSeedSplit(TestSuiteBase):
t.expect(pat,regex=True)
sid_cmp = t.expect_getend('Joined Seed ID: ')
cmp_or_die(sid,sid_cmp)
ocls = SeedSource.fmt_code_to_type(ofmt)
ocls = Wallet.fmt_code_to_type(ofmt)
if ocls == MMGenWallet:
t.hash_preset('new '+ocls.desc,'1')
t.passphrase_new('new '+ocls.desc,wpasswd)

View file

@ -24,7 +24,7 @@ import os
from mmgen.globalvars import g
from mmgen.opts import opt
from mmgen.util import ymsg
from mmgen.seed import SeedSource,SeedSourceEnc,Brainwallet,MMGenWallet,IncogWalletHidden
from mmgen.seed import Wallet,WalletEnc,Brainwallet,MMGenWallet,IncogWalletHidden
from ..include.common import *
from .common import *
@ -158,8 +158,8 @@ class TestSuiteShared(object):
t = self.spawn('mmgen-txsign', opts, extra_desc)
t.license()
t.view_tx(view)
wcls = MMGenWallet if dfl_wallet else SeedSource.ext_to_type(get_extension(wf))
pw = issubclass(wcls,SeedSourceEnc) and wcls != Brainwallet
wcls = MMGenWallet if dfl_wallet else Wallet.ext_to_type(get_extension(wf))
pw = issubclass(wcls,WalletEnc) and wcls != Brainwallet
if pw:
t.passphrase(wcls.desc,self.wpasswd)
if save:
@ -177,7 +177,7 @@ class TestSuiteShared(object):
def walletchk(self,wf,pf,wcls=None,add_args=[],sid=None,extra_desc='',dfl_wallet=False):
hp = self.hash_preset if hasattr(self,'hash_preset') else '1'
wcls = wcls or SeedSource.ext_to_type(get_extension(wf))
wcls = wcls or Wallet.ext_to_type(get_extension(wf))
t = self.spawn('mmgen-walletchk',
([] if dfl_wallet else ['-i',wcls.fmt_codes[0]])
+ add_args + ['-p',hp]
@ -185,7 +185,7 @@ class TestSuiteShared(object):
extra_desc=extra_desc)
if wcls != IncogWalletHidden:
t.expect("Getting {} from file '".format(wcls.desc))
pw = issubclass(wcls,SeedSourceEnc) and wcls != Brainwallet
pw = issubclass(wcls,WalletEnc) and wcls != Brainwallet
if pw:
t.passphrase(wcls.desc,self.wpasswd)
t.expect(['Passphrase is OK', 'Passphrase.* are correct'],regex=True)
@ -215,7 +215,7 @@ class TestSuiteShared(object):
[getattr(self,'{}_idx_list'.format(cmd_pfx))],
extra_desc='({})'.format(mmtype) if mmtype in ('segwit','bech32') else '')
t.license()
wcls = MMGenWallet if dfl_wallet else SeedSource.ext_to_type(get_extension(wf))
wcls = MMGenWallet if dfl_wallet else Wallet.ext_to_type(get_extension(wf))
t.passphrase(wcls.desc,self.wpasswd)
t.expect('Passphrase is OK')
desc = ('address','password')[passgen]
@ -237,7 +237,7 @@ class TestSuiteShared(object):
([],['--type='+str(mmtype)])[bool(mmtype)] + args,
extra_desc='({})'.format(mmtype) if mmtype in ('segwit','bech32') else '')
t.license()
wcls = SeedSource.ext_to_type(get_extension(wf))
wcls = Wallet.ext_to_type(get_extension(wf))
t.passphrase(wcls.desc,self.wpasswd)
chk = t.expect_getend(r'Checksum for key-address data .*?: ',regex=True)
if check_ref:

View file

@ -175,10 +175,10 @@ class TestSuiteWalletConv(TestSuiteBase,TestSuiteShared):
d = '(convert)'
t = self.spawn('mmgen-walletconv',opts+uopts+if_arg,extra_desc=d)
t.license()
icls = icls or SeedSource.ext_to_type(get_extension(infile))
icls = icls or Wallet.ext_to_type(get_extension(infile))
if icls == Brainwallet:
t.expect('Enter brainwallet: ',ref_wallet_brainpass+'\n')
pw = issubclass(icls,SeedSourceEnc) and icls != Brainwallet
pw = issubclass(icls,WalletEnc) and icls != Brainwallet
if pw:
t.passphrase(icls.desc,self.wpasswd)
if self.test_name[:19] == 'ref_hincog_conv_old':
@ -195,14 +195,14 @@ class TestSuiteWalletConv(TestSuiteBase,TestSuiteShared):
sid = self.seed_id )
def walletconv_out(self,out_fmt='w',uopts=[],uopts_chk=[]):
wcls = SeedSource.fmt_code_to_type(out_fmt)
wcls = Wallet.fmt_code_to_type(out_fmt)
opts = ['-d',self.tmpdir,'-p1','-o',out_fmt] + uopts
infile = joinpath(ref_dir,self.seed_id+'.mmwords')
t = self.spawn('mmgen-walletconv',[self.usr_rand_arg]+opts+[infile],extra_desc='(convert)')
add_args = ['-l{}'.format(self.seed_len)]
t.license()
pw = issubclass(wcls,SeedSourceEnc) and wcls != Brainwallet
pw = issubclass(wcls,WalletEnc) and wcls != Brainwallet
if pw:
t.passphrase_new('new '+wcls.desc,self.wpasswd)
t.usr_rand(self.usr_rand_chars)