whitespace (82 files)

This commit is contained in:
The MMGen Project 2025-10-06 09:40:47 +00:00
commit 09e70c4bf3
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
82 changed files with 236 additions and 363 deletions

View file

@ -53,8 +53,8 @@ class MMGenAddrType(HiliteStr, InitErrors, MMGenObject):
'X': ati('bech32x', 'std', True, 'p2pkh', 'bech32', 'wif', (), 'Cross-chain Bech32 address'),
'E': ati('ethereum', 'std', False,'ethereum','p2pkh', 'privkey', ('wallet_passwd',),'Ethereum address'),
'Z': ati('zcash_z','zcash_z',False,'zcash_z', 'zcash_z', 'wif', ('viewkey',), 'Zcash z-address'),
'M': ati('monero', 'monero', False,'monero', 'monero', 'spendkey',('viewkey','wallet_passwd'),'Monero address'),
}
'M': ati('monero', 'monero', False,'monero', 'monero', 'spendkey',('viewkey','wallet_passwd'),'Monero address')}
def __new__(cls, proto, id_str, *, errmsg=None):
if isinstance(id_str, cls):
return id_str

View file

@ -103,8 +103,7 @@ class TwAddrData(AddrData, metaclass=AsyncInit):
self.cfg,
self.proto,
al_id = al_id,
adata = AddrListData(sorted(out[al_id], key=lambda a: a.idx))
))
adata = AddrListData(sorted(out[al_id], key=lambda a: a.idx))))
class TwAddrDataWithStore(TwAddrData):
@ -112,8 +111,7 @@ class TwAddrDataWithStore(TwAddrData):
'multiple_acct_addrs': """
ERROR: More than one address found for account: {acct!r}.
Your tracking wallet is corrupted!
"""
}
"""}
async def get_tw_data(self, *, twctl=None):
self.cfg._util.vmsg('Getting address data from tracking wallet')

View file

@ -89,8 +89,7 @@ class AddrFile(MMGenObject):
lbl_p2 = ':'.join(
([] if coin == 'BTC' or (coin == 'BCH' and not self.cfg.cashaddr) else [coin])
+ ([] if mmtype == 'E' or (mmtype == 'L' and not proto.testnet) else [mmtype.name.upper()])
+ ([proto.network.upper()] if proto.testnet else [])
)
+ ([proto.network.upper()] if proto.testnet else []))
return self.parent.al_id.sid + (' ' if lbl_p2 else '') + lbl_p2
def format(self, *, add_comments=False):
@ -162,7 +161,7 @@ class AddrFile(MMGenObject):
assert is_addr_idx(idx), f'invalid address index {idx!r}'
p.check_format(addr)
a = le(**{'proto': p.proto, 'idx':int(idx), p.main_attr:addr, 'comment':comment})
a = le(**{'proto': p.proto, 'idx': int(idx), p.main_attr: addr, 'comment': comment})
if p.has_keys: # order: wif, (orig_hex), viewkey, wallet_passwd
if type(self) is not ViewKeyAddrFile:
@ -350,7 +349,7 @@ class PasswordFile(AddrFile):
ret = lines.pop(0).split(None, p.pw_len + 1)
match len(ret) - 1:
case p.pw_len:
return (ret[0], ' '.join(ret[1:p.pw_len + 1]), '')
return (ret[0], ' '.join(ret[1: p.pw_len + 1]), '')
case x if x > p.pw_len:
raise ValueError(
f'extraneous text {ret[p.pw_len + 1]!r} found after password '

View file

@ -27,8 +27,8 @@ def check_data(orig_func):
def f(self, data):
assert data.pubkey_type == self.pubkey_type, 'addrgen.py:check_data() pubkey_type mismatch'
assert data.compressed == self.compressed, (
f'addrgen.py:check_data() expected compressed={self.compressed} but got compressed={data.compressed}'
)
f'addrgen.py:check_data() expected compressed={self.compressed} '
f'but got compressed={data.compressed}')
return orig_func(self, data)
return f
@ -62,8 +62,7 @@ def AddrGenerator(cfg, proto, addr_type):
'bech32x': 'xchain',
'monero': 'xmr',
'ethereum': 'eth',
'zcash_z': 'zec',
}
'zcash_z': 'zec'}
from .addr import MMGenAddrType

View file

@ -287,15 +287,11 @@ def make_proto(e, *, testnet=False):
'base_coin': e.symbol,
'addr_ver_info': dict(
[(num2hexstr(e.p2pkh_info[0]), 'p2pkh')] +
([(num2hexstr(e.p2sh_info[0]), 'p2sh')] if e.p2sh_info else [])
),
([(num2hexstr(e.p2sh_info[0]), 'p2sh')] if e.p2sh_info else [])),
'wif_ver_num': {'std': num2hexstr(e.wif_ver_num)},
'mmtypes': ('L', 'C', 'S') if e.has_segwit else ('L', 'C'),
'dfl_mmtype': 'L',
'mmcaps': (),
},
)
)
'mmcaps': ()}))
def init_genonly_altcoins(usr_coin=None, *, testnet=False):
"""

