diff --git a/mmgen/main_txsend.py b/mmgen/main_txsend.py index c486d0bf..597720b0 100755 --- a/mmgen/main_txsend.py +++ b/mmgen/main_txsend.py @@ -53,6 +53,7 @@ opts_data = { {tx_proxies}). This is done via a publicly accessible web page, so no API key or registration is required -q, --quiet Suppress warnings; overwrite files without prompting +-r, --receipt Print the receipt of the sent transaction (Ethereum only) -s, --status Get status of a sent transaction (or current transaction, whether sent or unsent, when used with --autosign) -t, --test Test whether the transaction can be sent without sending it @@ -147,6 +148,9 @@ async def main(): await post_send(tx) sys.exit(0) + if cfg.receipt: + sys.exit(await tx.status.display(print_receipt=True)) + if cfg.status: if tx.coin_txid: cfg._util.qmsg(f'{tx.proto.coin} txid: {tx.coin_txid.hl()}') diff --git a/mmgen/proto/eth/tx/status.py b/mmgen/proto/eth/tx/status.py index 2ccbc27b..94c5d5d0 100755 --- a/mmgen/proto/eth/tx/status.py +++ b/mmgen/proto/eth/tx/status.py @@ -13,11 +13,11 @@ proto.eth.tx.status: Ethereum transaction status class """ from ....tx import status as TxBase -from ....util import msg, die, suf, capfirst, pp_fmt +from ....util import msg, Msg, die, suf, capfirst, pp_fmt class Status(TxBase.Status): - async def display(self, *, usr_req=False, return_exit_val=False): + async def display(self, *, usr_req=False, return_exit_val=False, print_receipt=False): def do_exit(retval, message): if return_exit_val: @@ -54,11 +54,12 @@ class Status(TxBase.Status): 'Warning: transaction is in mempool!') return - if usr_req: + if usr_req or print_receipt: ret = await is_in_wallet() - if tx.cfg.verbose: - from ....color import cyan - msg('{}\n{}'.format(cyan('TRANSACTION RECEIPT'), pp_fmt(ret.rx))) + if print_receipt: + import json + Msg(json.dumps(ret.rx, indent=4)) + return not ret.exec_status if ret: if tx.txobj['data'] and not tx.is_swap: cd = capfirst(tx.contract_desc)