summaryrefslogtreecommitdiff
path: root/daemon/kmd/lib/kmdapi/responses.go
blob: 4d233e9cbd9bce82526b09f9943493095b09148f (plain)
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
// Copyright (C) 2019-2023 Algorand, Inc.
// This file is part of go-algorand
//
// go-algorand is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// go-algorand is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with go-algorand.  If not, see <https://www.gnu.org/licenses/>.

package kmdapi

import (
	"errors"
)

// APIV1Response is the interface that all API V1 responses must satisfy
type APIV1Response interface {
	GetError() error
}

// APIV1ResponseEnvelope is a common envelope that all API V1 responses must embed
type APIV1ResponseEnvelope struct {
	_struct struct{} `codec:",omitempty,omitemptyarray"`
	Error   bool     `json:"error"`
	Message string   `json:"message"`
}

// GetError allows VersionResponse to satisfy the APIV1Response interface, even
// though it can never return an error and is not versioned
func (r VersionsResponse) GetError() error {
	return nil
}

// GetError allows responses that embed an APIV1ResponseEnvelope to satisfy the
// APIV1Response interface
func (r APIV1ResponseEnvelope) GetError() error {
	if r.Error {
		return errors.New(r.Message)
	}
	return nil
}

// VersionsResponse is the response to `GET /versions`
// friendly:VersionsResponse
type VersionsResponse struct {
	_struct  struct{} `codec:",omitempty,omitemptyarray"`
	Versions []string `json:"versions"`
}

// Response to `GET /versions`
// swagger:response VersionsResponse
type versionsResponse struct {
	//Versions Response
	//in:body
	Body *VersionsResponse
}

// APIV1GETWalletsResponse is the response to `GET /v1/wallets`
// friendly:ListWalletsResponse
type APIV1GETWalletsResponse struct {
	APIV1ResponseEnvelope
	Wallets []APIV1Wallet `json:"wallets"`
}

// Response to `GET /v1/wallets`
// swagger:response ListWalletsResponse
type listWalletsResponse struct {
	//in: body
	Body *APIV1GETWalletsResponse
}

// APIV1POSTWalletResponse is the response to `POST /v1/wallet`
// friendly:CreateWalletResponse
type APIV1POSTWalletResponse struct {
	APIV1ResponseEnvelope
	Wallet APIV1Wallet `json:"wallet"`
}

// Response to `POST /v1/wallet`
// swagger:response CreateWalletResponse
type createWalletResponse struct {
	//	in:body
	Body *APIV1POSTWalletResponse
}

// APIV1POSTWalletInitResponse is the response to `POST /v1/wallet/init`
// friendly:InitWalletHandleTokenResponse
type APIV1POSTWalletInitResponse struct {
	APIV1ResponseEnvelope
	WalletHandleToken string `json:"wallet_handle_token"`
}

// Response to `POST /v1/wallet/init`
// swagger:response InitWalletHandleTokenResponse
type initWalletHandleTokenResponse struct {
	//	in:body
	Body *APIV1POSTWalletInitResponse
}

// APIV1POSTWalletReleaseResponse is the response to `POST /v1/wallet/release`
// friendly:ReleaseWalletHandleTokenResponse
type APIV1POSTWalletReleaseResponse struct {
	APIV1ResponseEnvelope
}

// Response to `POST /v1/wallet/release`
// swagger:response ReleaseWalletHandleTokenResponse
type releaseWalletHandleTokenResponse struct {
	//	in:body
	Body *APIV1POSTWalletReleaseResponse
}

// APIV1POSTWalletRenewResponse is the response to `POST /v1/wallet/renew`
// friendly:RenewWalletHandleTokenResponse
type APIV1POSTWalletRenewResponse struct {
	APIV1ResponseEnvelope
	WalletHandle APIV1WalletHandle `json:"wallet_handle"`
}

