-
Notifications
You must be signed in to change notification settings - Fork 40
/
client_helpers.go
43 lines (37 loc) · 1.54 KB
/
client_helpers.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
package seth
import (
"crypto/ecdsa"
"github.com/ethereum/go-ethereum/common"
)
// MustGetRootKeyAddress returns the root key address from the client configuration. If no addresses are found, it panics.
// Root key address is the first address in the list of addresses.
func (m *Client) MustGetRootKeyAddress() common.Address {
if err := m.validateAddressesKeyNum(0); err != nil {
panic(err)
}
return m.Addresses[0]
}
// GetRootKeyAddress returns the root key address from the client configuration. If no addresses are found, it returns an error.
// Root key address is the first address in the list of addresses.
func (m *Client) GetRootKeyAddress() (common.Address, error) {
if err := m.validateAddressesKeyNum(0); err != nil {
return common.Address{}, err
}
return m.Addresses[0], nil
}
// MustGetRootPrivateKey returns the private key of root key/address from the client configuration. If no private keys are found, it panics.
// Root private key is the first private key in the list of private keys.
func (m *Client) MustGetRootPrivateKey() *ecdsa.PrivateKey {
if err := m.validatePrivateKeysKeyNum(0); err != nil {
panic(err)
}
return m.PrivateKeys[0]
}
// GetRootPrivateKey returns the private key of root key/address from the client configuration. If no private keys are found, it returns an error.
// Root private key is the first private key in the list of private keys.
func (m *Client) GetRootPrivateKey() (*ecdsa.PrivateKey, error) {
if err := m.validatePrivateKeysKeyNum(0); err != nil {
return nil, err
}
return m.PrivateKeys[0], nil
}