View file

@ -100,8 +100,7 @@ class CoinAmt(Decimal, Hilite, InitErrors): # abstract class
(res.rstrip('0').rstrip('.') if '.' in res else res) +
(' ' + self.coin if unit else ''),
color = color)
+ encl[1:]
)
+ encl[1:])
def __str__(self): # format simply, with no exponential notation
return str(int(self)) if int(self) == self else self.normalize().__format__('f')
@ -135,22 +134,19 @@ class CoinAmt(Decimal, Hilite, InitErrors): # abstract class
def __mul__(self, other, *args, **kwargs):
return type(self)('{:0.{p}f}'.format(
Decimal.__mul__(self, Decimal(other), *args, **kwargs),
p = self.max_prec
))
p = self.max_prec))
__rmul__ = __mul__
def __truediv__(self, other, *args, **kwargs):
return type(self)('{:0.{p}f}'.format(
Decimal.__truediv__(self, Decimal(other), *args, **kwargs),
p = self.max_prec
))
p = self.max_prec))
def __rtruediv__(self, other, *args, **kwargs):
return type(self)('{:0.{p}f}'.format(
Decimal.__rtruediv__(self, Decimal(other), *args, **kwargs),
p = self.max_prec
))
p = self.max_prec))
def __neg__(self, *args, **kwargs):
self.method_not_implemented()

View file

@ -188,8 +188,8 @@ class Signable:
def print_bad_list(self, bad_files):
msg('\n{a}\n{b}'.format(
a = red(f'Failed {self.desc}s:'),
b = ' {}\n'.format('\n '.join(self.gen_bad_list(sorted(bad_files, key=lambda f: f.name))))
))
b = ' {}\n'.format('\n '.join(
self.gen_bad_list(sorted(bad_files, key=lambda f: f.name))))))
def die_wrong_num_txs(self, tx_type, *, msg=None, desc=None, show_dir=False):
num_txs = len(getattr(self, tx_type))
@ -199,8 +199,7 @@ class Signable:
b = desc or tx_type,
c = suf(num_txs),
d = 'already present' if num_txs else 'present',
e = f'in ‘{getattr(self.parent, self.dir_name)}’' if show_dir else 'on removable device',
))
e = f'in ‘{getattr(self.parent, self.dir_name)}’' if show_dir else 'on removable device'))
def check_create_ok(self):
if len(self.unsigned):
@ -441,20 +440,20 @@ class Autosign:
mn_fmts = {
'mmgen': 'words',
'bip39': 'bip39',
}
'bip39': 'bip39'}
dfl_mn_fmt = 'mmgen'
non_xmr_dirs = {
'tx_dir': 'tx',
'txauto_dir': 'txauto',
'msg_dir': 'msg',
}
'msg_dir': 'msg'}
xmr_dirs = {
'xmr_dir': 'xmr',
'xmr_tx_dir': 'xmr/tx',
'xmr_outputs_dir': 'xmr/outputs',
}
'xmr_outputs_dir': 'xmr/outputs'}
have_xmr = False
xmr_only = False
@ -802,8 +801,7 @@ class Autosign:
'autosign': True,
'autosign_mountpoint': str(self.mountpoint),
'offline': True,
'passwd_file': str(self.keyfile),
})
'passwd_file': str(self.keyfile)})
return self._xmrwallet_cfg
def xmr_setup(self):

View file

@ -80,10 +80,9 @@ class AttrCtrl(metaclass=AttrCtrlMeta):
ref_val = getattr(type(self), name) if self._use_class_attr else getattr(self, name)
if (
(name not in self._skip_type_check)
and (ref_val is not None)
and not isinstance(value, type(ref_val))
):
(name not in self._skip_type_check)
and (ref_val is not None)
and not isinstance(value, type(ref_val))):
do_error(name, value, ref_val)
return object.__setattr__(self, name, value)

