Browse Source

xmrwallet: whitespace

The MMGen Project 1 week ago
parent
commit
f86c478cda
4 changed files with 50 additions and 33 deletions
  1. 27 25
      mmgen/xmrwallet/file/tx.py
  2. 14 3
      mmgen/xmrwallet/ops/sweep.py
  3. 4 2
      mmgen/xmrwallet/ops/sync.py
  4. 5 3
      mmgen/xmrwallet/rpc.py

+ 27 - 25
mmgen/xmrwallet/file/tx.py

@@ -74,8 +74,7 @@ class MoneroMMGenTX:
 			'metadata',
 			'metadata',
 			'unsigned_txset',
 			'unsigned_txset',
 			'signed_txset',
 			'signed_txset',
-			'complete',
-		])
+			'complete'])
 
 
 		def __init__(self):
 		def __init__(self):
 			self.name = type(self).__name__
 			self.name = type(self).__name__
@@ -93,11 +92,11 @@ class MoneroMMGenTX:
 					d = orange(self.file_id),
 					d = orange(self.file_id),
 					e = purple(d.op.ljust(9)),
 					e = purple(d.op.ljust(9)),
 					f = red('{}:{}'.format(d.source.wallet, d.source.account).ljust(6)),
 					f = red('{}:{}'.format(d.source.wallet, d.source.account).ljust(6)),
-					g = red('{}:{}'.format(d.dest.wallet, d.dest.account).ljust(6)) if d.dest else cyan('ext   '),
+					g = red('{}:{}'.format(d.dest.wallet, d.dest.account).ljust(6))
+						if d.dest else cyan('ext   '),
 					h = d.amount.fmt(4, color=True, prec=12),
 					h = d.amount.fmt(4, color=True, prec=12),
 					j = d.dest_address.fmt(0, addr_w, color=True) if addr_w else d.dest_address.hl(0),
 					j = d.dest_address.fmt(0, addr_w, color=True) if addr_w else d.dest_address.hl(0),
-					x = '->'
-				)
+					x = '->')
 
 
 		def get_info(self, *, indent='', addr_w=None):
 		def get_info(self, *, indent='', addr_w=None):
 			d = self.data
 			d = self.data
@@ -116,8 +115,7 @@ class MoneroMMGenTX:
 				['  Fee:       {n} XMR'],
 				['  Fee:       {n} XMR'],
 				['  Dest:      {o}'],
 				['  Dest:      {o}'],
 				['  Size:      {Z} bytes', d.signed_txset],
 				['  Size:      {Z} bytes', d.signed_txset],
-				['  Payment ID: {P}', pmt_id],
-			))
+				['  Payment ID: {P}', pmt_id]))
 
 
 			from ...util2 import format_elapsed_hr
 			from ...util2 import format_elapsed_hr
 			from ..ops import addr_width
 			from ..ops import addr_width
@@ -135,19 +133,20 @@ class MoneroMMGenTX:
 					j = d.source.wallet.hl(),
 					j = d.source.wallet.hl(),
 					k = red(f'#{d.source.account}'),
 					k = red(f'#{d.source.account}'),
 					m = d.amount.hl(),
 					m = d.amount.hl(),
-					F = (Int(d.priority).hl() + f' [{tx_priorities[d.priority]}]') if d.priority else None,
+					F = (Int(d.priority).hl() + f' [{tx_priorities[d.priority]}]')
+						if d.priority else None,
 					n = d.fee.hl(),
 					n = d.fee.hl(),
-					o = d.dest_address.hl(0) if self.cfg.full_address
-						else d.dest_address.fmt(0, addr_width, color=True),
+					o = d.dest_address.hl(0)
+						if self.cfg.full_address else d.dest_address.fmt(0, addr_width, color=True),
 					P = pink(pmt_id.hex()) if pmt_id else None,
 					P = pink(pmt_id.hex()) if pmt_id else None,
 					s = make_timestr(d.submit_time) if d.submit_time else None,
 					s = make_timestr(d.submit_time) if d.submit_time else None,
