From c6ef791a6be149d40aee49dba6373fd268881604 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Thu, 22 Feb 2024 12:48:14 +0000 Subject: [PATCH] TxInfo: improve timestamp display --- mmgen/proto/btc/tx/info.py | 4 ++-- mmgen/proto/eth/tx/info.py | 4 ++-- mmgen/tx/info.py | 12 ++++++++++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/mmgen/proto/btc/tx/info.py b/mmgen/proto/btc/tx/info.py index fb950f81..ee56c920 100755 --- a/mmgen/proto/btc/tx/info.py +++ b/mmgen/proto/btc/tx/info.py @@ -19,8 +19,8 @@ from ....addr import MMGenID class TxInfo(TxInfo): sort_orders = ('addr','raw') - txinfo_hdr_fs = 'TRANSACTION DATA\n\nID={i} ({a} {c}) UTC={t} RBF={r} Sig={s} Locktime={l}\n' - txinfo_hdr_fs_short = 'TX {i} ({a} {c}) UTC={t} RBF={r} Sig={s} Locktime={l}\n' + txinfo_hdr_fs = 'TRANSACTION DATA\n\nID={i} ({a} {c}) RBF={r} Sig={s} Locktime={l}\n' + txinfo_hdr_fs_short = 'TX {i} ({a} {c}) RBF={r} Sig={s} Locktime={l}\n' txinfo_ftr_fs = fmt(""" Input amount: {i} {d} Spend amount: {s} {d} diff --git a/mmgen/proto/eth/tx/info.py b/mmgen/proto/eth/tx/info.py index bcb1e765..6cd59413 100755 --- a/mmgen/proto/eth/tx/info.py +++ b/mmgen/proto/eth/tx/info.py @@ -19,8 +19,8 @@ from ....addr import MMGenID from ....obj import Str class TxInfo(TxInfo): - txinfo_hdr_fs = 'TRANSACTION DATA\n\nID={i} ({a} {c}) UTC={t} Sig={s} Locktime={l}\n' - txinfo_hdr_fs_short = 'TX {i} ({a} {c}) UTC={t} Sig={s} Locktime={l}\n' + txinfo_hdr_fs = 'TRANSACTION DATA\n\nID={i} ({a} {c}) Sig={s} Locktime={l}\n' + txinfo_hdr_fs_short = 'TX {i} ({a} {c}) Sig={s} Locktime={l}\n' txinfo_ftr_fs = fmt(""" Total in account: {i} {d} Total to spend: {o} {d} diff --git a/mmgen/tx/info.py b/mmgen/tx/info.py index 7b27900e..56eccce0 100755 --- a/mmgen/tx/info.py +++ b/mmgen/tx/info.py @@ -16,7 +16,8 @@ import importlib from ..cfg import gc from ..color import red,green,orange -from ..util import msg,msg_r +from ..util import msg,msg_r,decode_timestamp,make_timestr +from ..util2 import format_elapsed_hr class TxInfo: @@ -49,13 +50,20 @@ class TxInfo: i = tx.txid.hl(), a = tx.send_amt.hl(), c = tx.dcoin, - t = tx.timestamp, r = green('True') if tx.is_replaceable() else red('False'), s = green('True') if tx.signed else red('False'), l = ( orange(self.strfmt_locktime(terse=True)) if tx.locktime else green('None') )) + for attr,label in [('timestamp','Created:')]: + if (val := getattr(tx,attr)) is not None: + _ = decode_timestamp(val) + yield f'{label:8} {make_timestr(_)} ({format_elapsed_hr(_)})\n' + + if not terse: + yield '\n' + if tx.chain != 'mainnet': # if mainnet has a coin-specific name, display it yield green(f'Chain: {tx.chain.upper()}') + '\n'