View file

@ -43,14 +43,16 @@ class baseconv:
constants = {
'desc': {
'b58': dt('base58', 'base58-encoded data'),
'b32': dt('MMGen base32', 'MMGen base32-encoded data created using simple base conversion'),
'b32': dt('MMGen base32',
'MMGen base32-encoded data created using simple base conversion'),
'b16': dt('hexadecimal string', 'base16 (hexadecimal) string data'),
'b10': dt('base10 string', 'base10 (decimal) string data'),
'b8': dt('base8 string', 'base8 (octal) string data'),
'b6d': dt('base6d (die roll)', 'base6 data using the digits from one to six'),
'mmgen': dt('MMGen native mnemonic',
'MMGen native mnemonic seed phrase created using old Electrum wordlist and simple base conversion'),
},
'MMGen native mnemonic seed phrase created using old Electrum wordlist '
'and simple base conversion')},
# https://en.wikipedia.org/wiki/Base32#RFC_4648_Base32_alphabet
# https://tools.ietf.org/html/rfc4648
'digits': {
@ -59,24 +61,22 @@ class baseconv:
'b16': tuple('0123456789abcdef'),
'b10': tuple('0123456789'),
'b8': tuple('01234567'),
'b6d': tuple('123456'),
},
'b6d': tuple('123456')},
'wl_chksum': {
'mmgen': '5ca31424',
'mmgen': '5ca31424'},
# 'tirosh': '48f05e1f', # tirosh truncated to mn_base
# 'tirosh1633': '1a5faeff' # tirosh list is 1633 words long!
},
'seedlen_map': {
'b58': {16:22, 24:33, 32:44},
'b6d': {16:50, 24:75, 32:100},
'mmgen': {16:12, 24:18, 32:24},
},
'mmgen': {16:12, 24:18, 32:24}},
'seedlen_map_rev': {
'b58': {22:16, 33:24, 44:32},
'b6d': {50:16, 75:24, 100:32},
'mmgen': {12:16, 18:24, 24:32},
}
}
'mmgen': {12:16, 18:24, 24:32}}}
def __init__(self, wl_id):

View file

@ -44,8 +44,7 @@ class bip39(baseconv):
160: bc(5, 15),
192: bc(6, 18),
224: bc(7, 21),
256: bc(8, 24),
}
256: bc(8, 24)}
def __init__(self, wl_id='bip39'):
assert wl_id == 'bip39', "initialize with 'bip39' for compatibility with baseconv API"

View file

@ -148,8 +148,7 @@ class BipHDConfig(Lockable):
'coin': coin,
'network': network,
'type': addr_type or None,
'quiet': True
})
'quiet': True})
dfl_type = base_cfg._proto.dfl_mmtype
addr_type = MMGenAddrType(
@ -417,8 +416,7 @@ class BipHDNode(Lockable):
addr_types = {
84: 'bech32',
49: 'segwit',
44: None
}
44: None}
new = bip_hd_nodes[xk.depth]()

View file

