a few minor cleanups

This commit is contained in:
The MMGen Project 2023-10-03 14:27:58 +00:00
commit da32c52a0f
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
10 changed files with 23 additions and 20 deletions

View file

@ -200,6 +200,7 @@ class AddrList(MMGenObject): # Address info for a single seed ID
adata = AddrListData([AddrListEntry(proto=proto,addr=a) for a in addrlist])
elif keylist: # data from flat key list
self.al_id = None
from .util import remove_dups
keylist = remove_dups(keylist,edesc='key',desc='key list',hide=True)
adata = AddrListData([AddrListEntry(proto=proto,sec=PrivKey(proto=proto,wif=k)) for k in keylist])
elif seed or addr_idxs:

View file

@ -536,6 +536,7 @@ class Autosign:
def do_shred(f):
nonlocal count
msg_r('.')
from .fileutil import shred_file
shred_file( f, verbose=self.cfg.verbose )
count += 1
@ -565,7 +566,6 @@ class Autosign:
asi = get_autosign_obj( self.cfg, 'btc,xmr' )
count = 0
from .fileutil import shred_file
for s_name in Signable.signables:
clean_dir(s_name)

View file

@ -679,6 +679,8 @@ class Config(Lockable):
def check_opts(cfg): # Raises exception if any check fails
from .util import is_int,Msg
def get_desc(desc_pfx=''):
return (
(desc_pfx + ' ' if desc_pfx else '')
@ -831,8 +833,6 @@ def check_opts(cfg): # Raises exception if any check fails
def columns():
opt_compares(val,'>',10)
from .util import is_int,Msg
# TODO: add checks for token, rbf, tx_fee
check_funcs_names = tuple(check_funcs.__dict__)
for name in tuple(cfg._uopts) + cfg._envopts + cfg._cfgfile_opts.non_auto:

View file

@ -1 +1 @@
September 2023
October 2023

View file

@ -1 +1 @@
14.0.dev5
14.0.dev6

View file

@ -120,8 +120,17 @@ class MMGenObjectMethods: # mixin class for MMGenObject
self.pdie(exit_val=0)
def pfmt(self,lvl=0,id_list=[],color=None):
from decimal import Decimal
scalars = (str,int,float,Decimal)
def isDict(obj):
return isinstance(obj,dict)
def isList(obj):
return isinstance(obj,list)
def isScalar(obj):
return isinstance(obj,scalars)
def do_list(out,e,lvl=0,is_dict=False):
out.append('\n')
for i in e:
@ -155,13 +164,6 @@ class MMGenObjectMethods: # mixin class for MMGenObject
if not e:
out.append(f'{e!r}\n')
def isDict(obj):
return isinstance(obj,dict)
def isList(obj):
return isinstance(obj,list)
def isScalar(obj):
return isinstance(obj,scalars)
out = [f'<{type(self).__name__}>{" "+repr(self) if isScalar(self) else ""}\n']
if id(self) in id_list:

View file

@ -220,6 +220,8 @@ class coin_msg:
async def sign(self,wallet_files):
from .addrlist import KeyAddrList
async def sign_list(al_in,seed):
al = KeyAddrList(
cfg = self.cfg,
@ -254,7 +256,6 @@ class coin_msg:
self.rpc = await rpc_init( self.cfg, self.proto, ignore_wallet=True )
from .wallet import Wallet
from .addrlist import KeyAddrList
wallet_seeds = [Wallet(cfg=self.cfg,fn=fn).seed for fn in wallet_files]
need_sids = remove_dups([al.sid for al in self.addrlists], quiet=True)
saved_seeds = list()

View file

@ -36,11 +36,10 @@ class TxInfo:
blockcount = None
def get_max_mmwid(io):
if io == tx.inputs:
sel_f = lambda o: len(o.mmid) + 2 # len('()')
else:
sel_f = lambda o: len(o.mmid) + (2,8)[bool(o.is_chg)] # + len(' (chg)')
return max(max([sel_f(o) for o in io if o.mmid] or [0]),len(nonmm_str))
sel_f = (
(lambda o: len(o.mmid) + 2) if io == tx.inputs else # 2 = len('()')
(lambda o: len(o.mmid) + (2,8)[bool(o.is_chg)]) ) # 6 = len(' (chg)')
return max(max([sel_f(o) for o in io if o.mmid] or [0]),len(nonmm_str))
nonmm_str = f'(non-{gc.proj_name} address)'
max_mmwid = max(get_max_mmwid(tx.inputs),get_max_mmwid(tx.outputs))

View file

@ -33,7 +33,6 @@ class unit_test(object):
avail_opts = ('foo',)
def __init__(self,opts=None,flags=None):
self.opt = MyClassOpts(self,opts)
self.flag = MyClassFlags(self,flags)
def test_flags():
def gen():

View file

@ -181,6 +181,8 @@ class unit_tests:
rpc.call_raw('get_height')
rpc.call('get_last_block_header')
from mmgen.xmrseed import xmrseed
async def run():
networks = init_proto( cfg, 'xmr' ).networks
daemons = [(
@ -224,7 +226,6 @@ class unit_tests:
gmsg('OK')
from mmgen.xmrseed import xmrseed
import shutil
shutil.rmtree('test/trash2',ignore_errors=True)
os.makedirs('test/trash2/wallet_rpc')