From bbab13f6e7ddacf6d2cbceacf2527d3049cef899 Mon Sep 17 00:00:00 2001 From: Andrew Kozlik Date: Mon, 29 Jun 2020 13:11:43 +0200 Subject: [PATCH] common/protob: Add AuthorizeCoinJoin message. --- common/protob/messages-bitcoin.proto | 15 +++++++ common/protob/messages.proto | 1 + core/src/trezor/messages/AuthorizeCoinJoin.py | 42 +++++++++++++++++++ core/src/trezor/messages/MessageType.py | 1 + legacy/firmware/protob/Makefile | 2 +- .../firmware/protob/messages-bitcoin.options | 6 ++- .../trezorlib/messages/AuthorizeCoinJoin.py | 42 +++++++++++++++++++ python/src/trezorlib/messages/MessageType.py | 1 + python/src/trezorlib/messages/__init__.py | 1 + 9 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 core/src/trezor/messages/AuthorizeCoinJoin.py create mode 100644 python/src/trezorlib/messages/AuthorizeCoinJoin.py diff --git a/common/protob/messages-bitcoin.proto b/common/protob/messages-bitcoin.proto index 8b9d9b5361..abeb31dd3b 100644 --- a/common/protob/messages-bitcoin.proto +++ b/common/protob/messages-bitcoin.proto @@ -298,3 +298,18 @@ message OwnershipProof { required bytes ownership_proof = 1; // SLIP-0019 proof of ownership required bytes signature = 2; // signature of the proof } + +/** + * Request: Ask device to prompt the user to authorize a CoinJoin transaction + * @start + * @next Success + * @next Failure + */ +message AuthorizeCoinJoin { + required string coordinator = 1; // coordinator identifier to approve as a prefix in commitment data (max. 18 ASCII characters) + required uint64 max_total_fee = 2; // maximum total fees + optional uint32 fee_per_anonymity = 3; // fee per anonymity set in units of 10^-9 percent + repeated uint32 address_n = 4; // prefix of the BIP-32 path leading to the account (m / purpose' / coin_type' / account') + optional string coin_name = 5 [default='Bitcoin']; // coin to use + optional InputScriptType script_type = 6 [default=SPENDADDRESS]; // used to distinguish between various address formats (non-segwit, segwit, etc.) +} diff --git a/common/protob/messages.proto b/common/protob/messages.proto index 9ab796dbad..8f649e4864 100644 --- a/common/protob/messages.proto +++ b/common/protob/messages.proto @@ -91,6 +91,7 @@ enum MessageType { MessageType_OwnershipId = 44 [(wire_out) = true]; MessageType_GetOwnershipProof = 49 [(wire_in) = true]; MessageType_OwnershipProof = 50 [(wire_out) = true]; + MessageType_AuthorizeCoinJoin = 51 [(wire_in) = true]; // Crypto MessageType_CipherKeyValue = 23 [(wire_in) = true]; diff --git a/core/src/trezor/messages/AuthorizeCoinJoin.py b/core/src/trezor/messages/AuthorizeCoinJoin.py new file mode 100644 index 0000000000..e59dd6d15f --- /dev/null +++ b/core/src/trezor/messages/AuthorizeCoinJoin.py @@ -0,0 +1,42 @@ +# Automatically generated by pb2py +# fmt: off +import protobuf as p + +if __debug__: + try: + from typing import Dict, List # noqa: F401 + from typing_extensions import Literal # noqa: F401 + EnumTypeInputScriptType = Literal[0, 1, 2, 3, 4] + except ImportError: + pass + + +class AuthorizeCoinJoin(p.MessageType): + MESSAGE_WIRE_TYPE = 51 + + def __init__( + self, + coordinator: str = None, + max_total_fee: int = None, + fee_per_anonymity: int = None, + address_n: List[int] = None, + coin_name: str = None, + script_type: EnumTypeInputScriptType = None, + ) -> None: + self.coordinator = coordinator + self.max_total_fee = max_total_fee + self.fee_per_anonymity = fee_per_anonymity + self.address_n = address_n if address_n is not None else [] + self.coin_name = coin_name + self.script_type = script_type + + @classmethod + def get_fields(cls) -> Dict: + return { + 1: ('coordinator', p.UnicodeType, 0), # required + 2: ('max_total_fee', p.UVarintType, 0), # required + 3: ('fee_per_anonymity', p.UVarintType, 0), + 4: ('address_n', p.UVarintType, p.FLAG_REPEATED), + 5: ('coin_name', p.UnicodeType, 0), # default=Bitcoin + 6: ('script_type', p.EnumType("InputScriptType", (0, 1, 2, 3, 4)), 0), # default=SPENDADDRESS + } diff --git a/core/src/trezor/messages/MessageType.py b/core/src/trezor/messages/MessageType.py index 3a855bf14b..c25e2e866c 100644 --- a/core/src/trezor/messages/MessageType.py +++ b/core/src/trezor/messages/MessageType.py @@ -59,6 +59,7 @@ GetOwnershipId = 43 # type: Literal[43] OwnershipId = 44 # type: Literal[44] GetOwnershipProof = 49 # type: Literal[49] OwnershipProof = 50 # type: Literal[50] +AuthorizeCoinJoin = 51 # type: Literal[51] CipherKeyValue = 23 # type: Literal[23] CipheredKeyValue = 48 # type: Literal[48] SignIdentity = 53 # type: Literal[53] diff --git a/legacy/firmware/protob/Makefile b/legacy/firmware/protob/Makefile index 053328f8a6..535ad42616 100644 --- a/legacy/firmware/protob/Makefile +++ b/legacy/firmware/protob/Makefile @@ -4,7 +4,7 @@ endif SKIPPED_MESSAGES := Binance Cardano DebugMonero Eos Monero Ontology Ripple SdProtect Tezos WebAuthn \ DebugLinkRecordScreen DebugLinkReseedRandom DebugLinkShowText DebugLinkEraseSdCard DebugLinkWatchLayout \ - GetOwnershipProof OwnershipProof GetOwnershipId OwnershipId + GetOwnershipProof OwnershipProof GetOwnershipId OwnershipId AuthorizeCoinJoin ifeq ($(BITCOIN_ONLY), 1) SKIPPED_MESSAGES += Ethereum Lisk NEM Stellar diff --git a/legacy/firmware/protob/messages-bitcoin.options b/legacy/firmware/protob/messages-bitcoin.options index 56bae82263..d3db2a44cf 100644 --- a/legacy/firmware/protob/messages-bitcoin.options +++ b/legacy/firmware/protob/messages-bitcoin.options @@ -50,7 +50,7 @@ MultisigRedeemScriptType.signatures max_count:15 max_siz MultisigRedeemScriptType.nodes max_count:15 MultisigRedeemScriptType.address_n max_count:8 -HDNodePathType.address_n max_count:8 +HDNodePathType.address_n max_count:8 GetOwnershipProof.address_n max_count:8 GetOwnershipProof.coin_name max_size:21 @@ -64,3 +64,7 @@ GetOwnershipId.address_n max_count:8 GetOwnershipId.coin_name max_size:21 OwnershipId.ownership_id max_size:32 + +AuthorizeCoinJoin.coordinator max_size:18 +AuthorizeCoinJoin.address_n max_count:8 +AuthorizeCoinJoin.coin_name max_size:21 diff --git a/python/src/trezorlib/messages/AuthorizeCoinJoin.py b/python/src/trezorlib/messages/AuthorizeCoinJoin.py new file mode 100644 index 0000000000..8a636d7a7f --- /dev/null +++ b/python/src/trezorlib/messages/AuthorizeCoinJoin.py @@ -0,0 +1,42 @@ +# Automatically generated by pb2py +# fmt: off +from .. import protobuf as p + +if __debug__: + try: + from typing import Dict, List # noqa: F401 + from typing_extensions import Literal # noqa: F401 + EnumTypeInputScriptType = Literal[0, 1, 2, 3, 4] + except ImportError: + pass + + +class AuthorizeCoinJoin(p.MessageType): + MESSAGE_WIRE_TYPE = 51 + + def __init__( + self, + coordinator: str = None, + max_total_fee: int = None, + fee_per_anonymity: int = None, + address_n: List[int] = None, + coin_name: str = None, + script_type: EnumTypeInputScriptType = None, + ) -> None: + self.coordinator = coordinator + self.max_total_fee = max_total_fee + self.fee_per_anonymity = fee_per_anonymity + self.address_n = address_n if address_n is not None else [] + self.coin_name = coin_name + self.script_type = script_type + + @classmethod + def get_fields(cls) -> Dict: + return { + 1: ('coordinator', p.UnicodeType, 0), # required + 2: ('max_total_fee', p.UVarintType, 0), # required + 3: ('fee_per_anonymity', p.UVarintType, 0), + 4: ('address_n', p.UVarintType, p.FLAG_REPEATED), + 5: ('coin_name', p.UnicodeType, 0), # default=Bitcoin + 6: ('script_type', p.EnumType("InputScriptType", (0, 1, 2, 3, 4)), 0), # default=SPENDADDRESS + } diff --git a/python/src/trezorlib/messages/MessageType.py b/python/src/trezorlib/messages/MessageType.py index 91a9718c70..ab507d0972 100644 --- a/python/src/trezorlib/messages/MessageType.py +++ b/python/src/trezorlib/messages/MessageType.py @@ -57,6 +57,7 @@ GetOwnershipId = 43 # type: Literal[43] OwnershipId = 44 # type: Literal[44] GetOwnershipProof = 49 # type: Literal[49] OwnershipProof = 50 # type: Literal[50] +AuthorizeCoinJoin = 51 # type: Literal[51] CipherKeyValue = 23 # type: Literal[23] CipheredKeyValue = 48 # type: Literal[48] SignIdentity = 53 # type: Literal[53] diff --git a/python/src/trezorlib/messages/__init__.py b/python/src/trezorlib/messages/__init__.py index 02f413f284..5a7be945f3 100644 --- a/python/src/trezorlib/messages/__init__.py +++ b/python/src/trezorlib/messages/__init__.py @@ -4,6 +4,7 @@ from .Address import Address from .ApplyFlags import ApplyFlags from .ApplySettings import ApplySettings +from .AuthorizeCoinJoin import AuthorizeCoinJoin from .BackupDevice import BackupDevice from .BinanceAddress import BinanceAddress from .BinanceCancelMsg import BinanceCancelMsg