// Response `POST /v1/wallet/renew`
// swagger:response RenewWalletHandleTokenResponse
type renewWalletHandleTokenResponse struct {
	//	in:body
	Body *APIV1POSTWalletRenewResponse
}

// APIV1POSTWalletRenameResponse is the response to `POST /v1/wallet/rename`
// friendly:RenameWalletResponse
type APIV1POSTWalletRenameResponse struct {
	APIV1ResponseEnvelope
	Wallet APIV1Wallet `json:"wallet"`
}

// Response to `POST /v1/wallet/rename`
// swagger:response RenameWalletResponse
type renameWalletResponse struct {
	//	in:body
	Body *APIV1POSTWalletRenameResponse
}

// APIV1POSTWalletInfoResponse is the response to `POST /v1/wallet/info`
// friendly:WalletInfoResponse
type APIV1POSTWalletInfoResponse struct {
	APIV1ResponseEnvelope
	WalletHandle APIV1WalletHandle `json:"wallet_handle"`
}

// Response to `POST /v1/wallet/info`
// swagger:response WalletInfoResponse
type walletInfoResponse struct {
	//	in:body
	Body *APIV1POSTWalletInfoResponse
}

// APIV1POSTMasterKeyExportResponse is the response to `POST /v1/master-key/export`
// friendly:ExportMasterKeyResponse
type APIV1POSTMasterKeyExportResponse struct {
	APIV1ResponseEnvelope
	MasterDerivationKey APIV1MasterDerivationKey `json:"master_derivation_key"`
}

// Response to `POST /v1/master-key/export`
// swagger:response ExportMasterKeyResponse
type exportMasterKeyResponse struct {
	//	in:body
	Body *APIV1POSTMasterKeyExportResponse
}

// APIV1POSTKeyImportResponse is the response to `POST /v1/key/import`
// friendly:ImportKeyResponse
type APIV1POSTKeyImportResponse struct {
	APIV1ResponseEnvelope
	Address string `json:"address"`
}

// Response to `POST /v1/key/import`
// swagger:response ImportKeyResponse
type importKeyResponse struct {
	//	in:body
	Body *APIV1POSTKeyImportResponse
}

// APIV1POSTKeyExportResponse is the response to `POST /v1/key/export`
// friendly:ExportKeyResponse
type APIV1POSTKeyExportResponse struct {
	APIV1ResponseEnvelope
	PrivateKey APIV1PrivateKey `json:"private_key"`
}

// Response to `POST /v1/key/export`
// swagger:response ExportKeyResponse
type exportKeyResponse struct {
	//	in:body
	Body *APIV1POSTKeyExportResponse
}

// APIV1POSTKeyResponse is the response to `POST /v1/key`
// friendly:GenerateKeyResponse
type APIV1POSTKeyResponse struct {
	APIV1ResponseEnvelope
	Address string `json:"address"`
}

// Response to `POST /v1/key`
// swagger:response GenerateKeyResponse
type generateKeyResponse struct {
	//	in:body
	Body *APIV1POSTKeyResponse
}

// APIV1DELETEKeyResponse is the response to `DELETE /v1/key`
// friendly:DeleteKeyResponse
type APIV1DELETEKeyResponse struct {
	APIV1ResponseEnvelope
}

// Response to `DELETE /v1/key`
// swagger:response DeleteKeyResponse
type deleteKeyResponse struct {
	//	in:body
	Body *APIV1DELETEKeyResponse
}

// APIV1POSTKeyListResponse is the response to `POST /v1/key/list`
// friendly:ListKeysResponse
type APIV1POSTKeyListResponse struct {
	APIV1ResponseEnvelope
	Addresses []string `json:"addresses"`
}

// Response to `POST /v1/key/list`
// swagger:response ListKeysResponse
type listKeysResponse struct {
	//in: body
	Body *APIV1POSTKeyListResponse
}