@ -84,8 +84,8 @@ class GlobalConstants(Lockable):
'walletchk': _cc(False, False, False, None, [], 'lmw'),
'walletconv': _cc(False, False, False, None, [], 'lmw'),
'walletgen': _cc(False, False, False, None, [], 'lmw'),
'xmrwallet': _cc(True, True, False, '-rx', ['rpc'], 'lmw'),
}
'xmrwallet': _cc(True, True, False, '-rx', ['rpc'], 'lmw')}
altcoin_cmds = ('swaptxcreate', 'swaptxdo', 'xmrwallet')
prog_name = os.path.basename(sys.argv[0])
@ -390,15 +390,14 @@ class Config(Lockable):
'fee_estimate_mode': _ov('nocase_pfx', ['conservative', 'economical']),
'rpc_backend': _ov('nocase_pfx', ['auto', 'httplib', 'curl', 'aiohttp', 'requests']),
'swap_proto': _ov('nocase_pfx', ['thorchain']),
'tx_proxy': _ov('nocase_pfx', ['etherscan']) # , 'blockchair'
}
'tx_proxy': _ov('nocase_pfx', ['etherscan'])} # , 'blockchair'
_dfl_none_autoset_opts = ('tx_proxy',)
_auto_typeset_opts = {
'seed_len': int,
'subseeds': int,
'vsize_adj': float,
}
'vsize_adj': float}
# test suite:
err_disp_timeout = 0.7
@ -962,8 +961,7 @@ def conv_type(name, val, refval, *, src, invert_bool=False):
desc = {
'cmdline': 'command-line',
'cfg': 'Config',
'env': 'environment var',
}
'env': 'environment var'}
die(1, '{a!r}: invalid value for {b} option {c!r}{d} (must be of type {e!r})'.format(
a = val,
b = desc.get(src, 'config file'),

View file

@ -91,8 +91,7 @@ class cfg_file:
d = {
'usr': CfgFileUsr,
'sys': CfgFileSampleSys,
'sample': CfgFileSampleUsr,
}
'sample': CfgFileSampleUsr}
return d[id_str]
class cfg_file_sample(cfg_file):
@ -242,8 +241,7 @@ class CfgFileSampleUsr(cfg_file_sample):
if removed or added:
return {
'removed': [i for i in a_tup if i.name in removed],
'added': [i for i in b_tup if i.name in added],
}
'added': [i for i in b_tup if i.name in added]}
else:
return None

View file

@ -50,8 +50,7 @@ class Crypto:
'4': _hp(15, 8, 12),
'5': _hp(16, 8, 16),
'6': _hp(17, 8, 20),
'7': _hp(18, 8, 24),
}
'7': _hp(18, 8, 24)}
class pwfile_reuse_warning(oneshot_warning):
message = 'Reusing passphrase from file {!r} at user request'
@ -301,7 +300,7 @@ class Crypto:
rand_bytes,
*,
desc,
urand = {'data':b'', 'counter':0}):
urand = {'data': b'', 'counter': 0}):
assert type(rand_bytes) is bytes, 'add_user_random_chk1'

View file

@ -291,8 +291,7 @@ class CoinDaemon(Daemon):
'LTC': _cd(['litecoin_core']),
'XMR': _cd(['monero']),
'ETH': _cd(['geth', 'reth', 'erigon']), #, 'openethereum'
'ETC': _cd(['parity']),
}
'ETC': _cd(['parity'])}
@classmethod
def all_daemon_ids(cls):

View file

@ -72,8 +72,7 @@ def gen_arg_tuple(cfg, func, text):
'proto': proto,
'help_notes': help_notes,
'help_mod': help_mod,
'cfg': cfg,
}
'cfg': cfg}
for arg in func.__code__.co_varnames:
yield d[arg] if arg in d else text

View file

@ -40,8 +40,7 @@ class HTTPClient:
elif cfg.proxy:
self.session.proxies.update({
'http': f'socks5h://{cfg.proxy}',
'https': f'socks5h://{cfg.proxy}'
})
'https': f'socks5h://{cfg.proxy}'})
def call(self, name, path, err_fs, timeout, *, data=None):
url = self.network_proto + '://' + self.host + path

View file

@ -57,17 +57,13 @@ class keygen_base:
backend_data = {
'std': {
'backends': ('libsecp256k1', 'python-ecdsa'),
'package': 'secp256k1',
},
'package': 'secp256k1'},
'monero': {
'backends': ('nacl', 'ed25519ll-djbec', 'ed25519'),
'package': 'xmr',
},
'package': 'xmr'},
'zcash_z': {
'backends': ('nacl',),
'package': 'zec',
},
}
'package': 'zec'}}
def get_backends(pubkey_type):
return backend_data[pubkey_type]['backends']

View file

@ -85,8 +85,7 @@ class LEDControl:
'dummy': binfo(
name = 'Fake Board',
control = '/tmp/led_status',
trigger = '/tmp/led_trigger'),
}
trigger = '/tmp/led_trigger')}
def __init__(self, *, enabled, simulate=False, debug=False):

View file

@ -198,8 +198,7 @@ cfg = Config(
'out_fmt': 'wallet',
'usr_randchars': 0,
'hash_preset': '1',
'label': 'Autosign Wallet',
},
'label': 'Autosign Wallet'},
caller_post_init = True)
cmd = cfg._args[0] if len(cfg._args) == 1 else 'sign' if not cfg._args else cfg._usage()

Some files were not shown because too many files have changed in this diff Show more