Skip to content

Commit

Permalink
feat(cardano): display tx id for plutus txs
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmisiak committed Mar 11, 2022
1 parent 2b8f2d5 commit c860396
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
4 changes: 4 additions & 0 deletions core/src/apps/cardano/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ async def confirm_transaction(
ttl: int | None,
validity_interval_start: int | None,
is_network_id_verifiable: bool,
tx_hash: bytes | None,
) -> None:
props: list[PropertyType] = [
("Transaction fee:", format_coin_amount(fee)),
Expand All @@ -456,6 +457,9 @@ async def confirm_transaction(
props.append((f"Valid since: {format_optional_int(validity_interval_start)}", None))
props.append((f"TTL: {format_optional_int(ttl)}", None))

if tx_hash:
props.append(("Transaction ID:", tx_hash))

await confirm_properties(
ctx,
"confirm_total",
Expand Down
20 changes: 17 additions & 3 deletions core/src/apps/cardano/sign_tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,10 @@ async def sign_tx(
with tx_dict:
await _process_transaction(ctx, msg, keychain, tx_dict, account_path_checker)

await _confirm_transaction(ctx, msg, is_network_id_verifiable)
tx_hash = hash_fn.digest()
await _confirm_transaction(ctx, msg, is_network_id_verifiable, tx_hash)

try:
tx_hash = hash_fn.digest()
response_after_witness_requests = await _process_witness_requests(
ctx,
keychain,
Expand Down Expand Up @@ -362,11 +362,11 @@ async def _confirm_transaction(
ctx: wire.Context,
msg: CardanoSignTxInit,
is_network_id_verifiable: bool,
tx_hash: bytes,
) -> None:
if msg.signing_mode in (
CardanoTxSigningMode.ORDINARY_TRANSACTION,
CardanoTxSigningMode.MULTISIG_TRANSACTION,
CardanoTxSigningMode.PLUTUS_TRANSACTION,
):
await confirm_transaction(
ctx,
Expand All @@ -375,6 +375,20 @@ async def _confirm_transaction(
msg.ttl,
msg.validity_interval_start,
is_network_id_verifiable,
tx_hash=None,
)
elif msg.signing_mode == CardanoTxSigningMode.PLUTUS_TRANSACTION:
# we display tx hash so that experienced users can compare it to the tx hash computed by
# a trusted device (in case the tx contains many items which are tedious to check one by
# one on the Trezor screen)
await confirm_transaction(
ctx,
msg.fee,
msg.protocol_magic,
msg.ttl,
msg.validity_interval_start,
is_network_id_verifiable,
tx_hash,
)
elif msg.signing_mode == CardanoTxSigningMode.POOL_REGISTRATION_AS_OWNER:
await confirm_stake_pool_registration_final(
Expand Down

0 comments on commit c860396

Please sign in to comment.