diff --git a/common/protob/messages-solana.proto b/common/protob/messages-solana.proto index d62f07e296..7acffccdef 100644 --- a/common/protob/messages-solana.proto +++ b/common/protob/messages-solana.proto @@ -41,3 +41,23 @@ message SolanaGetAddress { message SolanaAddress { required string address = 1; // Solana address as Base58 encoded string } + +/** + * Request: Ask device to sign a Solana transaction + * @start + * @next SolanaSignedTx + * @next Failure + */ +message SolanaSignTx { + repeated uint32 signer_path_n = 1; // BIP-32 path to derive the key to sign with + required bytes serialized_tx = 2; // serialized tx to be signed +} + +/** + * Response: Contains the hash of the signed transaction and the signature + * @end + */ +message SolanaSignedTx { + required bytes serialized_tx = 1; // the tx which has been signed (the same data which was passed to SolanaSignTx) + required bytes signature = 2; // tx signature +} diff --git a/common/protob/messages.proto b/common/protob/messages.proto index a3350143d4..52e9884e6b 100644 --- a/common/protob/messages.proto +++ b/common/protob/messages.proto @@ -365,4 +365,6 @@ enum MessageType { MessageType_SolanaPublicKey = 901 [(wire_out) = true]; MessageType_SolanaGetAddress = 902 [(wire_in) = true]; MessageType_SolanaAddress = 903 [(wire_out) = true]; + MessageType_SolanaSignTx = 904 [(wire_in) = true]; + MessageType_SolanaSignedTx = 905 [(wire_out) = true]; } diff --git a/core/src/trezor/enums/MessageType.py b/core/src/trezor/enums/MessageType.py index 203de339d9..856ca60170 100644 --- a/core/src/trezor/enums/MessageType.py +++ b/core/src/trezor/enums/MessageType.py @@ -237,3 +237,5 @@ if not utils.BITCOIN_ONLY: SolanaPublicKey = 901 SolanaGetAddress = 902 SolanaAddress = 903 + SolanaSignTx = 904 + SolanaSignedTx = 905 diff --git a/core/src/trezor/enums/__init__.py b/core/src/trezor/enums/__init__.py index 5d3e370860..8cfe78cc22 100644 --- a/core/src/trezor/enums/__init__.py +++ b/core/src/trezor/enums/__init__.py @@ -255,6 +255,8 @@ if TYPE_CHECKING: SolanaPublicKey = 901 SolanaGetAddress = 902 SolanaAddress = 903 + SolanaSignTx = 904 + SolanaSignedTx = 905 class FailureType(IntEnum): UnexpectedMessage = 1 diff --git a/core/src/trezor/messages.py b/core/src/trezor/messages.py index 482ac2201f..17419fb7f2 100644 --- a/core/src/trezor/messages.py +++ b/core/src/trezor/messages.py @@ -5164,6 +5164,38 @@ if TYPE_CHECKING: def is_type_of(cls, msg: Any) -> TypeGuard["SolanaAddress"]: return isinstance(msg, cls) + class SolanaSignTx(protobuf.MessageType): + signer_path_n: "list[int]" + serialized_tx: "bytes" + + def __init__( + self, + *, + serialized_tx: "bytes", + signer_path_n: "list[int] | None" = None, + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["SolanaSignTx"]: + return isinstance(msg, cls) + + class SolanaSignedTx(protobuf.MessageType): + serialized_tx: "bytes" + signature: "bytes" + + def __init__( + self, + *, + serialized_tx: "bytes", + signature: "bytes", + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["SolanaSignedTx"]: + return isinstance(msg, cls) + class StellarAsset(protobuf.MessageType): type: "StellarAssetType" code: "str | None" diff --git a/python/src/trezorlib/messages.py b/python/src/trezorlib/messages.py index 19bbf2d516..3cbc9febdb 100644 --- a/python/src/trezorlib/messages.py +++ b/python/src/trezorlib/messages.py @@ -263,6 +263,8 @@ class MessageType(IntEnum): SolanaPublicKey = 901 SolanaGetAddress = 902 SolanaAddress = 903 + SolanaSignTx = 904 + SolanaSignedTx = 905 class FailureType(IntEnum): @@ -6588,6 +6590,40 @@ class SolanaAddress(protobuf.MessageType): self.address = address +class SolanaSignTx(protobuf.MessageType): + MESSAGE_WIRE_TYPE = 904 + FIELDS = { + 1: protobuf.Field("signer_path_n", "uint32", repeated=True, required=False, default=None), + 2: protobuf.Field("serialized_tx", "bytes", repeated=False, required=True), + } + + def __init__( + self, + *, + serialized_tx: "bytes", + signer_path_n: Optional[Sequence["int"]] = None, + ) -> None: + self.signer_path_n: Sequence["int"] = signer_path_n if signer_path_n is not None else [] + self.serialized_tx = serialized_tx + + +class SolanaSignedTx(protobuf.MessageType): + MESSAGE_WIRE_TYPE = 905 + FIELDS = { + 1: protobuf.Field("serialized_tx", "bytes", repeated=False, required=True), + 2: protobuf.Field("signature", "bytes", repeated=False, required=True), + } + + def __init__( + self, + *, + serialized_tx: "bytes", + signature: "bytes", + ) -> None: + self.serialized_tx = serialized_tx + self.signature = signature + + class StellarAsset(protobuf.MessageType): MESSAGE_WIRE_TYPE = None FIELDS = {