Browse Source

tw.view_and_sort(): cleanups

MMGen 5 years ago
parent
commit
69e09d3b54
2 changed files with 10 additions and 11 deletions
  1. 1 1
      mmgen/altcoins/eth/tw.py
  2. 9 10
      mmgen/tw.py

+ 1 - 1
mmgen/altcoins/eth/tw.py

@@ -192,7 +192,7 @@ Actions:         [q]uit view, [p]rint to file, pager [v]iew, [w]ide view,
 		'a':'s_amt','d':'s_addr','r':'d_reverse','M':'s_twmmid',
 		'm':'d_mmid','e':'d_redraw',
 		'q':'a_quit','p':'a_print','v':'a_view','w':'a_view_wide',
-		'l':'a_lbl_add','R':'a_addr_remove' }
+		'l':'a_lbl_add','R':'a_addr_delete' }
 
 	def do_sort(self,key=None,reverse=False):
 		if key == 'txid': return

+ 9 - 10
mmgen/tw.py

@@ -302,18 +302,16 @@ watch-only wallet using '{}-addrimport' and then re-run this program.
 		fs = '\nTotal unspent: {} {} ({} output%s)' % suf(self.unspent)
 		msg(fs.format(self.total.hl(),g.dcoin,len(self.unspent)))
 
-	def get_idx_from_user(self,get_label=False):
+	def get_idx_from_user(self,action):
 		msg('')
 		while True:
 			ret = my_raw_input('Enter {} number (or RETURN to return to main menu): '.format(self.item_desc))
-			if ret == '': return (None,None) if get_label else None
-			n = AddrIdx(ret,on_fail='silent') # hacky way to test and convert to integer
+			if ret == '': return (None,None) if action == 'a_lbl_add' else None
+			n = AddrIdx(ret,on_fail='silent')
 			if not n or n < 1 or n > len(self.unspent):
 				msg('Choice must be a single number between 1 and {}'.format(len(self.unspent)))
-# 			elif not self.unspent[n-1].mmid:
-# 				msg('Address #{} is not an {} address. No label can be added to it'.format(n,g.proj_name))
 			else:
-				if get_label:
+				if action == 'a_lbl_add':
 					while True:
 						s = my_raw_input("Enter label text (or 'q' to return to main menu): ")
 						if s == 'q':
@@ -326,7 +324,8 @@ watch-only wallet using '{}-addrimport' and then re-run this program.
 							if TwComment(s,on_fail='return'):
 								return n,s
 				else:
-					fs = "Removing {} #{} from tracking wallet.  Is this what you want?"
+					if action == 'a_addr_delete':
+						fs = "Removing {} #{} from tracking wallet.  Is this what you want?"
 					if keypress_confirm(fs.format(self.item_desc,n)):
 						return n
 
@@ -358,7 +357,7 @@ watch-only wallet using '{}-addrimport' and then re-run this program.
 			elif action == 'd_reverse': self.unspent.reverse(); self.reverse = not self.reverse
 			elif action == 'a_quit': msg(''); return self.unspent
 			elif action == 'a_lbl_add':
-				idx,lbl = self.get_idx_from_user(get_label=True)
+				idx,lbl = self.get_idx_from_user(action)
 				if idx:
 					e = self.unspent[idx-1]
 					if TrackingWallet(mode='w').add_label(e.twmmid,lbl,addr=e.addr):
@@ -368,8 +367,8 @@ watch-only wallet using '{}-addrimport' and then re-run this program.
 						oneshot_msg = yellow("Label {} {} #{}\n\n".format(a,self.item_desc,idx))
 					else:
 						oneshot_msg = red('Label could not be added\n\n')
-			elif action == 'a_addr_remove':
-				idx = self.get_idx_from_user()
+			elif action == 'a_addr_delete':
+				idx = self.get_idx_from_user(action)
 				if idx:
 					e = self.unspent[idx-1]
 					if TrackingWallet(mode='w').remove_address(e.addr):