-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathkeys.go
51 lines (40 loc) · 1.08 KB
/
keys.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
package walletapi
// ViewKey - gets the private view key of the wallet container
func (wAPI WalletAPI) ViewKey() (string, error) {
var vk string
resp, _, err := wAPI.sendRequest(
"GET",
wAPI.Host+":"+wAPI.Port+"/keys",
"",
)
if err == nil {
vk = (*resp)["privateViewKey"].(string)
}
return vk, err
}
// GetKeys - gets the public and private view key for the given address
func (wAPI WalletAPI) GetKeys(address string) (publicSpendKey, privateSpendKey string, err error) {
resp, _, err := wAPI.sendRequest(
"GET",
wAPI.Host+":"+wAPI.Port+"/keys/"+address,
"",
)
if err == nil {
privateSpendKey = (*resp)["privateSpendKey"].(string)
publicSpendKey = (*resp)["publicSpendKey"].(string)
}
return publicSpendKey, privateSpendKey, err
}
// GetMnemonic - gets the mnemonic seed for the given address
func (wAPI WalletAPI) GetMnemonic(address string) (string, error) {
var seed string
resp, _, err := wAPI.sendRequest(
"GET",
wAPI.Host+":"+wAPI.Port+"/keys/mnemonic/"+address,
"",
)
if err == nil {
seed = (*resp)["mnemonicSeed"].(string)
}
return seed, err
}