1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-03 21:18:17 +00:00
trezor-firmware/docs/core/src/apps.md
2024-02-13 16:51:54 +01:00

1.0 KiB

Apps

The folder src/apps/ is the place where all the user-facing features are implemented.

Each app must be registered by the register function inside the file workflow_handlers.py. This functions assigns what function should be called if some specific message was received. In other words, it is a link between the MicroPython functions and the Protobuf messages.

Example

For a user facing application you would assign the message to the module in _find_message_handler_module. This binds the message GetAddress to function get_address inside the apps.bitcoin.get_address module.

# in core/src/apps/workflow_handlers.py

# ...

def _find_message_handler_module(msg_type: int) -> str:
    from trezor.enums import MessageType

    # ...

    if msg_type == MessageType.GetAddress:
        return "apps.bitcoin.get_address"

    # ...
# in core/src/apps/bitcoin/get_address.py

# ...

async def get_address(msg: GetAddress, keychain: Keychain, coin: CoinInfo) -> Address:
    # ...