global rename: MMGenTXLabel -> MMGenTxLabel

This commit is contained in:
The MMGen Project 2020-05-18 10:20:27 +00:00
commit 144612c6fc
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
4 changed files with 9 additions and 9 deletions

View file

@ -844,7 +844,7 @@ class TwComment(MMGenLabel):
desc = 'tracking wallet comment'
exc = BadTwComment
class MMGenTXLabel(MMGenLabel):
class MMGenTxLabel(MMGenLabel):
max_len = 72
desc = 'transaction label'

View file

@ -320,7 +320,7 @@ class MMGenTX(MMGenObject):
self.send_amt = g.proto.coin_amt('0') # total amt minus change
self.fee = g.proto.coin_amt('0')
self.hex = '' # raw serialized hex transaction
self.label = MMGenTXLabel('')
self.label = MMGenTxLabel('')
self.txid = ''
self.coin_txid = ''
self.timestamp = ''
@ -421,12 +421,12 @@ class MMGenTX(MMGenObject):
# returns true if comment added or changed
def add_comment(self,infile=None):
if infile:
self.label = MMGenTXLabel(get_data_from_file(infile,'transaction comment'))
self.label = MMGenTxLabel(get_data_from_file(infile,'transaction comment'))
else: # get comment from user, or edit existing comment
m = ('Add a comment to transaction?','Edit transaction comment?')[bool(self.label)]
if keypress_confirm(m,default_yes=False):
while True:
s = MMGenTXLabel(my_raw_input('Comment: ',insert_txt=self.label))
s = MMGenTxLabel(my_raw_input('Comment: ',insert_txt=self.label))
if s:
lbl_save = self.label
self.label = s
@ -1198,7 +1198,7 @@ class MMGenTX(MMGenObject):
if len(tx_data) == 5:
# rough check: allow for 4-byte utf8 characters + base58 (4 * 11 / 8 = 6 (rounded up))
assert len(tx_data[-1]) < MMGenTXLabel.max_len*6,'invalid comment length'
assert len(tx_data[-1]) < MMGenTxLabel.max_len*6,'invalid comment length'
c = tx_data.pop(-1)
if c != '-':
desc = 'encoded comment (not base58)'
@ -1206,7 +1206,7 @@ class MMGenTX(MMGenObject):
comment = baseconv.tobytes(c,'b58').decode()
assert comment != False,'invalid comment'
desc = 'comment'
self.label = MMGenTXLabel(comment,on_fail='raise')
self.label = MMGenTxLabel(comment,on_fail='raise')
desc = 'number of lines' # four required lines
metadata,self.hex,inputs_data,outputs_data = tx_data

View file

@ -184,7 +184,7 @@ tests = {
text_jp[:40],
text_zh[:40] )
},
'MMGenTXLabel':{
'MMGenTxLabel':{
'bad': (utf8_text[:73],utf8_combining[:72],utf8_ctrl[:72],gr_uc_w_ctrl),
'good': (utf8_text[:72],)
},

View file

@ -47,13 +47,13 @@ non_mmgen_fn = 'coinkey'
ref_dir = os.path.join('test','ref')
dfl_words_file = os.path.join(ref_dir,'98831F3A.mmwords')
from mmgen.obj import MMGenTXLabel,TwComment
from mmgen.obj import MMGenTxLabel,TwComment
tx_label_jp = text_jp
tx_label_zh = text_zh
lcg = ascii_cyr_gr if g.platform == 'win' else lat_cyr_gr # MSYS2 popen_spawn issue
tx_label_lat_cyr_gr = lcg[:MMGenTXLabel.max_len] # 72 chars
tx_label_lat_cyr_gr = lcg[:MMGenTxLabel.max_len] # 72 chars
tw_label_zh = text_zh[:TwComment.max_screen_width // 2]
tw_label_lat_cyr_gr = lcg[:TwComment.max_screen_width] # 80 chars