Skip to content

Commit

Permalink
fix(transaction): handle fee parsing for newer CLI output
Browse files Browse the repository at this point in the history
Updated the fee parsing logic to handle the new CLI output format where
the fee is followed by "Lovelace". This ensures compatibility with both
the new and old versions of the `build` command.
  • Loading branch information
mkoura committed Sep 11, 2024
1 parent daa731f commit fb9e798
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cardano_clusterlib/transaction_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -1013,13 +1013,15 @@ def build_tx( # noqa: C901
*self._clusterlib_obj.magic_args,
*self._clusterlib_obj.socket_args,
]
stdout = self._clusterlib_obj.cli(cli_args).stdout
stdout = self._clusterlib_obj.cli(cli_args).stdout.strip()
stdout_dec = stdout.decode("utf-8") if stdout else ""

# check for the presence of fee information so compatibility with older versions
# of the `build` command is preserved
# Check for the presence of fee information. No fee information was provided in older
# versions of the `build` command.
estimated_fee = -1
if "transaction fee" in stdout_dec:
if stdout_dec.endswith("Lovelace"):
estimated_fee = int(stdout_dec.split()[-2])
elif "transaction fee" in stdout_dec:
estimated_fee = int(stdout_dec.split()[-1])

return structs.TxRawOutput(
Expand Down

0 comments on commit fb9e798

Please sign in to comment.