mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-18 05:28:40 +00:00
chore(cardano): rename cvote reward_address to payment_address
This commit is contained in:
parent
2011ffe9c9
commit
0754a008e9
@ -371,12 +371,12 @@ message CardanoCVoteRegistrationDelegation {
|
||||
message CardanoCVoteRegistrationParametersType {
|
||||
optional bytes voting_public_key = 1; // mutually exclusive with delegations
|
||||
repeated uint32 staking_path = 2;
|
||||
optional CardanoAddressParametersType reward_address_parameters = 3; // mutually exclusive with reward_address
|
||||
optional CardanoAddressParametersType payment_address_parameters = 3; // mutually exclusive with payment_address
|
||||
required uint64 nonce = 4;
|
||||
optional CardanoCVoteRegistrationFormat format = 5 [default=CIP15];
|
||||
repeated CardanoCVoteRegistrationDelegation delegations = 6; // mutually exclusive with voting_public_key; max 32 delegations
|
||||
optional uint64 voting_purpose = 7;
|
||||
optional string reward_address = 8; // mutually exclusive with reward_address_parameters
|
||||
optional string payment_address = 8; // mutually exclusive with payment_address_parameters
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1299,7 +1299,7 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "transaction with cvote registration containing byron reward address",
|
||||
"description": "transaction with cvote registration containing byron payment address",
|
||||
"parameters": {
|
||||
"protocol_magic": 764824073,
|
||||
"network_id": 1,
|
||||
@ -1313,7 +1313,7 @@
|
||||
"voting_public_key": "3b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b7",
|
||||
"staking_path": "m/1852'/1815'/0'/2/0",
|
||||
"nonce": 22634813,
|
||||
"reward_address_parameters": {
|
||||
"payment_address_parameters": {
|
||||
"addressType": 8,
|
||||
"path": "m/44'/1815'/0'/0/0"
|
||||
}
|
||||
@ -1362,7 +1362,7 @@
|
||||
"cvote_registration_parameters": {
|
||||
"voting_public_key": "38DA0B509D45BF6C87BD55594B92F97081D3923B8C1334B9B8D0BF13FC1C12D0",
|
||||
"staking_path": "m/1852'/1815'/0'/2/0",
|
||||
"reward_address_parameters": {
|
||||
"payment_address_parameters": {
|
||||
"addressType": 0,
|
||||
"path": "m/1852'/1815'/0'/0/0",
|
||||
"stakingPath": "m/1852'/1815'/0'/2/0"
|
||||
@ -1412,7 +1412,7 @@
|
||||
"cvote_registration_parameters": {
|
||||
"voting_public_key": "38DA0B509D45BF6C87BD55594B92F97081D3923B8C1334B9B8D0BF13FC1C12D0",
|
||||
"staking_path": "m/1852'/1815'/0'/2/0",
|
||||
"reward_address_parameters": {
|
||||
"payment_address_parameters": {
|
||||
"addressType": 0,
|
||||
"path": "m/1852'/1815'/0'/0/0",
|
||||
"stakingPath": "m/1852'/1815'/0'/2/0"
|
||||
|
20
common/tests/fixtures/cardano/sign_tx.json
vendored
20
common/tests/fixtures/cardano/sign_tx.json
vendored
@ -1015,7 +1015,7 @@
|
||||
"cvote_registration_parameters": {
|
||||
"voting_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc",
|
||||
"staking_path": "m/1852'/1815'/0'/2/0",
|
||||
"reward_address_parameters": {
|
||||
"payment_address_parameters": {
|
||||
"addressType": 0,
|
||||
"path": "m/1852'/1815'/0'/0/0",
|
||||
"stakingPath": "m/1852'/1815'/0'/2/0"
|
||||
@ -1077,7 +1077,7 @@
|
||||
"auxiliary_data": {
|
||||
"cvote_registration_parameters": {
|
||||
"staking_path": "m/1852'/1815'/0'/2/0",
|
||||
"reward_address_parameters": {
|
||||
"payment_address_parameters": {
|
||||
"addressType": 0,
|
||||
"path": "m/1852'/1815'/0'/0/0",
|
||||
"stakingPath": "m/1852'/1815'/0'/2/0"
|
||||
@ -1150,7 +1150,7 @@
|
||||
"auxiliary_data": {
|
||||
"cvote_registration_parameters": {
|
||||
"staking_path": "m/1852'/1815'/0'/2/0",
|
||||
"reward_address_parameters": {
|
||||
"payment_address_parameters": {
|
||||
"addressType": 0,
|
||||
"path": "m/1852'/1815'/0'/0/0",
|
||||
"stakingPath": "m/1852'/1815'/0'/2/0"
|
||||
@ -1208,7 +1208,7 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "transaction with CIP36 registration and external reward address",
|
||||
"description": "transaction with CIP36 registration and external payment address",
|
||||
"parameters": {
|
||||
"protocol_magic": 764824073,
|
||||
"network_id": 1,
|
||||
@ -1228,7 +1228,7 @@
|
||||
"weight": 1
|
||||
}
|
||||
],
|
||||
"reward_address": "addr1q84sh2j72ux0l03fxndjnhctdg7hcppsaejafsa84vh7lwgmcs5wgus8qt4atk45lvt4xfxpjtwfhdmvchdf2m3u3hlsd5tq5r"
|
||||
"payment_address": "addr1q84sh2j72ux0l03fxndjnhctdg7hcppsaejafsa84vh7lwgmcs5wgus8qt4atk45lvt4xfxpjtwfhdmvchdf2m3u3hlsd5tq5r"
|
||||
}
|
||||
},
|
||||
"inputs": [
|
||||
@ -1273,7 +1273,7 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "transaction with CIP36 registration and non-payment reward address parameters",
|
||||
"description": "transaction with CIP36 registration and non-payment payment address parameters",
|
||||
"parameters": {
|
||||
"protocol_magic": 764824073,
|
||||
"network_id": 1,
|
||||
@ -1285,7 +1285,7 @@
|
||||
"auxiliary_data": {
|
||||
"cvote_registration_parameters": {
|
||||
"staking_path": "m/1852'/1815'/0'/2/0",
|
||||
"reward_address_parameters": {
|
||||
"payment_address_parameters": {
|
||||
"addressType": 14,
|
||||
"stakingPath": "m/1852'/1815'/0'/2/0"
|
||||
},
|
||||
@ -1341,7 +1341,7 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "transaction with CIP36 registration and non-payment external reward address",
|
||||
"description": "transaction with CIP36 registration and external payment address with REWARD type",
|
||||
"parameters": {
|
||||
"protocol_magic": 764824073,
|
||||
"network_id": 1,
|
||||
@ -1361,7 +1361,7 @@
|
||||
"weight": 1
|
||||
}
|
||||
],
|
||||
"reward_address": "stake1uyfz49rtntfa9h0s98f6s28sg69weemgjhc4e8hm66d5yacalmqha"
|
||||
"payment_address": "stake1uyfz49rtntfa9h0s98f6s28sg69weemgjhc4e8hm66d5yacalmqha"
|
||||
}
|
||||
},
|
||||
"inputs": [
|
||||
@ -1934,7 +1934,7 @@
|
||||
"auxiliary_data": {
|
||||
"cvote_registration_parameters": {
|
||||
"staking_path": "m/1852'/1815'/0'/2/0",
|
||||
"reward_address_parameters": {
|
||||
"payment_address_parameters": {
|
||||
"addressType": 0,
|
||||
"path": "m/1852'/1815'/0'/0/0",
|
||||
"stakingPath": "m/1852'/1815'/0'/2/0"
|
||||
|
@ -469,7 +469,7 @@
|
||||
"auxiliary_data": {
|
||||
"cvote_registration_parameters": {
|
||||
"staking_path": "m/1852'/1815'/0'/2/0",
|
||||
"reward_address_parameters": {
|
||||
"payment_address_parameters": {
|
||||
"addressType": 0,
|
||||
"path": "m/1852'/1815'/0'/0/0",
|
||||
"stakingPath": "m/1852'/1815'/0'/2/0"
|
||||
|
@ -233,13 +233,10 @@ def validate_output_address_parameters(
|
||||
assert_params_cond(parameters.address_type in ADDRESS_TYPES_PAYMENT_KEY)
|
||||
|
||||
|
||||
def validate_cvote_reward_address_parameters(
|
||||
def validate_cvote_payment_address_parameters(
|
||||
parameters: messages.CardanoAddressParametersType,
|
||||
) -> None:
|
||||
validate_address_parameters(parameters)
|
||||
|
||||
# Despite the name, the address doesn't have to be a REWARD address.
|
||||
# see also validate_cvote_reward_address
|
||||
assert_params_cond(parameters.address_type in ADDRESS_TYPES_SHELLEY)
|
||||
|
||||
|
||||
@ -299,7 +296,7 @@ def validate_reward_address(address: str, protocol_magic: int, network_id: int)
|
||||
)
|
||||
|
||||
|
||||
def validate_cvote_reward_address(
|
||||
def validate_cvote_payment_address(
|
||||
address: str, protocol_magic: int, network_id: int
|
||||
) -> None:
|
||||
address_type = _validate_and_get_type(address, protocol_magic, network_id)
|
||||
|
@ -75,18 +75,18 @@ def _validate_cvote_registration_parameters(
|
||||
|
||||
assert_cond(SCHEMA_STAKING_ANY_ACCOUNT.match(parameters.staking_path))
|
||||
|
||||
reward_address_fields_provided = 0
|
||||
if parameters.reward_address is not None:
|
||||
reward_address_fields_provided += 1
|
||||
addresses.validate_cvote_reward_address(
|
||||
parameters.reward_address, protocol_magic, network_id
|
||||
payment_address_fields_provided = 0
|
||||
if parameters.payment_address is not None:
|
||||
payment_address_fields_provided += 1
|
||||
addresses.validate_cvote_payment_address(
|
||||
parameters.payment_address, protocol_magic, network_id
|
||||
)
|
||||
if parameters.reward_address_parameters:
|
||||
reward_address_fields_provided += 1
|
||||
addresses.validate_cvote_reward_address_parameters(
|
||||
parameters.reward_address_parameters
|
||||
if parameters.payment_address_parameters:
|
||||
payment_address_fields_provided += 1
|
||||
addresses.validate_cvote_payment_address_parameters(
|
||||
parameters.payment_address_parameters
|
||||
)
|
||||
assert_cond(reward_address_fields_provided == 1)
|
||||
assert_cond(payment_address_fields_provided == 1)
|
||||
|
||||
if parameters.voting_purpose is not None:
|
||||
assert_cond(parameters.format == CardanoCVoteRegistrationFormat.CIP36)
|
||||
@ -138,8 +138,8 @@ async def show(
|
||||
|
||||
|
||||
def _should_show_payment_warning(address_type: CardanoAddressType) -> bool:
|
||||
# For non-payment cvote reward addresses, we show a warning that the address is not
|
||||
# actually eligible for rewards. https://github.com/cardano-foundation/CIPs/pull/373
|
||||
# For cvote payment addresses that are actually REWARD addresses, we show a warning that the
|
||||
# address is not eligible for rewards. https://github.com/cardano-foundation/CIPs/pull/373
|
||||
# However, the registration is otherwise valid, so we allow such addresses since we don't
|
||||
# want to prevent the user from voting just because they use an outdated SW wallet.
|
||||
return address_type not in addresses.ADDRESS_TYPES_PAYMENT
|
||||
@ -164,21 +164,21 @@ async def _show_cvote_registration(
|
||||
ctx, encoded_public_key, delegation.weight
|
||||
)
|
||||
|
||||
if parameters.reward_address:
|
||||
if parameters.payment_address:
|
||||
show_payment_warning = _should_show_payment_warning(
|
||||
addresses.get_type(addresses.get_bytes_unsafe(parameters.reward_address))
|
||||
addresses.get_type(addresses.get_bytes_unsafe(parameters.payment_address))
|
||||
)
|
||||
await layout.confirm_cvote_registration_reward_address(
|
||||
ctx, parameters.reward_address, show_payment_warning
|
||||
await layout.confirm_cvote_registration_payment_address(
|
||||
ctx, parameters.payment_address, show_payment_warning
|
||||
)
|
||||
else:
|
||||
address_parameters = parameters.reward_address_parameters
|
||||
address_parameters = parameters.payment_address_parameters
|
||||
assert address_parameters # _validate_cvote_registration_parameters
|
||||
show_both_credentials = should_show_credentials(address_parameters)
|
||||
show_payment_warning = _should_show_payment_warning(
|
||||
address_parameters.address_type
|
||||
)
|
||||
await layout.show_cvote_registration_reward_credentials(
|
||||
await layout.show_cvote_registration_payment_credentials(
|
||||
ctx,
|
||||
Credential.payment_credential(address_parameters),
|
||||
Credential.stake_credential(address_parameters),
|
||||
@ -281,12 +281,12 @@ def _get_signed_cvote_registration_payload(
|
||||
|
||||
staking_key = derive_public_key(keychain, parameters.staking_path)
|
||||
|
||||
if parameters.reward_address:
|
||||
reward_address = addresses.get_bytes_unsafe(parameters.reward_address)
|
||||
if parameters.payment_address:
|
||||
payment_address = addresses.get_bytes_unsafe(parameters.payment_address)
|
||||
else:
|
||||
address_parameters = parameters.reward_address_parameters
|
||||
address_parameters = parameters.payment_address_parameters
|
||||
assert address_parameters # _validate_cvote_registration_parameters
|
||||
reward_address = addresses.derive_bytes(
|
||||
payment_address = addresses.derive_bytes(
|
||||
keychain,
|
||||
address_parameters,
|
||||
protocol_magic,
|
||||
@ -298,7 +298,7 @@ def _get_signed_cvote_registration_payload(
|
||||
payload: CVoteRegistrationPayload = {
|
||||
1: delegations_or_key,
|
||||
2: staking_key,
|
||||
3: reward_address,
|
||||
3: payment_address,
|
||||
4: parameters.nonce,
|
||||
}
|
||||
if voting_purpose is not None:
|
||||
|
@ -357,16 +357,18 @@ async def show_device_owned_output_credentials(
|
||||
await _show_credential(ctx, stake_credential, intro_text, purpose="output")
|
||||
|
||||
|
||||
async def show_cvote_registration_reward_credentials(
|
||||
async def show_cvote_registration_payment_credentials(
|
||||
ctx: Context,
|
||||
payment_credential: Credential,
|
||||
stake_credential: Credential,
|
||||
show_both_credentials: bool,
|
||||
show_payment_warning: bool,
|
||||
) -> None:
|
||||
intro_text = "The vote key registration reward address is owned by this device. Its"
|
||||
intro_text = (
|
||||
"The vote key registration payment address is owned by this device. Its"
|
||||
)
|
||||
await _show_credential(
|
||||
ctx, payment_credential, intro_text, purpose="cvote_reg_reward_address"
|
||||
ctx, payment_credential, intro_text, purpose="cvote_reg_payment_address"
|
||||
)
|
||||
if show_both_credentials or show_payment_warning:
|
||||
extra_text = CVOTE_REWARD_ELIGIBILITY_WARNING if show_payment_warning else None
|
||||
@ -374,7 +376,7 @@ async def show_cvote_registration_reward_credentials(
|
||||
ctx,
|
||||
stake_credential,
|
||||
intro_text,
|
||||
purpose="cvote_reg_reward_address",
|
||||
purpose="cvote_reg_payment_address",
|
||||
extra_text=extra_text,
|
||||
)
|
||||
|
||||
@ -383,13 +385,13 @@ async def _show_credential(
|
||||
ctx: Context,
|
||||
credential: Credential,
|
||||
intro_text: str,
|
||||
purpose: Literal["address", "output", "cvote_reg_reward_address"],
|
||||
purpose: Literal["address", "output", "cvote_reg_payment_address"],
|
||||
extra_text: str | None = None,
|
||||
) -> None:
|
||||
title = {
|
||||
"address": f"{ADDRESS_TYPE_NAMES[credential.address_type]} address",
|
||||
"output": "Confirm transaction",
|
||||
"cvote_reg_reward_address": "Confirm transaction",
|
||||
"cvote_reg_payment_address": "Confirm transaction",
|
||||
}[purpose]
|
||||
|
||||
props: list[PropertyType] = []
|
||||
@ -412,7 +414,7 @@ async def _show_credential(
|
||||
append((None, "Path is unusual."))
|
||||
if credential.is_mismatch:
|
||||
append((None, "Credential doesn't match payment credential."))
|
||||
if credential.is_reward and purpose != "cvote_reg_reward_address":
|
||||
if credential.is_reward and purpose != "cvote_reg_payment_address":
|
||||
# for cvote registrations, this is handled by extra_text at the end
|
||||
append(("Address is a reward address.", None))
|
||||
if credential.is_no_staking:
|
||||
@ -794,20 +796,20 @@ async def confirm_cvote_registration_delegation(
|
||||
)
|
||||
|
||||
|
||||
async def confirm_cvote_registration_reward_address(
|
||||
async def confirm_cvote_registration_payment_address(
|
||||
ctx: Context,
|
||||
reward_address: str,
|
||||
payment_address: str,
|
||||
should_show_payment_warning: bool,
|
||||
) -> None:
|
||||
props = [
|
||||
("Vote key registration (CIP-36)", None),
|
||||
("Rewards go to:", reward_address),
|
||||
("Rewards go to:", payment_address),
|
||||
]
|
||||
if should_show_payment_warning:
|
||||
props.append((CVOTE_REWARD_ELIGIBILITY_WARNING, None))
|
||||
await confirm_properties(
|
||||
ctx,
|
||||
"confirm_cvote_registration_reward_address",
|
||||
"confirm_cvote_registration_payment_address",
|
||||
title="Confirm transaction",
|
||||
props=props,
|
||||
br_code=ButtonRequestType.Other,
|
||||
|
@ -1657,12 +1657,12 @@ if TYPE_CHECKING:
|
||||
class CardanoCVoteRegistrationParametersType(protobuf.MessageType):
|
||||
voting_public_key: "bytes | None"
|
||||
staking_path: "list[int]"
|
||||
reward_address_parameters: "CardanoAddressParametersType | None"
|
||||
payment_address_parameters: "CardanoAddressParametersType | None"
|
||||
nonce: "int"
|
||||
format: "CardanoCVoteRegistrationFormat"
|
||||
delegations: "list[CardanoCVoteRegistrationDelegation]"
|
||||
voting_purpose: "int | None"
|
||||
reward_address: "str | None"
|
||||
payment_address: "str | None"
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@ -1671,10 +1671,10 @@ if TYPE_CHECKING:
|
||||
staking_path: "list[int] | None" = None,
|
||||
delegations: "list[CardanoCVoteRegistrationDelegation] | None" = None,
|
||||
voting_public_key: "bytes | None" = None,
|
||||
reward_address_parameters: "CardanoAddressParametersType | None" = None,
|
||||
payment_address_parameters: "CardanoAddressParametersType | None" = None,
|
||||
format: "CardanoCVoteRegistrationFormat | None" = None,
|
||||
voting_purpose: "int | None" = None,
|
||||
reward_address: "str | None" = None,
|
||||
payment_address: "str | None" = None,
|
||||
) -> None:
|
||||
pass
|
||||
|
||||
|
@ -591,12 +591,12 @@ def parse_auxiliary_data(
|
||||
),
|
||||
staking_path=tools.parse_path(cvote_registration["staking_path"]),
|
||||
nonce=cvote_registration["nonce"],
|
||||
reward_address=cvote_registration.get("reward_address"),
|
||||
reward_address_parameters=_parse_address_parameters(
|
||||
cvote_registration["reward_address_parameters"],
|
||||
payment_address=cvote_registration.get("payment_address"),
|
||||
payment_address_parameters=_parse_address_parameters(
|
||||
cvote_registration["payment_address_parameters"],
|
||||
str(AUXILIARY_DATA_MISSING_FIELDS_ERROR),
|
||||
)
|
||||
if "reward_address_parameters" in cvote_registration
|
||||
if "payment_address_parameters" in cvote_registration
|
||||
else None,
|
||||
format=serialization_format,
|
||||
delegations=delegations,
|
||||
|
@ -2658,12 +2658,12 @@ class CardanoCVoteRegistrationParametersType(protobuf.MessageType):
|
||||
FIELDS = {
|
||||
1: protobuf.Field("voting_public_key", "bytes", repeated=False, required=False, default=None),
|
||||
2: protobuf.Field("staking_path", "uint32", repeated=True, required=False, default=None),
|
||||
3: protobuf.Field("reward_address_parameters", "CardanoAddressParametersType", repeated=False, required=False, default=None),
|
||||
3: protobuf.Field("payment_address_parameters", "CardanoAddressParametersType", repeated=False, required=False, default=None),
|
||||
4: protobuf.Field("nonce", "uint64", repeated=False, required=True),
|
||||
5: protobuf.Field("format", "CardanoCVoteRegistrationFormat", repeated=False, required=False, default=CardanoCVoteRegistrationFormat.CIP15),
|
||||
6: protobuf.Field("delegations", "CardanoCVoteRegistrationDelegation", repeated=True, required=False, default=None),
|
||||
7: protobuf.Field("voting_purpose", "uint64", repeated=False, required=False, default=None),
|
||||
8: protobuf.Field("reward_address", "string", repeated=False, required=False, default=None),
|
||||
8: protobuf.Field("payment_address", "string", repeated=False, required=False, default=None),
|
||||
}
|
||||
|
||||
def __init__(
|
||||
@ -2673,19 +2673,19 @@ class CardanoCVoteRegistrationParametersType(protobuf.MessageType):
|
||||
staking_path: Optional[Sequence["int"]] = None,
|
||||
delegations: Optional[Sequence["CardanoCVoteRegistrationDelegation"]] = None,
|
||||
voting_public_key: Optional["bytes"] = None,
|
||||
reward_address_parameters: Optional["CardanoAddressParametersType"] = None,
|
||||
payment_address_parameters: Optional["CardanoAddressParametersType"] = None,
|
||||
format: Optional["CardanoCVoteRegistrationFormat"] = CardanoCVoteRegistrationFormat.CIP15,
|
||||
voting_purpose: Optional["int"] = None,
|
||||
reward_address: Optional["str"] = None,
|
||||
payment_address: Optional["str"] = None,
|
||||
) -> None:
|
||||
self.staking_path: Sequence["int"] = staking_path if staking_path is not None else []
|
||||
self.delegations: Sequence["CardanoCVoteRegistrationDelegation"] = delegations if delegations is not None else []
|
||||
self.nonce = nonce
|
||||
self.voting_public_key = voting_public_key
|
||||
self.reward_address_parameters = reward_address_parameters
|
||||
self.payment_address_parameters = payment_address_parameters
|
||||
self.format = format
|
||||
self.voting_purpose = voting_purpose
|
||||
self.reward_address = reward_address
|
||||
self.payment_address = payment_address
|
||||
|
||||
|
||||
class CardanoTxAuxiliaryData(protobuf.MessageType):
|
||||
|
Loading…
Reference in New Issue
Block a user