// APIV1POSTTransactionSignResponse is the response to `POST /v1/transaction/sign`
// friendly:SignTransactionResponse
type APIV1POSTTransactionSignResponse struct {
	APIV1ResponseEnvelope

	// swagger:strfmt byte
	SignedTransaction []byte `json:"signed_transaction"`
}

// Response to `POST /v1/transaction/sign`
// swagger:response SignTransactionResponse
type signTransactionResponse struct {
	//	in:body
	Body *APIV1POSTTransactionSignResponse
}

// APIV1POSTProgramSignResponse is the response to `POST /v1/data/sign`
// friendly:SignProgramResponse
type APIV1POSTProgramSignResponse struct {
	APIV1ResponseEnvelope

	// swagger:strfmt byte
	Signature []byte `json:"sig"`
}

// Response to `POST /v1/data/sign`
// swagger:response SignProgramResponse
type signProgramResponse struct {
	//	in:body
	Body *APIV1POSTProgramSignResponse
}

// APIV1POSTMultisigListResponse is the response to `POST /v1/multisig/list`
// friendly:ListMultisigResponse
type APIV1POSTMultisigListResponse struct {
	APIV1ResponseEnvelope
	Addresses []string `json:"addresses"`
}

// Response to `POST /v1/multisig/list`
// swagger:response ListMultisigResponse
type listMultisigResponse struct {
	//	in:body
	Body *APIV1POSTMultisigListResponse
}

// APIV1POSTMultisigImportResponse is the response to `POST /v1/multisig/import`
// friendly:ImportMultisigResponse
type APIV1POSTMultisigImportResponse struct {
	APIV1ResponseEnvelope
	Address string `json:"address"`
}

// Response to `POST /v1/multisig/import`
// swagger:response ImportMultisigResponse
type importMultisigResponse struct {
	//	in:body
	Body *APIV1POSTMultisigImportResponse
}

// APIV1POSTMultisigExportResponse is the response to `POST /v1/multisig/export`
// friendly:ExportMultisigResponse
type APIV1POSTMultisigExportResponse struct {
	APIV1ResponseEnvelope
	Version   uint8            `json:"multisig_version"`
	Threshold uint8            `json:"threshold"`
	PKs       []APIV1PublicKey `json:"pks"`
}

// Response to `POST /v1/multisig/export`
// swagger:response ExportMultisigResponse
type exportMultisigResponse struct {
	//	in:body
	Body *APIV1POSTMultisigExportResponse
}

// APIV1DELETEMultisigResponse is the response to POST /v1/multisig/delete`
// friendly:DeleteMultisigResponse
type APIV1DELETEMultisigResponse struct {
	APIV1ResponseEnvelope
}

// Response to POST /v1/multisig/delete
// swagger:response DeleteMultisigResponse
type deleteMultisigResponse struct {
	// in:body
	Body *APIV1DELETEMultisigResponse
}

// APIV1POSTMultisigTransactionSignResponse is the response to `POST /v1/multisig/sign`
// friendly:SignMultisigResponse
type APIV1POSTMultisigTransactionSignResponse struct {
	APIV1ResponseEnvelope

	// swagger:strfmt byte
	Multisig []byte `json:"multisig"`
}

// Response to `POST /v1/multisig/sign`
// swagger:response SignMultisigResponse
type signMultisigResponse struct {
	//	in:body
	Body *APIV1POSTMultisigTransactionSignResponse
}

// APIV1POSTMultisigProgramSignResponse is the response to `POST /v1/multisig/signdata`
// friendly:SignProgramMultisigResponse
type APIV1POSTMultisigProgramSignResponse struct {
	APIV1ResponseEnvelope

	// swagger:strfmt byte
	Multisig []byte `json:"multisig"`
}

// Response to `POST /v1/multisig/signdata`
// swagger:response SignProgramMultisigResponse
type signProgramMultisigResponse struct {
	//	in:body
	Body *APIV1POSTMultisigProgramSignResponse
}