1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-18 20:38:10 +00:00

chore(common): Rework AuthorizeCoinJoin message parameters.

[no changelog]
This commit is contained in:
Andrew Kozlik 2022-03-15 19:26:25 +01:00 committed by Andrew Kozlik
parent 556e8a147a
commit 8be6689150
4 changed files with 32 additions and 24 deletions

View File

@ -599,10 +599,11 @@ message AuthorizeCoinJoin {
option (unstable) = true; option (unstable) = true;
required string coordinator = 1; // coordinator identifier to approve as a prefix in commitment data (max. 36 ASCII characters) required string coordinator = 1; // coordinator identifier to approve as a prefix in commitment data (max. 36 ASCII characters)
required uint64 max_total_fee = 2; // maximum total fees required uint64 max_rounds = 2; // maximum number of rounds that Trezor is authorized to take part in
optional uint32 fee_per_anonymity = 3 [default=0]; // fee per anonymity set in units of 10^-9 percent required uint32 max_coordinator_fee_rate = 3; // maximum coordination fee rate in units of 10^-8 percent
repeated uint32 address_n = 4; // prefix of the BIP-32 path leading to the account (m / purpose' / coin_type' / account') required uint32 max_fee_per_kvbyte = 4; // maximum mining fee rate in units of satoshis per 1000 vbytes
optional string coin_name = 5 [default='Bitcoin']; // coin to use repeated uint32 address_n = 5; // prefix of the BIP-32 path leading to the account (m / purpose' / coin_type' / account')
optional InputScriptType script_type = 6 [default=SPENDADDRESS]; // used to distinguish between various address formats (non-segwit, segwit, etc.) optional string coin_name = 6 [default='Bitcoin']; // coin to use
optional AmountUnit amount_unit = 11 [default=BITCOIN]; // show amounts in optional InputScriptType script_type = 7 [default=SPENDADDRESS]; // used to distinguish between various address formats (non-segwit, segwit, etc.)
optional AmountUnit amount_unit = 8 [default=BITCOIN]; // show amounts in
} }

View File

@ -926,8 +926,9 @@ if TYPE_CHECKING:
class AuthorizeCoinJoin(protobuf.MessageType): class AuthorizeCoinJoin(protobuf.MessageType):
coordinator: "str" coordinator: "str"
max_total_fee: "int" max_rounds: "int"
fee_per_anonymity: "int" max_coordinator_fee_rate: "int"
max_fee_per_kvbyte: "int"
address_n: "list[int]" address_n: "list[int]"
coin_name: "str" coin_name: "str"
script_type: "InputScriptType" script_type: "InputScriptType"
@ -937,9 +938,10 @@ if TYPE_CHECKING:
self, self,
*, *,
coordinator: "str", coordinator: "str",
max_total_fee: "int", max_rounds: "int",
max_coordinator_fee_rate: "int",
max_fee_per_kvbyte: "int",
address_n: "list[int] | None" = None, address_n: "list[int] | None" = None,
fee_per_anonymity: "int | None" = None,
coin_name: "str | None" = None, coin_name: "str | None" = None,
script_type: "InputScriptType | None" = None, script_type: "InputScriptType | None" = None,
amount_unit: "AmountUnit | None" = None, amount_unit: "AmountUnit | None" = None,

View File

@ -404,19 +404,21 @@ def sign_tx(
def authorize_coinjoin( def authorize_coinjoin(
client: "TrezorClient", client: "TrezorClient",
coordinator: str, coordinator: str,
max_total_fee: int, max_rounds: int,
max_coordinator_fee_rate: int,
max_fee_per_kvbyte: int,
n: "Address", n: "Address",
coin_name: str, coin_name: str,
fee_per_anonymity: Optional[int] = None,
script_type: messages.InputScriptType = messages.InputScriptType.SPENDADDRESS, script_type: messages.InputScriptType = messages.InputScriptType.SPENDADDRESS,
) -> "MessageType": ) -> "MessageType":
return client.call( return client.call(
messages.AuthorizeCoinJoin( messages.AuthorizeCoinJoin(
coordinator=coordinator, coordinator=coordinator,
max_total_fee=max_total_fee, max_rounds=max_rounds,
max_coordinator_fee_rate=max_coordinator_fee_rate,
max_fee_per_kvbyte=max_fee_per_kvbyte,
address_n=n, address_n=n,
coin_name=coin_name, coin_name=coin_name,
fee_per_anonymity=fee_per_anonymity,
script_type=script_type, script_type=script_type,
) )
) )

View File

@ -1565,29 +1565,32 @@ class AuthorizeCoinJoin(protobuf.MessageType):
MESSAGE_WIRE_TYPE = 51 MESSAGE_WIRE_TYPE = 51
FIELDS = { FIELDS = {
1: protobuf.Field("coordinator", "string", repeated=False, required=True), 1: protobuf.Field("coordinator", "string", repeated=False, required=True),
2: protobuf.Field("max_total_fee", "uint64", repeated=False, required=True), 2: protobuf.Field("max_rounds", "uint64", repeated=False, required=True),
3: protobuf.Field("fee_per_anonymity", "uint32", repeated=False, required=False), 3: protobuf.Field("max_coordinator_fee_rate", "uint32", repeated=False, required=True),
4: protobuf.Field("address_n", "uint32", repeated=True, required=False), 4: protobuf.Field("max_fee_per_kvbyte", "uint32", repeated=False, required=True),
5: protobuf.Field("coin_name", "string", repeated=False, required=False), 5: protobuf.Field("address_n", "uint32", repeated=True, required=False),
6: protobuf.Field("script_type", "InputScriptType", repeated=False, required=False), 6: protobuf.Field("coin_name", "string", repeated=False, required=False),
11: protobuf.Field("amount_unit", "AmountUnit", repeated=False, required=False), 7: protobuf.Field("script_type", "InputScriptType", repeated=False, required=False),
8: protobuf.Field("amount_unit", "AmountUnit", repeated=False, required=False),
} }
def __init__( def __init__(
self, self,
*, *,
coordinator: "str", coordinator: "str",
max_total_fee: "int", max_rounds: "int",
max_coordinator_fee_rate: "int",
max_fee_per_kvbyte: "int",
address_n: Optional[Sequence["int"]] = None, address_n: Optional[Sequence["int"]] = None,
fee_per_anonymity: Optional["int"] = 0,
coin_name: Optional["str"] = 'Bitcoin', coin_name: Optional["str"] = 'Bitcoin',
script_type: Optional["InputScriptType"] = InputScriptType.SPENDADDRESS, script_type: Optional["InputScriptType"] = InputScriptType.SPENDADDRESS,
amount_unit: Optional["AmountUnit"] = AmountUnit.BITCOIN, amount_unit: Optional["AmountUnit"] = AmountUnit.BITCOIN,
) -> None: ) -> None:
self.address_n: Sequence["int"] = address_n if address_n is not None else [] self.address_n: Sequence["int"] = address_n if address_n is not None else []
self.coordinator = coordinator self.coordinator = coordinator
self.max_total_fee = max_total_fee self.max_rounds = max_rounds
self.fee_per_anonymity = fee_per_anonymity self.max_coordinator_fee_rate = max_coordinator_fee_rate
self.max_fee_per_kvbyte = max_fee_per_kvbyte
self.coin_name = coin_name self.coin_name = coin_name
self.script_type = script_type self.script_type = script_type
self.amount_unit = amount_unit self.amount_unit = amount_unit