Browse Source

tw.py: get_tw_label() bugfix

The MMGen Project 4 years ago
parent
commit
bc439e0b3d
4 changed files with 8 additions and 1 deletions
  1. 1 0
      mmgen/exception.py
  2. 1 0
      mmgen/obj.py
  3. 5 1
      mmgen/tw.py
  4. 1 0
      test/objtest_py_d/ot_btc_mainnet.py

+ 1 - 0
mmgen/exception.py

@@ -40,6 +40,7 @@ class InvalidTokenAddress(Exception):     mmcode = 2
 class UnrecognizedTokenSymbol(Exception): mmcode = 2
 class TokenNotInBlockchain(Exception):    mmcode = 2
 class TokenNotInWallet(Exception):        mmcode = 2
+class BadTwComment(Exception):            mmcode = 2
 class BadTwLabel(Exception):              mmcode = 2
 class BaseConversionError(Exception):     mmcode = 2
 class BaseConversionPadError(Exception):  mmcode = 2

+ 1 - 0
mmgen/obj.py

@@ -876,6 +876,7 @@ class MMGenWalletLabel(MMGenLabel):
 class TwComment(MMGenLabel):
 	max_screen_width = 80
 	desc = 'tracking wallet comment'
+	exc = BadTwComment
 
 class MMGenTxLabel(MMGenLabel):
 	max_len = 72

+ 5 - 1
mmgen/tw.py

@@ -32,9 +32,13 @@ CUR_HOME,ERASE_ALL = '\033[H','\033[0J'
 def CUR_RIGHT(n): return '\033[{}C'.format(n)
 
 def get_tw_label(proto,s):
+	"""
+	We must fail only on malformed comment, not on empty label.
+	Otherwise, listaddresses showempty=1 will fail.
+	"""
 	try:
 		return TwLabel(proto,s)
-	except BadTwLabel:
+	except BadTwComment:
 		raise
 	except:
 		return None

+ 1 - 0
test/objtest_py_d/ot_btc_mainnet.py

@@ -265,6 +265,7 @@ tests = {
 		'good':  (utf8_text[:48],)
 	},
 	'TwComment': {
+		'exc_name': 'BadTwComment',
 		'arg1': 's',
 		'bad': (    utf8_combining[:40],
 					utf8_ctrl[:40],