-
Notifications
You must be signed in to change notification settings - Fork 105
/
status.go
44 lines (33 loc) · 835 Bytes
/
status.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
package wallet
import (
"github.com/urfave/cli"
"github.com/rocket-pool/smartnode/shared/services"
"github.com/rocket-pool/smartnode/shared/types/api"
)
func getStatus(c *cli.Context) (*api.WalletStatusResponse, error) {
// Get services
pm, err := services.GetPasswordManager(c)
if err != nil {
return nil, err
}
w, err := services.GetWallet(c)
if err != nil {
return nil, err
}
// Response
response := api.WalletStatusResponse{}
// Get wallet status
response.PasswordSet = pm.IsPasswordSet()
response.WalletInitialized = w.IsInitialized()
// Get accounts if initialized
if response.WalletInitialized {
// Get node account
nodeAccount, err := w.GetNodeAccount()
if err != nil {
return nil, err
}
response.AccountAddress = nodeAccount.Address
}
// Return response
return &response, nil
}