You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
trezor-firmware/core/src/apps/cardano/get_native_script_hash.py

27 lines
892 B

from typing import TYPE_CHECKING
from trezor import wire
from trezor.enums import CardanoNativeScriptHashDisplayFormat
from trezor.messages import CardanoNativeScriptHash
from . import native_script, seed
from .layout import show_native_script, show_script_hash
if TYPE_CHECKING:
from trezor.messages import CardanoGetNativeScriptHash
@seed.with_keychain
async def get_native_script_hash(
ctx: wire.Context, msg: CardanoGetNativeScriptHash, keychain: seed.Keychain
) -> CardanoNativeScriptHash:
native_script.validate_native_script(msg.script)
script_hash = native_script.get_native_script_hash(keychain, msg.script)
if msg.display_format != CardanoNativeScriptHashDisplayFormat.HIDE:
await show_native_script(ctx, msg.script)
await show_script_hash(ctx, script_hash, msg.display_format)
return CardanoNativeScriptHash(script_hash=script_hash)