Skip to content

Commit d0e3716

Browse files
committed
cardano: Allow vote delegation
Allow cardano based on conway.cddl to sign messages containing Vote Delegation certificate. This is needed for withdrawing rewards. Signed-off-by: RostarMarek <[email protected]> cardano: Add Test and minor improvements Adds unit test for vote delegation and adresses minor issues mentioned in PR. Signed-off-by: RostarMarek <[email protected]> cardano: Adress review issues Addresses review issues found during the review process Signed-off-by: RostarMarek <[email protected]> cardano: Add confirmation screen Adds confirmation screen for drep vote delegation dislpaying type and if present drep credential hash. Signed-off-by: RostarMarek <[email protected]>
1 parent 83cd6c8 commit d0e3716

File tree

9 files changed

+359
-25
lines changed

9 files changed

+359
-25
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ customers cannot upgrade their bootloader, its changes are recorded separately.
99
### [Unreleased]
1010
- Bitcoin: add support for sending to silent payment (BIP-352) addresses
1111
- Bitcoin: add support for regtest
12+
- Cardano: add support for vote delegation
1213

1314
### 9.20.0
1415
- Bitcoin: UX improvements for payment request confirmations

messages/cardano.proto

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,30 @@ message CardanoSignTransactionRequest {
8585
repeated AssetGroup asset_groups = 4;
8686
}
8787

88-
// See https://github.com/input-output-hk/cardano-ledger-specs/blob/d0aa86ded0b973b09b629e5aa62aa1e71364d088/eras/alonzo/test-suite/cddl-files/alonzo.cddl#L150
88+
// See https://github.com/IntersectMBO/cardano-ledger/blob/cardano-ledger-conway-1.12.0.0/eras/conway/impl/cddl-files/conway.cddl#L273
8989
message Certificate {
9090
message StakeDelegation {
9191
repeated uint32 keypath = 1;
9292
bytes pool_keyhash = 2;
9393
}
94+
message VoteDelegation {
95+
enum CardanoDRepType {
96+
KEY_HASH = 0;
97+
SCRIPT_HASH = 1;
98+
ALWAYS_ABSTAIN = 2;
99+
ALWAYS_NO_CONFIDENCE = 3;
100+
}
101+
102+
// keypath in this instance refers to stake credential
103+
repeated uint32 keypath = 1;
104+
CardanoDRepType type = 2;
105+
optional bytes drep_credhash = 3;
106+
}
94107
oneof cert {
95108
Keypath stake_registration = 1;
96109
Keypath stake_deregistration = 2;
97110
StakeDelegation stake_delegation = 3;
111+
VoteDelegation vote_delegation = 10;
98112
}
99113
}
100114

py/bitbox02/bitbox02/communication/generated/cardano_pb2.py

Lines changed: 21 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

py/bitbox02/bitbox02/communication/generated/cardano_pb2.pyi

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ class CardanoSignTransactionRequest(google.protobuf.message.Message):
182182
def ClearField(self, field_name: typing_extensions.Literal["asset_groups",b"asset_groups","encoded_address",b"encoded_address","script_config",b"script_config","value",b"value"]) -> None: ...
183183

184184
class Certificate(google.protobuf.message.Message):
185-
"""See https://github.com/input-output-hk/cardano-ledger-specs/blob/d0aa86ded0b973b09b629e5aa62aa1e71364d088/eras/alonzo/test-suite/cddl-files/alonzo.cddl#L150"""
185+
"""See https://github.com/IntersectMBO/cardano-ledger/blob/cardano-ledger-conway-1.12.0.0/eras/conway/impl/cddl-files/conway.cddl#L273"""
186186
DESCRIPTOR: google.protobuf.descriptor.Descriptor
187187
class StakeDelegation(google.protobuf.message.Message):
188188
DESCRIPTOR: google.protobuf.descriptor.Descriptor
@@ -198,24 +198,66 @@ class CardanoSignTransactionRequest(google.protobuf.message.Message):
198198
) -> None: ...
199199
def ClearField(self, field_name: typing_extensions.Literal["keypath",b"keypath","pool_keyhash",b"pool_keyhash"]) -> None: ...
200200

