whitespace, comments, minor cleanups

This commit is contained in:
The MMGen Project 2025-03-15 18:24:52 +00:00
commit 168e6bbc56
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
9 changed files with 34 additions and 23 deletions

View file

@ -186,7 +186,9 @@ class AddrList(MMGenObject): # Address info for a single seed ID
if seed and addr_idxs: # data from seed + idxs
self.al_id = AddrListID(sid=seed.sid, mmtype=MMGenAddrType(proto, mmtype or proto.dfl_mmtype))
src = 'gen'
adata = self.generate(seed, addr_idxs if isinstance(addr_idxs, AddrIdxList) else AddrIdxList(addr_idxs))
adata = self.generate(
seed,
addr_idxs if isinstance(addr_idxs, AddrIdxList) else AddrIdxList(addr_idxs))
do_chksum = True
elif infile: # data from MMGen address file
self.infile = infile

View file

@ -193,7 +193,13 @@ class MasterNode(Lockable):
new = BipHDNodeMaster()
new.cfg = BipHDConfig(self.base_cfg, coin, network, addr_type, from_path, no_path_checks)
new.cfg = BipHDConfig(
self.base_cfg,
coin,
network,
addr_type,
from_path,
no_path_checks)
new.par_print = self.par_print
new.depth = self.depth
new.key = self.key

View file

@ -33,7 +33,13 @@ class LEDControl:
class binfo(Lockable):
_reset_ok = ('trigger_reset',)
def __init__(self, name, control, trigger=None, trigger_dfl='heartbeat', trigger_disable='none'):
def __init__(
self,
name,
control,
trigger = None,
trigger_dfl = 'heartbeat',
trigger_disable = 'none'):
self.name = name
self.control = control
self.trigger = trigger

View file

@ -126,22 +126,18 @@ class PasswordList(AddrList):
die('InvalidPasswdFormat',
f'{self.pw_fmt!r}: invalid password format. Valid formats: {", ".join(self.pw_info)}')
def chk_pw_len(self, passwd=None):
if passwd is None:
assert self.pw_len, 'either passwd or pw_len must be set'
pw_len = self.pw_len
fs = '{l}: invalid user-requested length for {b} ({c}{m})'
else:
pw_len = len(passwd)
fs = '{pw}: {b} has invalid length {l} ({c}{m} characters)'
def chk_pw_len(self):
assert self.pw_len, 'pw_len must be set'
pw_len = self.pw_len
fs = '{l}: invalid user-requested length for {b} ({c}{m})'
d = self.pw_info[self.pw_fmt]
if d.valid_lens:
if pw_len not in d.valid_lens:
die(2, fs.format(l=pw_len, b=d.desc, c='not one of ', m=d.valid_lens, pw=passwd))
die(2, fs.format(l=pw_len, b=d.desc, c='not one of ', m=d.valid_lens))
elif pw_len > d.max_len:
die(2, fs.format(l=pw_len, b=d.desc, c='>', m=d.max_len, pw=passwd))
die(2, fs.format(l=pw_len, b=d.desc, c='>', m=d.max_len))
elif pw_len < d.min_len:
die(2, fs.format(l=pw_len, b=d.desc, c='<', m=d.min_len, pw=passwd))
die(2, fs.format(l=pw_len, b=d.desc, c='<', m=d.min_len))
def set_pw_len(self, pw_len):
d = self.pw_info[self.pw_fmt]

View file

@ -65,7 +65,7 @@ class mainnet(CoinProtocol.Secp256k1): # chainparams.cpp
'cashaddr',
)
def encode_wif(self, privbytes, pubkey_type, compressed): # input is preprocessed hex
def encode_wif(self, privbytes, pubkey_type, compressed): # input is preprocessed
assert len(privbytes) == self.privkey_len, f'{len(privbytes)} bytes: incorrect private key length!'
assert pubkey_type in self.wif_ver_bytes, f'{pubkey_type!r}: invalid pubkey_type'
return b58chk_encode(

View file

@ -75,10 +75,6 @@ class Completed(Base, TxBase.Completed):
'scriptPubKey:', i.scriptPubKey,
'scriptPubKey->address:', ds.addr))
# def is_replaceable_from_rpc(self):
# dec_tx = await self.rpc.call('decoderawtransaction', self.serialized)
# return None < dec_tx['vin'][0]['sequence'] <= self.proto.max_int - 2
def is_replaceable(self):
return self.inputs[0].sequence == self.proto.max_int - 2

View file

@ -125,7 +125,10 @@ class New(Base, TxNew):
def final_inputs_ok_msg(self, funds_left):
return 'Transaction produces {} {} in change'.format(funds_left.hl(), self.coin)
def check_chg_addr_is_wallet_addr(self, output=None, message='Change address is not an MMGen wallet address!'):
def check_chg_addr_is_wallet_addr(
self,
output = None,
message = 'Change address is not an MMGen wallet address!'):
def do_err():
from ....ui import confirm_or_raise
confirm_or_raise(

View file

@ -82,7 +82,8 @@ class EthereumRPCClient(RPCClient, metaclass=AsyncInit):
if self.daemon.id in ('parity', 'openethereum'):
if (await self.call('parity_nodeKind'))['capability'] == 'full':
self.caps += ('full_node',)
self.chainID = None if ci is None else Int(ci, 16) # parity/oe return chainID only for dev chain
# parity/openethereum return chainID only for dev chain:
self.chainID = None if ci is None else Int(ci, 16)
self.chain = (await self.call('parity_chain')).replace(' ', '_').replace('_testnet', '')
elif self.daemon.id in ('geth', 'reth', 'erigon'):
if self.daemon.network == 'mainnet':

View file

@ -72,7 +72,8 @@ init_tests() {
"
[ "$VERBOSE" ] || STDOUT_DEVNULL='> /dev/null'
d_lint="code errors with static code analyzer"
d_lint="code errors with Ruff static code analyzer"
e_lint="Error checking failed!"
t_lint="
b ruff check setup.py $STDOUT_DEVNULL
b ruff check mmgen $STDOUT_DEVNULL
@ -81,7 +82,7 @@ init_tests() {
"
PYLINT_OPTS='--errors-only --jobs=0'
d_pylint="code errors with static code analyzer"
d_pylint="code errors with Pylint static code analyzer"
e_pylint="Error checking failed!"
t_pylint="
b $pylint $PYLINT_OPTS mmgen