mmgen-xmrwallet: add date and ID to TX display

This commit is contained in:
The MMGen Project 2022-10-07 19:48:51 +00:00
commit f4c3eaccd3
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
3 changed files with 31 additions and 10 deletions

View file

@ -377,6 +377,22 @@ def secs_to_hms(secs):
def secs_to_ms(secs):
return '{:02d}:{:02d}'.format(secs//60, secs % 60)
def format_elapsed_hr(t,now=None,cached={}):
now = now or time.time()
e = int(now - t)
if not e in cached:
abs_e = abs(e)
d = abs_e // 86400 # 60 * 60 * 24
h = abs_e // 3600 % 24
m = abs_e // 60 % 60
cached[e] = '{d}{h}{m} minute{M} {w}'.format(
d = '{} day{}, '.format(d,suf(d)) if d else '',
h = '{} hour{}, '.format(h,suf(h)) if h else '',
m = m,
M = suf(m),
w = 'ago' if e > 0 else 'in the future' ) if (h or m) else 'just now'
return cached[e]
def is_int(s):
try:
int(str(s))

View file

@ -119,7 +119,7 @@ class MoneroMMGenTX:
def get_info(self,indent=''):
d = self.data
if d.dest:
to_entry = f'\n{indent} To: ' + (
to_entry = f'\n{indent} To: ' + (
'Wallet {}, account {}, address {}'.format(
d.dest.wallet.hl(),
red(f'#{d.dest.account}'),
@ -128,13 +128,14 @@ class MoneroMMGenTX:
)
fs = """
Transaction info [Seed ID: {}. Network: {}]:
TxID: {}
Type: {}
From: Wallet {}, account {}{}
Amt: {} XMR
Fee: {} XMR
Dest: {}
Info for transaction {} [Seed ID: {}. Network: {}]:
TxID: {}
Signed: {} [{}]
Type: {}
From: Wallet {}, account {}{}
Amount: {} XMR
Fee: {} XMR
Dest: {}
"""
pmid = d.dest_address.parsed.payment_id
@ -142,8 +143,12 @@ class MoneroMMGenTX:
fs += ' Payment ID: {pmid}'
return fmt(fs,strip_char='\t',indent=indent).format(
d.seed_id.hl(), d.network.upper(),
orange(self.base_chksum.upper()),
d.seed_id.hl(),
yellow(d.network.upper()),
d.txid.hl(),
make_timestr(d.sign_time),
format_elapsed_hr(d.sign_time),
blue(capfirst(d.op)),
d.source.wallet.hl(),
red(f'#{d.source.account}'),

View file

@ -429,7 +429,7 @@ class TestSuiteXMRWallet(TestSuiteBase):
t.expect( r'to last existing account .* \(y/N\): ','y', regex=True )
if return_amt:
amt = XMRAmt(strip_ansi_escapes(t.expect_getend('Amt: ')).replace('XMR','').strip())
amt = XMRAmt(strip_ansi_escapes(t.expect_getend('Amount: ')).replace('XMR','').strip())
if no_relay:
t.expect('Save MoneroMMGenTX data? (y/N): ','y')