Browse Source

XMR compat: allow sweep transaction to empty account (bugfix)

The MMGen Project 1 month ago
parent
commit
80d122a1d8
3 changed files with 11 additions and 4 deletions
  1. 1 1
      mmgen/proto/xmr/tw/unspent.py
  2. 9 2
      mmgen/proto/xmr/tw/view.py
  3. 1 1
      test/cmdtest_d/xmr_autosign.py

+ 1 - 1
mmgen/proto/xmr/tw/unspent.py

@@ -20,7 +20,6 @@ class MoneroTwUnspentOutputs(MoneroTwView, TwUnspentOutputs):
 
 	hdr_lbl = 'spendable accounts'
 	desc = 'spendable accounts'
-	include_empty = False
 
 	async def __init__(self, cfg, proto, *, minconf=1, addrs=[], tx=None):
 		self.prompt_fs_in = [
@@ -38,6 +37,7 @@ class MoneroTwUnspentOutputs(MoneroTwView, TwUnspentOutputs):
 				's': 'i_addr_sweep',
 				'S': 'i_acct_sweep'})
 		await super().__init__(cfg, proto, minconf=minconf, addrs=addrs, tx=tx)
+		self.is_sweep = self.include_empty = self.tx and self.tx.is_sweep
 
 	async def get_idx_from_user(self, method_name):
 		if method_name in ('i_acct_sweep', 'i_addr_sweep'):

+ 9 - 2
mmgen/proto/xmr/tw/view.py

@@ -29,6 +29,7 @@ class MoneroTwView:
 	item_desc = 'account'
 	nice_addr_w = {'addr': 20}
 	total = None
+	is_sweep = False
 
 	sort_disp = {
 		'addr':   'Addr',
@@ -195,8 +196,14 @@ class MoneroTwView:
 					color = color,
 					color_override = None if d.total == d.unlocked_total else 'orange'
 				)) + rfill
-			for v in d.data.values():
-				yield fmt_method(None, v.data, cw, fs, color, yes, no)
+			if self.is_sweep:
+				if d.total:
+					for v in d.data.values():
+						if v.data.amt:
+							yield fmt_method(None, v.data, cw, fs, color, yes, no)
+			else:
+				for v in d.data.values():
+					yield fmt_method(None, v.data, cw, fs, color, yes, no)
 
 	def squeezed_format_line(self, n, d, cw, fs, color, yes, no):
 		return fs.format(

+ 1 - 1
test/cmdtest_d/xmr_autosign.py

@@ -791,7 +791,7 @@ class CmdTestXMRCompat(CmdTestXMRAutosign):
 		return self._alice_txops('txcreate', menu='S', sweep_menu='23', sweep_type='sweep')
 
 	def alice_txcreate_sweep2(self):
-		return self._alice_txops('txcreate', menu='s', sweep_menu='2', sweep_type='sweep_all')
+		return self._alice_txops('txcreate', menu='s', sweep_menu='3', sweep_type='sweep_all')
 
 	alice_txcreate3 = alice_txcreate2 = alice_txcreate1