-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
types.go
55 lines (46 loc) · 1.61 KB
/
types.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
package keys
// used for outputting keys.Info over REST
// AddNewKey request a new key
type AddNewKey struct {
Name string `json:"name"`
Password string `json:"password"`
Mnemonic string `json:"mnemonic"`
Account int `json:"account,string,omitempty"`
Index int `json:"index,string,omitempty"`
}
// NewAddNewKey constructs a new AddNewKey request structure.
func NewAddNewKey(name, password, mnemonic string, account, index int) AddNewKey {
return AddNewKey{
Name: name,
Password: password,
Mnemonic: mnemonic,
Account: account,
Index: index,
}
}
// RecoverKeyBody recovers a key
type RecoverKey struct {
Password string `json:"password"`
Mnemonic string `json:"mnemonic"`
Account int `json:"account,string,omitempty"`
Index int `json:"index,string,omitempty"`
}
// NewRecoverKey constructs a new RecoverKey request structure.
func NewRecoverKey(password, mnemonic string, account, index int) RecoverKey {
return RecoverKey{Password: password, Mnemonic: mnemonic, Account: account, Index: index}
}
// UpdateKeyReq requests updating a key
type UpdateKeyReq struct {
OldPassword string `json:"old_password"`
NewPassword string `json:"new_password"`
}
// NewUpdateKeyReq constructs a new UpdateKeyReq structure.
func NewUpdateKeyReq(old, new string) UpdateKeyReq {
return UpdateKeyReq{OldPassword: old, NewPassword: new}
}
// DeleteKeyReq requests deleting a key
type DeleteKeyReq struct {
Password string `json:"password"`
}
// NewDeleteKeyReq constructs a new DeleteKeyReq structure.
func NewDeleteKeyReq(password string) DeleteKeyReq { return DeleteKeyReq{Password: password} }