forked from trezor/trezor-firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmessages-cardano.proto
165 lines (153 loc) · 6.46 KB
/
messages-cardano.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
syntax = "proto2";
package hw.trezor.messages.cardano;
// Sugar for easier handling in Java
option java_package = "com.satoshilabs.trezor.lib.protobuf";
option java_outer_classname = "TrezorMessageCardano";
import "messages-common.proto";
/**
* Values correspond to address header values given by the spec.
* Script addresses are only supported in transaction outputs.
*/
enum CardanoAddressType {
BASE = 0;
BASE_SCRIPT_KEY = 1;
BASE_KEY_SCRIPT = 2;
BASE_SCRIPT_SCRIPT = 3;
POINTER = 4;
POINTER_SCRIPT = 5;
ENTERPRISE = 6;
ENTERPRISE_SCRIPT = 7;
BYRON = 8;
REWARD = 14;
REWARD_SCRIPT = 15;
}
enum CardanoCertificateType {
STAKE_REGISTRATION = 0;
STAKE_DEREGISTRATION = 1;
STAKE_DELEGATION = 2;
}
/**
* Structure representing cardano PointerAddress pointer,
* which points to a staking key registration certificate.
* @embed
*/
message CardanoBlockchainPointerType {
optional uint32 block_index = 1;
optional uint32 tx_index = 2;
optional uint32 certificate_index = 3;
}
/**
* Structure to represent address parameters so they can be
* reused in CardanoGetAddress and CardanoTxOutputType.
* NetworkId isn't a part of the parameters, because in a transaction
* this will be included separately in the transaction itself, so it
* shouldn't be duplicated here.
* @embed
*/
message CardanoAddressParametersType {
optional CardanoAddressType address_type = 1; // one of the CardanoAddressType-s
repeated uint32 address_n = 2; // BIP-32-style path to derive the spending key from master node
repeated uint32 address_n_staking = 3; // BIP-32-style path to derive staking key from master node
optional bytes staking_key_hash = 4; // staking key can be derived from address_n_staking, or
// can be sent directly e.g. if it doesn't belong to
// the same account as address_n
optional CardanoBlockchainPointerType certificate_pointer = 5; // a pointer to the staking key registration certificate
}
/**
* Request: Ask device for Cardano address
* @start
* @next CardanoAddress
* @next Failure
*/
message CardanoGetAddress {
// repeated uint32 address_n = 1; // moved to address_parameters
optional bool show_display = 2; // optionally prompt for confirmation on trezor display
optional uint32 protocol_magic = 3; // network's protocol magic - needed for Byron addresses on testnets
optional uint32 network_id = 4; // network id - mainnet or testnet
optional CardanoAddressParametersType address_parameters = 5; // parameters used to derive the address
}
/**
* Request: Ask device for Cardano address
* @end
*/
message CardanoAddress {
optional string address = 1; // Base58 cardano address
}
/**
* Request: Ask device for public key corresponding to address_n path
* @start
* @next CardanoPublicKey
* @next Failure
*/
message CardanoGetPublicKey {
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
optional bool show_display = 2; // optionally show on display before sending the result
}
/**
* Response: Contains public key derived from device private seed
* @end
*/
message CardanoPublicKey {
optional string xpub = 1; // Xpub key
optional hw.trezor.messages.common.HDNodeType node = 2; // BIP-32 public node
}
/**
* Request: Ask device to sign Cardano transaction
* @start
* @next CardanoSignedTx
* @next Failure
*/
message CardanoSignTx {
repeated CardanoTxInputType inputs = 1; // inputs to be used in transaction
repeated CardanoTxOutputType outputs = 2; // outputs to be used in transaction
// optional uint32 transactions_count = 3; // left as a comment so we know to skip the id 3 in the future
optional uint32 protocol_magic = 5; // network's protocol magic
optional uint64 fee = 6; // transaction fee - added in shelley
optional uint64 ttl = 7; // transaction ttl - added in shelley
optional uint32 network_id = 8; // network id - mainnet or testnet
repeated CardanoTxCertificateType certificates = 9; // transaction certificates - added in shelley
repeated CardanoTxWithdrawalType withdrawals = 10; // transaction withdrawals - added in shelley
optional bytes metadata = 11; // transaction metadata - added in shelley
/**
* Structure representing cardano transaction input
*/
message CardanoTxInputType {
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
optional bytes prev_hash = 2; // hash of previous transaction output to spend by this input
optional uint32 prev_index = 3; // index of previous output to spend
// left as a comment so we know to skip the id 4 in the future
// optional uint32 type = 4;
}
/**
* Structure representing cardano transaction output
*/
message CardanoTxOutputType {
optional string address = 1; // target coin address in bech32 or base58
// repeated uint32 address_n = 2; // moved to address_parameters
optional uint64 amount = 3; // amount to spend
optional CardanoAddressParametersType address_parameters = 4; // parameters used to derive the address
}
/**
* Structure representing cardano transaction certificate
*/
message CardanoTxCertificateType {
optional CardanoCertificateType type = 1; // certificate type
repeated uint32 path = 2; // BIP-32 path to derive (staking) key
optional bytes pool = 3; // pool hash
}
/**
* Structure representing cardano transaction withdrawals
*/
message CardanoTxWithdrawalType {
repeated uint32 path = 1;
optional uint64 amount = 2;
}
}
/**
* Response: Serialised signed cardano transaction
* @end
*/
message CardanoSignedTx {
optional bytes tx_hash = 1; // hash of the transaction body
optional bytes serialized_tx = 2; // serialized, signed transaction
}