use keyword-only parameters where practicable (103 files changed)

This commit is contained in:
The MMGen Project 2025-03-15 18:24:52 +00:00
commit 70022b04b2
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
103 changed files with 307 additions and 279 deletions

View file

@ -54,7 +54,7 @@ class MMGenAddrType(HiliteStr, InitErrors, MMGenObject):
'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'),
}
def __new__(cls, proto, id_str, errmsg=None):
def __new__(cls, proto, id_str, *, errmsg=None):
if isinstance(id_str, cls):
return id_str
try:
@ -99,7 +99,7 @@ class AddrListID(HiliteStr, InitErrors, MMGenObject):
width = 10
trunc_ok = False
color = 'yellow'
def __new__(cls, sid=None, mmtype=None, proto=None, id_str=None):
def __new__(cls, *, sid=None, mmtype=None, proto=None, id_str=None):
try:
if id_str:
a, b = id_str.split(':')

View file

@ -29,7 +29,7 @@ from .addrlist import AddrListEntry, AddrListData, AddrList
class AddrData(MMGenObject):
def __init__(self, proto, *args, **kwargs):
def __init__(self, proto):
self.al_ids = {}
self.proto = proto
self.rpc = None
@ -68,10 +68,10 @@ class AddrData(MMGenObject):
class TwAddrData(AddrData, metaclass=AsyncInit):
def __new__(cls, cfg, proto, *args, **kwargs):
def __new__(cls, cfg, proto, *, twctl=None):
return MMGenObject.__new__(proto.base_proto_subclass(cls, 'addrdata'))
async def __init__(self, cfg, proto, twctl=None):
async def __init__(self, cfg, proto, *, twctl=None):
from .rpc import rpc_init
from .tw.shared import TwLabel
from .seed import SeedID
@ -79,7 +79,7 @@ class TwAddrData(AddrData, metaclass=AsyncInit):
self.proto = proto
self.rpc = await rpc_init(cfg, proto)
self.al_ids = {}
twd = await self.get_tw_data(twctl)
twd = await self.get_tw_data(twctl=twctl)
out, i = {}, 0
for acct, addr_array in twd:
l = get_obj(TwLabel, proto=self.proto, text=acct, silent=True)

View file

@ -30,7 +30,7 @@ class AddrIdxList(tuple, InitErrors, MMGenObject):
max_len = 1000000
def __new__(cls, fmt_str=None, idx_list=None, sep=','):
def __new__(cls, *, fmt_str=None, idx_list=None, sep=','):
try:
if fmt_str:
def gen():
@ -103,7 +103,7 @@ class AddrListIDStr(HiliteStr):
color = 'green'
trunc_ok = False
def __new__(cls, addrlist, fmt_str=None):
def __new__(cls, addrlist, *, fmt_str=None):
idxs = [e.idx for e in addrlist.data]
prev = idxs[0]
ret = [prev]
@ -188,7 +188,7 @@ class AddrList(MMGenObject): # Address info for a single seed ID
src = 'gen'
adata = self.generate(
seed,
addr_idxs if isinstance(addr_idxs, AddrIdxList) else AddrIdxList(addr_idxs))
addr_idxs if isinstance(addr_idxs, AddrIdxList) else AddrIdxList(fmt_str=addr_idxs))
do_chksum = True
elif infile: # data from MMGen address file
self.infile = infile

View file

