mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-29 18:08:19 +00:00
feat(core): add basic Solana sign_tx call
This commit is contained in:
parent
54aa5cc35a
commit
200a668f2f
@ -371,6 +371,8 @@ apps.solana.get_public_key
|
||||
import apps.solana.get_public_key
|
||||
apps.solana.helpers.paths
|
||||
import apps.solana.helpers.paths
|
||||
apps.solana.sign_tx
|
||||
import apps.solana.sign_tx
|
||||
apps.workflow_handlers
|
||||
import apps.workflow_handlers
|
||||
|
||||
|
29
core/src/apps/solana/sign_tx.py
Normal file
29
core/src/apps/solana/sign_tx.py
Normal file
@ -0,0 +1,29 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from trezor.crypto import base58
|
||||
|
||||
from apps.common.keychain import auto_keychain
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import SolanaSignTx, SolanaSignedTx
|
||||
|
||||
from apps.common.keychain import Keychain
|
||||
|
||||
|
||||
@auto_keychain(__name__)
|
||||
async def sign_tx(
|
||||
msg: SolanaSignTx,
|
||||
keychain: Keychain,
|
||||
) -> SolanaSignedTx:
|
||||
from trezor.crypto.curve import ed25519
|
||||
from trezor.messages import SolanaSignedTx
|
||||
|
||||
signer_path = msg.signer_path_n
|
||||
serialized_tx = msg.serialized_tx
|
||||
|
||||
node = keychain.derive(signer_path)
|
||||
|
||||
signature = ed25519.sign(node.private_key(), serialized_tx)
|
||||
|
||||
# TODO SOL: only one signature per request?
|
||||
return SolanaSignedTx(serialized_tx=serialized_tx, signature=signature)
|
@ -191,6 +191,8 @@ def _find_message_handler_module(msg_type: int) -> str:
|
||||
return "apps.solana.get_public_key"
|
||||
if msg_type == MessageType.SolanaGetAddress:
|
||||
return "apps.solana.get_address"
|
||||
if msg_type == MessageType.SolanaSignTx:
|
||||
return "apps.solana.sign_tx"
|
||||
|
||||
raise ValueError
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user