201+
class VoteDelegation(google.protobuf.message.Message):
202+
DESCRIPTOR: google.protobuf.descriptor.Descriptor
203+
class _CardanoDRepType:
204+
ValueType = typing.NewType('ValueType', builtins.int)
205+
V: typing_extensions.TypeAlias = ValueType
206+
class _CardanoDRepTypeEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[CardanoSignTransactionRequest.Certificate.VoteDelegation._CardanoDRepType.ValueType], builtins.type):
207+
DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor
208+
KEY_HASH: CardanoSignTransactionRequest.Certificate.VoteDelegation._CardanoDRepType.ValueType # 0
209+
SCRIPT_HASH: CardanoSignTransactionRequest.Certificate.VoteDelegation._CardanoDRepType.ValueType # 1
210+
ALWAYS_ABSTAIN: CardanoSignTransactionRequest.Certificate.VoteDelegation._CardanoDRepType.ValueType # 2
211+
ALWAYS_NO_CONFIDENCE: CardanoSignTransactionRequest.Certificate.VoteDelegation._CardanoDRepType.ValueType # 3
212+
class CardanoDRepType(_CardanoDRepType, metaclass=_CardanoDRepTypeEnumTypeWrapper):
213+
pass
214+
215+
KEY_HASH: CardanoSignTransactionRequest.Certificate.VoteDelegation.CardanoDRepType.ValueType # 0
216+
SCRIPT_HASH: CardanoSignTransactionRequest.Certificate.VoteDelegation.CardanoDRepType.ValueType # 1
217+
ALWAYS_ABSTAIN: CardanoSignTransactionRequest.Certificate.VoteDelegation.CardanoDRepType.ValueType # 2
218+
ALWAYS_NO_CONFIDENCE: CardanoSignTransactionRequest.Certificate.VoteDelegation.CardanoDRepType.ValueType # 3
219+
220+
KEYPATH_FIELD_NUMBER: builtins.int
221+
TYPE_FIELD_NUMBER: builtins.int
222+
DREP_CREDHASH_FIELD_NUMBER: builtins.int
223+
@property
224+
def keypath(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.int]:
225+
"""keypath in this instance refers to stake credential"""
226+
pass
227+
type: global___CardanoSignTransactionRequest.Certificate.VoteDelegation.CardanoDRepType.ValueType
228+
drep_credhash: builtins.bytes
229+
def __init__(self,
230+
*,
231+
keypath: typing.Optional[typing.Iterable[builtins.int]] = ...,
232+
type: global___CardanoSignTransactionRequest.Certificate.VoteDelegation.CardanoDRepType.ValueType = ...,
233+
drep_credhash: typing.Optional[builtins.bytes] = ...,
234+
) -> None: ...
235+
def HasField(self, field_name: typing_extensions.Literal["_drep_credhash",b"_drep_credhash","drep_credhash",b"drep_credhash"]) -> builtins.bool: ...
236+
def ClearField(self, field_name: typing_extensions.Literal["_drep_credhash",b"_drep_credhash","drep_credhash",b"drep_credhash","keypath",b"keypath","type",b"type"]) -> None: ...
237+
def WhichOneof(self, oneof_group: typing_extensions.Literal["_drep_credhash",b"_drep_credhash"]) -> typing.Optional[typing_extensions.Literal["drep_credhash"]]: ...
238+
201239
STAKE_REGISTRATION_FIELD_NUMBER: builtins.int
202240
STAKE_DEREGISTRATION_FIELD_NUMBER: builtins.int
203241
STAKE_DELEGATION_FIELD_NUMBER: builtins.int
242+
VOTE_DELEGATION_FIELD_NUMBER: builtins.int
204243
@property
205244
def stake_registration(self) -> common_pb2.Keypath: ...
206245
@property
207246
def stake_deregistration(self) -> common_pb2.Keypath: ...
208247
@property
209248
def stake_delegation(self) -> global___CardanoSignTransactionRequest.Certificate.StakeDelegation: ...
249+
@property
250+
def vote_delegation(self) -> global___CardanoSignTransactionRequest.Certificate.VoteDelegation: ...
210251
def __init__(self,
211252
*,
212253
stake_registration: typing.Optional[common_pb2.Keypath] = ...,
213254
stake_deregistration: typing.Optional[common_pb2.Keypath] = ...,
214255
stake_delegation: typing.Optional[global___CardanoSignTransactionRequest.Certificate.StakeDelegation] = ...,
256+
vote_delegation: typing.Optional[global___CardanoSignTransactionRequest.Certificate.VoteDelegation] = ...,
215257
) -> None: ...
216-
def HasField(self, field_name: typing_extensions.Literal["cert",b"cert","stake_delegation",b"stake_delegation","stake_deregistration",b"stake_deregistration","stake_registration",b"stake_registration"]) -> builtins.bool: ...
217-
def ClearField(self, field_name: typing_extensions.Literal["cert",b"cert","stake_delegation",b"stake_delegation","stake_deregistration",b"stake_deregistration","stake_registration",b"stake_registration"]) -> None: ...
218-
def WhichOneof(self, oneof_group: typing_extensions.Literal["cert",b"cert"]) -> typing.Optional[typing_extensions.Literal["stake_registration","stake_deregistration","stake_delegation"]]: ...
258+
def HasField(self, field_name: typing_extensions.Literal["cert",b"cert","stake_delegation",b"stake_delegation","stake_deregistration",b"stake_deregistration","stake_registration",b"stake_registration","vote_delegation",b"vote_delegation"]) -> builtins.bool: ...
259+
def ClearField(self, field_name: typing_extensions.Literal["cert",b"cert","stake_delegation",b"stake_delegation","stake_deregistration",b"stake_deregistration","stake_registration",b"stake_registration","vote_delegation",b"vote_delegation"]) -> None: ...
260+
def WhichOneof(self, oneof_group: typing_extensions.Literal["cert",b"cert"]) -> typing.Optional[typing_extensions.Literal["stake_registration","stake_deregistration","stake_delegation","vote_delegation"]]: ...
219261

220262
class Withdrawal(google.protobuf.message.Message):
221263
DESCRIPTOR: google.protobuf.descriptor.Descriptor

0 commit comments

Comments
 (0)