From 5cf873a03a545ebaa28f81e9d7a69ee8ecc37a5f Mon Sep 17 00:00:00 2001 From: overcat <4catcode@gmail.com> Date: Thu, 5 Aug 2021 22:18:43 +0800 Subject: [PATCH] feat(python/stellar): print a readable message when the user has not submitted a base64-encoded transaction envelope. --- python/src/trezorlib/cli/stellar.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/python/src/trezorlib/cli/stellar.py b/python/src/trezorlib/cli/stellar.py index 5c93c57be..1a5908b9d 100644 --- a/python/src/trezorlib/cli/stellar.py +++ b/python/src/trezorlib/cli/stellar.py @@ -83,8 +83,17 @@ def sign_transaction(client, b64envelope, address, network_passphrase): click.echo() click.echo(" pip install stellar-sdk") sys.exit(1) + try: + envelope = parse_transaction_envelope_from_xdr(b64envelope, network_passphrase) + except Exception: + click.echo( + "Failed to parse XDR.\n" + "Make sure to pass a valid TransactionEnvelope object.\n" + "You can check whether the data you submitted is valid TransactionEnvelope object " + "through XDRViewer - https://laboratory.stellar.org/#xdr-viewer\n" + ) + sys.exit(1) - envelope = parse_transaction_envelope_from_xdr(b64envelope, network_passphrase) if isinstance(envelope, FeeBumpTransactionEnvelope): click.echo("FeeBumpTransactionEnvelope is not supported") sys.exit(1)