@ -14,7 +14,7 @@ altcoin.util: various altcoin-related utilities
from ..util import die
def decrypt_keystore(data, passwd, mac_algo=None, mac_params={}):
def decrypt_keystore(data, passwd, *, mac_algo=None, mac_params={}):
"""
Decrypt the encrypted data in a cross-chain keystore
Returns the decrypted data as a bytestring

View file

@ -459,7 +459,7 @@ class Autosign:
def init_fixup(self): # see test/overlay/fakemods/mmgen/autosign.py
pass
def __init__(self, cfg, cmd=None):
def __init__(self, cfg, *, cmd=None):
if cfg.mnemonic_fmt:
if cfg.mnemonic_fmt not in self.mn_fmts:
@ -728,7 +728,7 @@ class Autosign:
def _get_macOS_ramdisk_size(self):
from .platform.darwin.util import MacOSRamDisk, warn_ramdisk_too_small
# allow 1MB for each Monero wallet
xmr_size = len(AddrIdxList(self.cfg.xmrwallets)) if self.cfg.xmrwallets else 0
xmr_size = len(AddrIdxList(fmt_str=self.cfg.xmrwallets)) if self.cfg.xmrwallets else 0
calc_size = xmr_size + 1
usr_size = self.cfg.macos_ramdisk_size or self.cfg.macos_autosign_ramdisk_size
if is_int(usr_size):

View file

@ -113,7 +113,7 @@ class baseconv:
die(3, 'ERROR: List is not sorted!')
@staticmethod
def get_pad(pad, seed_pad_func):
def get_pad(pad, /, seed_pad_func):
"""
'pad' argument to baseconv conversion methods must be either None, 'seed' or an integer.
If None, output of minimum (but never zero) length will be produced.
@ -129,11 +129,11 @@ class baseconv:
else:
die('BaseConversionPadError', f"{pad!r}: illegal value for 'pad' (must be None, 'seed' or int)")
def tohex(self, words_arg, *, pad=None):
def tohex(self, words_arg, /, *, pad=None):
"convert string or list data of instance base to a hexadecimal string"
return self.tobytes(words_arg, pad=pad//2 if type(pad) is int else pad).hex()
def tobytes(self, words_arg, *, pad=None):
def tobytes(self, words_arg, /, *, pad=None):
"convert string or list data of instance base to byte string"
words = words_arg if isinstance(words_arg, (list, tuple)) else tuple(words_arg.strip())
@ -163,7 +163,7 @@ class baseconv:
bl = ret.bit_length()
return ret.to_bytes(max(pad_val, bl//8+bool(bl%8)), 'big')
def fromhex(self, hexstr, *, pad=None, tostr=False):
def fromhex(self, hexstr, /, *, pad=None, tostr=False):
"convert a hexadecimal string to a list or string data of instance base"
from .util import is_hex_str
@ -174,7 +174,7 @@ class baseconv:
return self.frombytes(bytes.fromhex(hexstr), pad=pad, tostr=tostr)
def frombytes(self, bytestr, *, pad=None, tostr=False):
def frombytes(self, bytestr, /, *, pad=None, tostr=False):
"convert byte string to list or string data of instance base"
if not bytestr:

View file

@ -54,24 +54,24 @@ class bip39(baseconv):
self.wl_id = 'bip39'
@classmethod
def nwords2seedlen(cls, nwords, *, in_bytes=False, in_hex=False):
def nwords2seedlen(cls, nwords, /, *, in_bytes=False, in_hex=False):
for k, v in cls.constants.items():
if v.mn_len == nwords:
return k//8 if in_bytes else k//4 if in_hex else k
die('MnemonicError', f'{nwords!r}: invalid word length for BIP39 mnemonic')
@classmethod
def seedlen2nwords(cls, seed_len, *, in_bytes=False, in_hex=False):
def seedlen2nwords(cls, seed_len, /, *, in_bytes=False, in_hex=False):
seed_bits = seed_len * 8 if in_bytes else seed_len * 4 if in_hex else seed_len
try:
return cls.constants[seed_bits].mn_len
except Exception as e:
raise ValueError(f'{seed_bits!r}: invalid seed length for BIP39 mnemonic') from e
def tohex(self, words_arg, pad=None):
def tohex(self, words_arg, /, *, pad=None):
return self.tobytes(words_arg, pad=pad).hex()
def tobytes(self, words_arg, pad=None):
def tobytes(self, words_arg, /, *, pad=None):
assert isinstance(words_arg, (list, tuple)), 'words_arg must be list or tuple'
assert pad in (None, 'seed'), f"{pad}: invalid 'pad' argument (must be None or 'seed')"
@ -105,11 +105,11 @@ class bip39(baseconv):
return seed_bytes
def fromhex(self, hexstr, *, pad=None, tostr=False):
def fromhex(self, hexstr, /, *, pad=None, tostr=False):
assert is_hex_str(hexstr), 'seed data not a hexadecimal string'
return self.frombytes(bytes.fromhex(hexstr), pad=pad, tostr=tostr)
def frombytes(self, seed_bytes, *, pad=None, tostr=False):
def frombytes(self, seed_bytes, /, *, pad=None, tostr=False):
assert tostr is False, "'tostr' must be False for 'bip39'"
assert pad in (None, 'seed'), f"{pad}: invalid 'pad' argument (must be None or 'seed')"
@ -128,7 +128,7 @@ class bip39(baseconv):
return tuple(wl[int(res[i*11:(i+1)*11], 2)] for i in range(c.mn_len))
def generate_seed(self, words_arg, passwd=''):
def generate_seed(self, words_arg, /, *, passwd=''):
self.tohex(words_arg) # validate

View file

@ -137,7 +137,7 @@ class BipHDConfig(Lockable):
supported_coins = ('btc', 'eth', 'doge', 'ltc', 'bch')
def __init__(self, base_cfg, coin, network, addr_type, from_path, no_path_checks):
def __init__(self, base_cfg, coin, *, network, addr_type, from_path, no_path_checks):
if not coin.lower() in self.supported_coins:
raise ValueError(f'bip_hd: coin {coin.upper()} not supported')
@ -196,10 +196,10 @@ class MasterNode(Lockable):
new.cfg = BipHDConfig(
self.base_cfg,
coin,
network,
addr_type,
from_path,
no_path_checks)
network = network,
addr_type = addr_type,
from_path = from_path,
no_path_checks = no_path_checks)
new.par_print = self.par_print
new.depth = self.depth
new.key = self.key
@ -237,7 +237,7 @@ class BipHDNode(Lockable):
'None' if getattr(cls, name) is None else f'None or {getattr(cls, name)}')
)
def set_params(self, cfg, idx, hardened):
def set_params(self, cfg, idx, *, hardened):
self.check_param('idx', idx)
self.check_param('hardened', hardened)
return (
@ -323,7 +323,7 @@ class BipHDNode(Lockable):
def derive_private(self, idx=None, hardened=None):
return self.derive(idx=idx, hardened=hardened, public=False)
def derive(self, idx, hardened, public):
def derive(self, idx, *, hardened, public):
if self.public and not public:
raise ValueError('cannot derive private node from public node!')
@ -341,7 +341,7 @@ class BipHDNode(Lockable):
if new.public and type(new).hardened:
raise ValueError(
f'‘public’ requested, but node of depth {new.depth} ({new.desc}) must be hardened!')
new.idx, new.hardened = new.set_params(new.cfg, idx, hardened)
new.idx, new.hardened = new.set_params(new.cfg, idx, hardened=hardened)
key_in = b'\x00' + self.key if new.hardened else self.pubkey_bytes
@ -398,14 +398,14 @@ class BipHDNode(Lockable):
if not is_int(idx):
raise ValueError(f'invalid path component {s!r}')
res = res.derive(int(idx), hardened, public=False)
res = res.derive(int(idx), hardened=hardened, public=False)
return res
@staticmethod
# ‘addr_type’ is required for broken coins with duplicate version bytes across BIP protocols
# (i.e. Dogecoin)
def from_extended_key(base_cfg, coin, xkey_b58, addr_type=None):
def from_extended_key(base_cfg, coin, xkey_b58, *, addr_type=None):
xk = Bip32ExtendedKey(xkey_b58)
if xk.public:
@ -424,10 +424,10 @@ class BipHDNode(Lockable):
new.cfg = BipHDConfig(
base_cfg,
coin,
xk.network,
addr_type or addr_types[xk.bip_proto],
False,
False)
network = xk.network,
addr_type = addr_type or addr_types[xk.bip_proto],
from_path = False,
no_path_checks = False)
new.par_print = xk.par_print
new.depth = xk.depth
@ -460,7 +460,7 @@ class BipHDNodePurpose(BipHDNode):
desc = 'Purpose'
hardened = True
def set_params(self, cfg, idx, hardened):
def set_params(self, cfg, idx, *, hardened):
self.check_param('hardened', hardened)
if idx not in (None, cfg.bip_proto):
raise ValueError(
@ -472,7 +472,7 @@ class BipHDNodeCoinType(BipHDNode):
desc = 'Coin Type'
hardened = True
def set_params(self, cfg, idx, hardened):
def set_params(self, cfg, idx, *, hardened):
self.check_param('hardened', hardened)
chain_idx = get_chain_params(
bipnum = get_bip_by_addr_type(cfg.addr_type),
@ -498,7 +498,7 @@ class BipHDNodeChain(BipHDNode):
desc = 'Chain'
hardened = False
def set_params(self, cfg, idx, hardened):
def set_params(self, cfg, idx, *, hardened):
self.check_param('hardened', hardened)
if idx not in (0, 1):
raise ValueError(

View file

@ -99,7 +99,7 @@ class GlobalConstants(Lockable):
else:
die2(2, '$HOME is not set! Unable to determine home directory')
def get_mmgen_data_file(self, filename, package='mmgen'):
def get_mmgen_data_file(self, *, filename, package='mmgen'):
"""
this is an expensive import, so do only when required
"""
@ -522,7 +522,7 @@ class Config(Lockable):
# Step 4: set cfg from cfgfile, skipping already-set opts and auto opts; save set opts and auto
# opts to be set:
# requires ‘data_dir_root’, ‘test_suite_cfgtest’
self._cfgfile_opts = self._set_cfg_from_cfg_file(self._envopts, need_proto)
self._cfgfile_opts = self._set_cfg_from_cfg_file(self._envopts, need_proto=need_proto)
# Step 5: set autoset opts from user-supplied data, cfgfile data, or default values, in that order:
self._set_autoset_opts(self._cfgfile_opts.autoset)
@ -615,7 +615,7 @@ class Config(Lockable):
else:
raise ValueError(f'{name!r} is not a valid MMGen environment variable')
def _set_cfg_from_cfg_file(self, env_cfg, need_proto):
def _set_cfg_from_cfg_file(self, env_cfg, *, need_proto):
_ret = namedtuple('cfgfile_opts', ['non_auto', 'autoset', 'auto_typeset'])
@ -761,7 +761,7 @@ def check_opts(cfg): # Raises exception if any check fails
+ (f' in {cfg._cfgfile_fn!r}' if name in cfg._cfgfile_opts.non_auto else '')
)
def display_opt(name, val='', beg='For selected', end=':\n'):
def display_opt(name, val='', *, beg='For selected', end=':\n'):
from .util import msg_r
msg_r('{} option {!r}{}'.format(
beg,
@ -779,11 +779,11 @@ def check_opts(cfg): # Raises exception if any check fails
}[op_str](val, target):
die('UserOptError', f'{val}: invalid {get_desc()} (not {op_str} {target})')
def opt_is_int(val, desc_pfx=''):
def opt_is_int(val, *, desc_pfx=''):
if not is_int(val):
die('UserOptError', f'{val!r}: invalid {get_desc(desc_pfx)} (not an integer)')
def opt_is_in_list(val, tlist, desc_pfx=''):
def opt_is_in_list(val, tlist, *, desc_pfx=''):
if val not in tlist:
q, sep = (('', ','), ("'", "','"))[isinstance(tlist[0], str)]
die('UserOptError', '{q}{v}{q}: invalid {w}\nValid choices: {q}{o}{q}'.format(

View file

@ -190,7 +190,7 @@ class CfgFileSampleSys(cfg_file_sample):
else:
# self.fn is used for error msgs only, so file need not exist on filesystem
self.fn = os.path.join(os.path.dirname(__file__), 'data', self.fn_base)
self.data = gc.get_mmgen_data_file(self.fn_base).splitlines()
self.data = gc.get_mmgen_data_file(filename=self.fn_base).splitlines()
def make_metadata(self):
return [f'# Version {self.cur_ver} {self.computed_chksum}']

View file

@ -89,10 +89,10 @@ class Crypto:
msg(f'Seed: {seed.hex()!r}\nScramble key: {scramble_key}\nScrambled seed: {step1.hex()}\n')
return self.sha256_rounds(step1)
def encrypt_seed(self, data, key, desc='seed'):
def encrypt_seed(self, data, key, *, desc='seed'):
return self.encrypt_data(data, key=key, desc=desc)
def decrypt_seed(self, enc_seed, key, seed_id, key_id):
def decrypt_seed(self, enc_seed, key, *, seed_id, key_id):
self.util.vmsg_r('Checking key...')
chk1 = make_chksum_8(key)
if key_id:
@ -152,6 +152,7 @@ class Crypto:
self,
enc_data,
key,
*,
iv = aesctr_dfl_iv,
desc = 'data'):
@ -167,6 +168,7 @@ class Crypto:
passwd,
salt,
hash_preset,
*,
buflen = 32):
# Buflen arg is for brainwallets only, which use this function to generate
@ -228,7 +230,7 @@ class Crypto:
self.util.dmsg(f'Key: {key.hex()}')
return key
def _get_random_data_from_user(self, uchars=None, desc='data'):
def _get_random_data_from_user(self, uchars=None, *, desc='data'):
if uchars is None:
uchars = self.cfg.usr_randchars
@ -297,6 +299,7 @@ class Crypto:
def add_user_random(
self,
rand_bytes,
*,
desc,
urand = {'data':b'', 'counter':0}):
@ -329,6 +332,7 @@ class Crypto:
def get_hash_preset_from_user(
self,
old_preset = gc.dfl_hash_preset,
*,
data_desc = 'data',
prompt = None):
@ -347,7 +351,7 @@ class Crypto:
else:
return old_preset
def get_new_passphrase(self, data_desc, hash_preset, passwd_file, pw_desc='passphrase'):
def get_new_passphrase(self, data_desc, hash_preset, passwd_file, *, pw_desc='passphrase'):
message = f"""
You must choose a passphrase to encrypt your {data_desc} with.
A key will be generated from your passphrase using a hash preset of '{hash_preset}'.
@ -383,7 +387,7 @@ class Crypto:
return pw
def get_passphrase(self, data_desc, passwd_file, pw_desc='passphrase'):
def get_passphrase(self, data_desc, passwd_file, *, pw_desc='passphrase'):
if passwd_file:
from .fileutil import get_words_from_file
return ' '.join(get_words_from_file(
@ -395,7 +399,7 @@ class Crypto:
from .ui import get_words_from_user
return ' '.join(get_words_from_user(self.cfg, f'Enter {pw_desc} for {data_desc}: '))
def mmgen_encrypt(self, data, desc='data', hash_preset=None):
def mmgen_encrypt(self, data, *, desc='data', hash_preset=None):
salt = self.get_random(self.mmenc_salt_len)
iv = self.get_random(self.aesctr_iv_len)
nonce = self.get_random(self.mmenc_nonce_len)
@ -412,7 +416,7 @@ class Crypto:
enc_d = self.encrypt_data(sha256(nonce+data).digest() + nonce + data, key=key, iv=iv, desc=desc)
return salt+iv+enc_d
def mmgen_decrypt(self, data, desc='data', hash_preset=None):
def mmgen_decrypt(self, data, *, desc='data', hash_preset=None):
self.util.vmsg(f'Preparing to decrypt {desc}')
dstart = self.mmenc_salt_len + self.aesctr_iv_len
salt = data[:self.mmenc_salt_len]
@ -425,7 +429,7 @@ class Crypto:
data_desc = desc,
passwd_file = self.cfg.passwd_file)
key = self.make_key(passwd, salt, hp)
dec_d = self.decrypt_data(enc_d, key, iv, desc)
dec_d = self.decrypt_data(enc_d, key, iv=iv, desc=desc)
sha256_len = 32
from hashlib import sha256
if dec_d[:sha256_len] == sha256(dec_d[sha256_len:]).digest():
@ -435,9 +439,9 @@ class Crypto:
msg('Incorrect passphrase or hash preset')
return False
def mmgen_decrypt_retry(self, d, desc='data'):
def mmgen_decrypt_retry(self, d, *, desc='data'):
while True:
d_dec = self.mmgen_decrypt(d, desc)
d_dec = self.mmgen_decrypt(d, desc=desc)
if d_dec:
return d_dec
msg('Trying again...')

View file

@ -50,7 +50,7 @@ class Daemon(Lockable):
_reset_ok = ('debug', 'wait', 'pids')
version_info_arg = '--version'
def __init__(self, cfg, opts=None, flags=None):
def __init__(self, cfg, *, opts=None, flags=None):
self.cfg = cfg
self.platform = sys.platform
@ -78,7 +78,7 @@ class Daemon(Lockable):
p = Popen(cmd, creationflags=CREATE_NEW_CONSOLE, startupinfo=si)
p.wait()
def exec_cmd(self, cmd, is_daemon=False, check_retcode=False):
def exec_cmd(self, cmd, *, is_daemon=False, check_retcode=False):
out = (PIPE, None)[is_daemon and self.opt.no_daemonize]
try:
cp = run(cmd, check=False, stdout=out, stderr=out)
@ -105,7 +105,7 @@ class Daemon(Lockable):
if self.use_threads and is_daemon and not self.opt.no_daemonize:
ret = self.exec_cmd_thread(cmd)
else:
ret = self.exec_cmd(cmd, is_daemon, check_retcode)
ret = self.exec_cmd(cmd, is_daemon=is_daemon, check_retcode=check_retcode)
if isinstance(ret, CompletedProcess):
if ret.stdout and (self.debug or not silent):
@ -166,7 +166,7 @@ class Daemon(Lockable):
def cli(self, *cmds, silent=False):
return self.run_cmd(self.cli_cmd(*cmds), silent=silent)
def state_msg(self, extra_text=None):
def state_msg(self, *, extra_text=None):
try:
pid = self.pid
except:
@ -225,7 +225,7 @@ class Daemon(Lockable):
self.stop(silent=silent)
return self.start(silent=silent)
def test_socket(self, host, port, timeout=10):
def test_socket(self, host, port, *, timeout=10):
import socket
try:
socket.create_connection((host, port), timeout=timeout).close()
@ -258,7 +258,7 @@ class RPCDaemon(Daemon):
avail_opts = ('no_daemonize',)
def __init__(self, cfg, opts=None, flags=None):
def __init__(self, cfg, *, opts=None, flags=None):
super().__init__(cfg, opts=opts, flags=flags)
self.desc = '{} {} {}RPC daemon'.format(
self.rpc_type,
@ -317,7 +317,7 @@ class CoinDaemon(Daemon):
return ret
@classmethod
def get_daemon(cls, cfg, coin, daemon_id, proto=None):
def get_daemon(cls, cfg, coin, daemon_id, *, proto=None):
if proto:
proto_cls = type(proto)
else:

View file

@ -341,7 +341,7 @@ def get_lines_from_file(
if have_enc_ext or not is_utf8(data):
m = ('Attempting to decrypt', 'Decrypting')[have_enc_ext]
cfg._util.qmsg(f'{m} {desc} ‘{fn}’')
data = Crypto(cfg).mmgen_decrypt_retry(data, desc)
data = Crypto(cfg).mmgen_decrypt_retry(data, desc=desc)
return data
lines = decrypt_file_maybe().decode().splitlines()

View file

@ -69,7 +69,7 @@ class PrivKey(bytes, InitErrors, MMGenObject):
wif = ImmutableAttr(WifKey, typeconv=False)
# initialize with (priv_bin, compressed), WIF or self
def __new__(cls, proto, s=None, compressed=None, wif=None, pubkey_type=None):
def __new__(cls, proto, s=None, *, compressed=None, wif=None, pubkey_type=None):
if isinstance(s, cls):
return s
if wif:
@ -103,7 +103,7 @@ class PrivKey(bytes, InitErrors, MMGenObject):
assert type(compressed) is bool, (
f"'compressed' must be of type bool, not {type(compressed).__name__}")
me = bytes.__new__(cls, proto.preprocess_key(s, pubkey_type))
me.wif = WifKey(proto, proto.encode_wif(me, pubkey_type, compressed))
me.wif = WifKey(proto, proto.encode_wif(me, pubkey_type, compressed=compressed))
me.compressed = compressed
me.pubkey_type = pubkey_type
me.orig_bytes = s # save the non-preprocessed key

View file

@ -78,7 +78,7 @@ def get_pubkey_type_cls(pubkey_type):
importlib.import_module(f'mmgen.proto.{backend_data[pubkey_type]["package"]}.keygen'),
'backend')
def _check_backend(cfg, backend, pubkey_type, desc='keygen backend'):
def _check_backend(cfg, backend, pubkey_type, *, desc='keygen backend'):
from .util import is_int, die

View file

@ -35,6 +35,7 @@ class LEDControl:
def __init__(
self,
*,
name,
control,
trigger = None,
@ -125,7 +126,7 @@ class LEDControl:
))
sys.exit(1)
def init_state(fn, desc, init_val=None):
def init_state(fn, *, desc, init_val=None):
try:
write_init_val(fn, init_val)
except PermissionError:

View file

@ -211,7 +211,7 @@ if cmd not in ('sign', 'wait'):
if getattr(cfg, opt):
die(1, f'--{opt.replace("_", "-")} makes no sense for the ‘{cmd}’ operation')
asi = Autosign(cfg, cmd)
asi = Autosign(cfg, cmd=cmd)
cfg._post_init()

View file

@ -61,13 +61,13 @@ class MsgOps:
class verify(sign):
async def __init__(self, msgfile, addr=None):
async def __init__(self, msgfile, *, addr=None):
try:
m = SignedOnlineMsg(cfg, infile=msgfile)
except:
m = ExportedMsgSigs(cfg, infile=msgfile)
nSigs = await m.verify(addr)
nSigs = await m.verify(addr=addr)
summary = f'{nSigs} signature{suf(nSigs)} verified'
@ -81,13 +81,13 @@ class MsgOps:
class export(sign):
async def __init__(self, msgfile, addr=None):
async def __init__(self, msgfile, *, addr=None):
from .fileutil import write_data_to_file
write_data_to_file(
cfg = cfg,
outfile = 'signatures.json',
data = SignedOnlineMsg(cfg, infile=msgfile).get_json_for_export(addr),
data = SignedOnlineMsg(cfg, infile=msgfile).get_json_for_export(addr=addr),
desc = 'signature data')
opts_data = {
@ -223,7 +223,7 @@ async def main():
elif op in ('verify', 'export'):
if len(cmd_args) not in (1, 2):
cfg._usage()
await getattr(MsgOps, op)(cmd_args[0], cmd_args[1] if len(cmd_args) == 2 else None)
await getattr(MsgOps, op)(cmd_args[0], addr=cmd_args[1] if len(cmd_args) == 2 else None)
else:
die(1, f'{op!r}: unrecognized operation')

View file

@ -151,7 +151,7 @@ async def main():
kal = get_keyaddrlist(cfg, tx1.proto)
kl = get_keylist(cfg)
tx2 = await txsign(cfg, tx1, seed_files, kl, kal, tx_num_disp)
tx2 = await txsign(cfg, tx1, seed_files, kl, kal, tx_num_str=tx_num_disp)
if tx2:
if not cfg.yes:
tx2.add_comment() # edits an existing comment

View file

@ -143,7 +143,7 @@ elif op in ('export-outputs', 'export-outputs-sign', 'import-key-images'):
else:
die(1, f'{op!r}: unrecognized operation')
m = xmrwallet.op(op, cfg, infile, wallets, spec)
m = xmrwallet.op(op, cfg, infile, wallets, spec=spec)
if asyncio.run(m.main()):
m.post_main_success()

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