-					S = pink(f" [cold signed{', submitted' if d.complete else ''}]") if d.signed_txset else '',
+					S = pink(f" [cold signed{', submitted' if d.complete else ''}]")
+						if d.signed_txset else '',
 					t = format_elapsed_hr(d.submit_time) if d.submit_time else None,
 					t = format_elapsed_hr(d.submit_time) if d.submit_time else None,
 					x = d.dest.wallet.hl() if d.dest else None,
 					x = d.dest.wallet.hl() if d.dest else None,
 					y = red(f'#{d.dest.account}') if d.dest else None,
 					y = red(f'#{d.dest.account}') if d.dest else None,
 					z = red(f'#{d.dest.account_address}') if d.dest else None,
 					z = red(f'#{d.dest.account_address}') if d.dest else None,
-					Z = Int(len(d.signed_txset) // 2).hl() if d.signed_txset else None,
-				)
+					Z = Int(len(d.signed_txset) // 2).hl() if d.signed_txset else None)
 
 
 		@property
 		@property
 		def file_id(self):
 		def file_id(self):
@@ -162,8 +161,7 @@ class MoneroMMGenTX:
 				a = self.file_id,
 				a = self.file_id,
 				b = self.data.amount,
 				b = self.data.amount,
 				c = '' if self.data.network == 'mainnet' else f'.{self.data.network}',
 				c = '' if self.data.network == 'mainnet' else f'.{self.data.network}',
-				d = self.ext
-			)
+				d = self.ext)
 
 
 			if self.cfg.autosign:
 			if self.cfg.autosign:
 				fn = get_autosign_obj(self.cfg).xmr_tx_dir / fn
 				fn = get_autosign_obj(self.cfg).xmr_tx_dir / fn
@@ -202,8 +200,10 @@ class MoneroMMGenTX:
 
 
 			self.data = self.xmrwallet_tx_data(
 			self.data = self.xmrwallet_tx_data(
 				op             = d.op,
 				op             = d.op,
-				create_time    = now if self.name in ('NewSigned', 'NewUnsigned') else getattr(d, 'create_time', None),
-				sign_time      = now if self.name in ('NewSigned', 'NewColdSigned') else getattr(d, 'sign_time', None),
+				create_time    = now if self.name in ('NewSigned', 'NewUnsigned')
+					else getattr(d, 'create_time', None),
+				sign_time      = now if self.name in ('NewSigned', 'NewColdSigned')
+					else getattr(d, 'sign_time', None),
 				submit_time    = now if self.name == 'NewSubmitted' else None,
 				submit_time    = now if self.name == 'NewSubmitted' else None,
 				network        = d.network,
 				network        = d.network,
 				seed_id        = SeedID(sid=d.seed_id),
 				seed_id        = SeedID(sid=d.seed_id),
@@ -212,14 +212,14 @@ class MoneroMMGenTX:
 				dest_address   = CoinAddr(proto, d.dest_address),
 				dest_address   = CoinAddr(proto, d.dest_address),
 				txid           = CoinTxID(d.txid),
 				txid           = CoinTxID(d.txid),
 				amount         = d.amount,
 				amount         = d.amount,
-				priority       = self.cfg.priority if self.name in ('NewSigned', 'NewUnsigned') else d.priority,
+				priority       = self.cfg.priority if self.name in ('NewSigned', 'NewUnsigned')
+					else d.priority,
 				fee            = d.fee,
 				fee            = d.fee,
 				blob           = d.blob,
 				blob           = d.blob,
 				metadata       = d.metadata,
 				metadata       = d.metadata,
 				unsigned_txset = d.unsigned_txset,
 				unsigned_txset = d.unsigned_txset,
 				signed_txset   = getattr(d, 'signed_txset', None),
 				signed_txset   = getattr(d, 'signed_txset', None),
-				complete       = self.name in ('NewSigned', 'NewSubmitted'),
-			)
+				complete       = self.name in ('NewSigned', 'NewSubmitted'))
 
 
 	class NewUnsigned(New):
 	class NewUnsigned(New):
 		desc = 'unsigned transaction'
 		desc = 'unsigned transaction'
