Skip to content

feat(transaction): add conditional --output-text flag #297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions cardano_clusterlib/transaction_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,24 @@ def get_txid(self, tx_body_file: itp.FileType = "", tx_file: itp.FileType = "")
Returns:
str: A transaction ID.
"""
cli_args = []

# The `--output-text` option is available since 10.3.0.0 and is the default
# until about 10.8.0.0. Then the JSON format became the default.
# Adding the option for cli >= 10.7.0.0, because the option was already available.
if self._clusterlib_obj.cli_version >= version.parse("10.7.0.0"):
cli_args.append("--output-text")

if tx_body_file:
cli_args = ["--tx-body-file", str(tx_body_file)]
cli_args.extend(["--tx-body-file", str(tx_body_file)])
elif tx_file:
cli_args = ["--tx-file", str(tx_file)]
cli_args.extend(["--tx-file", str(tx_file)])
else:
msg = "Either `tx_body_file` or `tx_file` is needed."
raise AssertionError(msg)

return (
self._clusterlib_obj.cli(["transaction", "txid", "--output-text", *cli_args])
self._clusterlib_obj.cli(["transaction", "txid", *cli_args])
.stdout.rstrip()
.decode("ascii")
)
Expand Down
Loading