/
responses.go
155 lines (128 loc) · 4.28 KB
/
responses.go
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
package kmd
import (
"errors"
"golang.org/x/crypto/ed25519"
"github.com/algorand/go-algorand-sdk/types"
)
// 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`
type VersionsResponse struct {
_struct struct{} `codec:",omitempty,omitemptyarray"`
Versions []string `json:"versions"`
}
// ListWalletsResponse is the response to `GET /v1/wallets`
type ListWalletsResponse struct {
APIV1ResponseEnvelope
Wallets []APIV1Wallet `json:"wallets"`
}
// CreateWalletResponse is the response to `POST /v1/wallet`
type CreateWalletResponse struct {
APIV1ResponseEnvelope
Wallet APIV1Wallet `json:"wallet"`
}
// InitWalletHandleResponse is the response to `POST /v1/wallet/init`
type InitWalletHandleResponse struct {
APIV1ResponseEnvelope
WalletHandleToken string `json:"wallet_handle_token"`
}
// ReleaseWalletHandleResponse is the response to `POST /v1/wallet/release`
type ReleaseWalletHandleResponse struct {
APIV1ResponseEnvelope
}
// RenewWalletHandleResponse is the response to `POST /v1/wallet/renew`
type RenewWalletHandleResponse struct {
APIV1ResponseEnvelope
WalletHandle APIV1WalletHandle `json:"wallet_handle"`
}
// RenameWalletResponse is the response to `POST /v1/wallet/rename`
type RenameWalletResponse struct {
APIV1ResponseEnvelope
Wallet APIV1Wallet `json:"wallet"`
}
// GetWalletResponse is the response to `POST /v1/wallet/info`
type GetWalletResponse struct {
APIV1ResponseEnvelope
WalletHandle APIV1WalletHandle `json:"wallet_handle"`
}
// ExportMasterDerivationKeyResponse is the response to `POST /v1/master-key/export`
type ExportMasterDerivationKeyResponse struct {
APIV1ResponseEnvelope
MasterDerivationKey types.MasterDerivationKey `json:"master_derivation_key"`
}
// ImportKeyResponse is the response to `POST /v1/key/import`
type ImportKeyResponse struct {
APIV1ResponseEnvelope
Address string `json:"address"`
}
// ExportKeyResponse is the response to `POST /v1/key/export`
type ExportKeyResponse struct {
APIV1ResponseEnvelope
PrivateKey ed25519.PrivateKey `json:"private_key"`
}
// GenerateKeyResponse is the response to `POST /v1/key`
type GenerateKeyResponse struct {
APIV1ResponseEnvelope
Address string `json:"address"`
}
// DeleteKeyResponse is the response to `DELETE /v1/key`
type DeleteKeyResponse struct {
APIV1ResponseEnvelope
}
// ListKeysResponse is the response to `POST /v1/key/list`
type ListKeysResponse struct {
APIV1ResponseEnvelope
Addresses []string `json:"addresses"`
}
// SignTransactionResponse is the response to `POST /v1/transaction/sign`
type SignTransactionResponse struct {
APIV1ResponseEnvelope
SignedTransaction []byte `json:"signed_transaction"`
}
// ListMultisigResponse is the response to `POST /v1/multisig/list`
type ListMultisigResponse struct {
APIV1ResponseEnvelope
Addresses []string `json:"addresses"`
}
// ImportMultisigResponse is the response to `POST /v1/multisig/import`
type ImportMultisigResponse struct {
APIV1ResponseEnvelope
Address string `json:"address"`
}
// ExportMultisigResponse is the response to `POST /v1/multisig/export`
type ExportMultisigResponse struct {
APIV1ResponseEnvelope
Version uint8 `json:"multisig_version"`
Threshold uint8 `json:"threshold"`
PKs []ed25519.PublicKey `json:"pks"`
}
// DeleteMultisigResponse is the response to POST /v1/multisig/delete`
type DeleteMultisigResponse struct {
APIV1ResponseEnvelope
}
// SignMultisigTransactionResponse is the response to `POST /v1/multisig/sign`
type SignMultisigTransactionResponse struct {
APIV1ResponseEnvelope
Multisig []byte `json:"multisig"`
}