@@ -252,7 +252,8 @@ class MoneroMMGenTX:
 			try:
 			try:
 				d_wrap = self.extract_data_from_file(cfg, fn)
 				d_wrap = self.extract_data_from_file(cfg, fn)
 			except Exception as e:
 			except Exception as e:
-				die('MoneroMMGenTXFileParseError', f'{type(e).__name__}: {e}\nCould not load transaction file')
+				die('MoneroMMGenTXFileParseError',
+					f'{type(e).__name__}: {e}\nCould not load transaction file')
 
 
 			if 'unsigned_txset' in d_wrap['data']: # post-autosign
 			if 'unsigned_txset' in d_wrap['data']: # post-autosign
 				self.full_chksum_fields &= set(d_wrap['data']) # allow for added chksum fields in future
 				self.full_chksum_fields &= set(d_wrap['data']) # allow for added chksum fields in future
@@ -266,8 +267,10 @@ class MoneroMMGenTX:
 			d = self.xmrwallet_tx_data(**d_wrap['data'])
 			d = self.xmrwallet_tx_data(**d_wrap['data'])
 
 
 			if self.name not in ('View', 'Completed'):
 			if self.name not in ('View', 'Completed'):
-				assert fn.name.endswith('.'+self.ext), 'TX file {fn} has incorrect extension (not {self.ext!r})'
-				assert getattr(d, self.req_field), f'{self.name} TX missing required field {self.req_field!r}'
+				assert fn.name.endswith('.' + self.ext), (
+					'TX file {fn} has incorrect extension (not {self.ext!r})')
+				assert getattr(d, self.req_field), (
+					f'{self.name} TX missing required field {self.req_field!r}')
 				assert bool(d.sign_time) == self.signed, '{a} has {b}sign time!'.format(
 				assert bool(d.sign_time) == self.signed, '{a} has {b}sign time!'.format(
 					a = self.desc,
 					a = self.desc,
 					b = 'no ' if self.signed else'')
 					b = 'no ' if self.signed else'')
@@ -294,8 +297,7 @@ class MoneroMMGenTX:
 				metadata       = d.metadata,
 				metadata       = d.metadata,
 				unsigned_txset = d.unsigned_txset,
 				unsigned_txset = d.unsigned_txset,
 				signed_txset   = d.signed_txset,
 				signed_txset   = d.signed_txset,
-				complete       = d.complete,
-			)
+				complete       = d.complete)
 
 
 			self.check_checksums(d_wrap)
 			self.check_checksums(d_wrap)
 
 

+ 14 - 3
mmgen/xmrwallet/ops/sweep.py

@@ -85,7 +85,10 @@ class OpSweep(OpMixinSpec, OpWallet):
 				h, self.account, f'{self.name} from this account [{make_timestr()}]')
 				h, self.account, f'{self.name} from this account [{make_timestr()}]')
 			if dest_addr_chk:
 			if dest_addr_chk:
 				wallet_data = h.get_wallet_data(print=False)
 				wallet_data = h.get_wallet_data(print=False)
-			dest_addr, dest_addr_idx = h.get_last_addr(self.account, wallet_data, display=not dest_addr_chk)
+			dest_addr, dest_addr_idx = h.get_last_addr(
+				self.account,
+				wallet_data,
+				display = not dest_addr_chk)
 			if dest_addr_chk:
 			if dest_addr_chk:
 				h.print_acct_addrs(wallet_data, self.account)
 				h.print_acct_addrs(wallet_data, self.account)
 		elif self.dest_acct is None: # sweep to wallet
 		elif self.dest_acct is None: # sweep to wallet
@@ -118,7 +121,10 @@ class OpSweep(OpMixinSpec, OpWallet):
 				dest_addr_chk = create_new_addr_maybe(h, dest_acct, label)
 				dest_addr_chk = create_new_addr_maybe(h, dest_acct, label)
 				if dest_addr_chk:
 				if dest_addr_chk:
 					wallet_data = h.get_wallet_data(print=False)
 					wallet_data = h.get_wallet_data(print=False)
