whitespace, minor fixes and cleanups

This commit is contained in:
The MMGen Project 2026-11-16 10:45:27 +00:00
commit ded33e7efe
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
4 changed files with 20 additions and 8 deletions

View file

@ -67,7 +67,7 @@ class MoneroTwView:
try:
op = xmrwallet_op('dump_data_refresh', self.cfg, None, None, compat_call=True)
except SocketError as e:
ymsg('\nRefresh failed: ' + str(e))
ymsg(f'Refresh failed: {e}')
await asyncio.sleep(1.5)
return None
else:

View file

@ -79,7 +79,7 @@ class TwAddressesPrune(TwAddresses):
else:
return []
def query_user(self, desc, addrnum, e):
def query_user(self, parent, desc, addrnum, e):
from collections import namedtuple
md = namedtuple('mdata', ['wmsg', 'prompt'])
@ -88,7 +88,7 @@ class TwAddressesPrune(TwAddresses):
red('Address #{a} ({b}) has a balance of {c}!'.format(
a = addrnum,
b = e.twmmid.addr,
c = e.amt.hl3(color=False, unit=self.proto.dcoin))),
c = e.amt.hl3(color=False, unit=parent.proto.dcoin))),
'[p]rune anyway, [P]rune all with balance, [s]kip, [S]kip all with balance: '),
'used': md(
yellow('Address #{a} ({b}) is used!'.format(
@ -120,7 +120,7 @@ class TwAddressesPrune(TwAddresses):
if auto[desc]:
return False
else:
auto[desc], prune = self.query_user(desc, addrnum, e)
auto[desc], prune = self.query_user(parent, desc, addrnum, e)
dfl[desc] = auto[desc] and prune
skip_all_used = auto['used'] and not dfl['used']
if auto[desc]: # we’ve switched to auto mode, so go back and fix up all previous entries

View file

@ -193,6 +193,7 @@ class OpWallet(OpBase):
return 'offline signing ' if self.cfg.offline else 'watch-only ' if self.cfg.watch_only else ''
async def main(self):
if self.need_daemon_start and self.main_starts_daemon:
await self.restart_wallet_daemon()
@ -202,8 +203,9 @@ class OpWallet(OpBase):
b = self.to_process,
c = self.add_wallet_desc,
d = suf(self.to_process)))
data = []
for n, d in enumerate(self.addr_data): # [d.sec,d.addr,d.wallet_passwd,d.viewkey]
for n, d in enumerate(self.addr_data): # [d.idx, d.sec, d.addr, d.wallet_passwd, d.viewkey]
fn = self.get_wallet_fn(d)
if self.is_create and self.stat_wallet(fn):
continue
@ -216,9 +218,12 @@ class OpWallet(OpBase):
h = MoneroWalletRPC(self, d)
if self.main_opens_wallet:
h.open_wallet(self.wallet_desc, refresh=not self.wallet_offline)
data.append(await self.process_wallet(d, h, last=(n == len(self.addr_data) - 1)))
if not self.compat_call:
gmsg(f'\n{len(data)} wallet{suf(len(data))} {self.stem}ed\n')
return data if self.return_data else sum(map(bool, data))
def head_msg(self, wallet_idx, fn):

View file

@ -602,6 +602,7 @@ class CmdTestXMRCompat(CmdTestXMRAutosign):
('mine_blocks_10', 'mining some blocks'),
('user_twview_chk5', 'viewing user’s tracking wallets (check balances)'),
('wait_loop_kill', 'stopping autosign wait loop'),
('stop_daemons', 'stopping all wallet and coin daemons'),
('user_newacct1', 'adding account to user’s tracking wallet (dfl label)'),
('user_newacct2', 'adding account to user’s tracking wallet (no timestr)'),
('user_newacct3', 'adding account to user’s tracking wallet'),
@ -609,8 +610,7 @@ class CmdTestXMRCompat(CmdTestXMRAutosign):
('user_newaddr1', 'adding address to user’s tracking wallet'),
('user_newaddr2', 'adding address to user’s tracking wallet (no timestr)'),
('user_newaddr3', 'adding address to user’s tracking wallet (dfl label)'),
('user_newaddr4', 'adding address to user’s tracking wallet (dfl label, no timestr)'),
('stop_daemons', 'stopping all wallet and coin daemons'))
('user_newaddr4', 'adding address to user’s tracking wallet (dfl label, no timestr)'))
def __init__(self, cfg, trunner, cfgs, spawn):
super().__init__(cfg, trunner, cfgs, spawn)
@ -970,6 +970,9 @@ class CmdTestXMRCompat(CmdTestXMRAutosign):
return t
class CmdTestXMRAutosignDev(CmdTestXMRAutosign):
"""
Monero autosigning operations (non-compat mode, for development)
"""
tx_relay_user = None
user_data = (
# user sid autosign kal_range add_coind_args
@ -1013,10 +1016,11 @@ class CmdTestXMRCompatDev(CmdTestXMRCompat):
('autosign_xmr_setup', 'autosign setup (creation of Monero signing wallet)'),
('addrimport_user', 'creating (importing) user’s watch-only wallet from key-address file'),
('gen_vkafile_user', 'generating viewkey-address file for user'),
('user_listaddresses_refresh', 'refreshing wallet'),
('gen_kafile_miner', 'generating key-address file for Miner'),
('create_wallet_miner', 'creating Monero wallet for Miner'),
('mine_initial_coins', 'mining initial coins'),
# ('user_listaddresses_refresh_loop', 'refreshing wallet'),
# ('mine_blocks_10', 'mining some blocks'),
('fund_user1', 'sending funds to user (wallet #1)'),
('check_bal_alice', 'mining, checking balance'),
('user_txcreate1', 'creating a transaction'),
@ -1029,6 +1033,9 @@ class CmdTestXMRCompatDev(CmdTestXMRCompat):
('wait_loop_kill', 'stopping autosign wait loop'),
('stop_daemons', 'stopping all wallet and coin daemons'))
def user_listaddresses_refresh_loop(self):
return self._user_twops('listaddresses', refresh_loop=True)
def user_view(self):
return self.sync_wallets(self.user, op='listview', wallets='1')