-				dest_addr, dest_addr_idx = h.get_last_addr(dest_acct, wallet_data, display=not dest_addr_chk)
+				dest_addr, dest_addr_idx = h.get_last_addr(
+					dest_acct,
+					wallet_data,
+					display = not dest_addr_chk)
 				if dest_addr_chk:
 				if dest_addr_chk:
 					h.print_acct_addrs(wallet_data, dest_acct)
 					h.print_acct_addrs(wallet_data, dest_acct)
 				return dest_addr, dest_addr_idx, dest_addr_chk
 				return dest_addr, dest_addr_idx, dest_addr_chk
@@ -143,7 +149,12 @@ class OpSweep(OpMixinSpec, OpWallet):
 			f'dest_addr: ({dest_addr}) != dest_addr_chk: ({dest_addr_chk})')
 			f'dest_addr: ({dest_addr}) != dest_addr_chk: ({dest_addr_chk})')
 
 
 		msg(f'\n    Creating {self.name} transaction...')
 		msg(f'\n    Creating {self.name} transaction...')
-		return (h, h.make_sweep_tx(self.account, dest_acct, dest_addr_idx, dest_addr, wallet_data.addrs_data))
+		return (h, h.make_sweep_tx(
+			self.account,
+			dest_acct,
+			dest_addr_idx,
+			dest_addr,
+			wallet_data.addrs_data))
 
 
 	@property
 	@property
 	def add_desc(self):
 	def add_desc(self):

+ 4 - 2
mmgen/xmrwallet/ops/sync.py

@@ -25,7 +25,8 @@ class OpSync(OpWallet):
 
 
 	def check_uopts(self):
 	def check_uopts(self):
 		if self.cfg.rescan_blockchain and self.cfg.watch_only:
 		if self.cfg.rescan_blockchain and self.cfg.watch_only:
-			die(1, f'Operation ‘{self.name}’ does not support --rescan-blockchain with watch-only wallets')
+			die(1,
+				f'Operation ‘{self.name}’ does not support --rescan-blockchain with watch-only wallets')
 
 
 	def __init__(self, cfg, uarg_tuple):
 	def __init__(self, cfg, uarg_tuple):
 
 
@@ -71,7 +72,8 @@ class OpSync(OpWallet):
 			wallet_height = self.c.call('get_height')['height']
 			wallet_height = self.c.call('get_height')['height']
 			if wallet_height >= chain_height:
 			if wallet_height >= chain_height:
 				break
 				break
-			ymsg(f'  Wallet failed to sync (wallet height [{wallet_height}] < chain height [{chain_height}])')
+			ymsg('  Wallet failed to sync '
+				f'(wallet height [{wallet_height}] < chain height [{chain_height}])')
 			if i or not self.cfg.rescan_blockchain:
 			if i or not self.cfg.rescan_blockchain:
 				break
 				break
 			msg_r('  Rescanning blockchain, please be patient...')
 			msg_r('  Rescanning blockchain, please be patient...')

+ 5 - 3
mmgen/xmrwallet/rpc.py

@@ -88,10 +88,12 @@ class MoneroWalletRPC:
 		accts_data = self.c.call('get_accounts')
 		accts_data = self.c.call('get_accounts')
 		addrs_data = [
 		addrs_data = [
 			self.c.call('get_address', account_index=i)
 			self.c.call('get_address', account_index=i)
-				for i in range(len(accts_data['subaddress_accounts']))
-		]
+				for i in range(len(accts_data['subaddress_accounts']))]
 		if print:
 		if print:
-			msg('\n' + '\n'.join(self.gen_accts_info(accts_data, addrs_data, skip_empty_ok=skip_empty_ok)))
+			msg('\n' + '\n'.join(self.gen_accts_info(
+				accts_data,
+				addrs_data,
+				skip_empty_ok = skip_empty_ok)))
 		bals_data = self.c.call('get_balance', all_accounts=True)
 		bals_data = self.c.call('get_balance', all_accounts=True)
 		return namedtuple('wallet_data', ['accts_data', 'addrs_data', 'bals_data'])(
 		return namedtuple('wallet_data', ['accts_data', 'addrs_data', 'bals_data'])(
 			accts_data, addrs_data, bals_data)
 			accts_data, addrs_data, bals_data)