-
Notifications
You must be signed in to change notification settings - Fork 249
/
accounts_geth.go
51 lines (40 loc) · 1.06 KB
/
accounts_geth.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 account
import (
"time"
"github.com/ethereum/go-ethereum/accounts"
"github.com/status-im/status-go/account/generator"
"github.com/status-im/status-go/rpc"
)
// GethManager represents account manager interface.
type GethManager struct {
*Manager
gethAccManager *accounts.Manager
}
// NewGethManager returns new node account manager.
func NewGethManager() *GethManager {
m := &GethManager{}
m.Manager = &Manager{accountsGenerator: generator.New(m)}
return m
}
func (m *GethManager) SetRPCClient(rpcClient *rpc.Client, rpcTimeout time.Duration) {
m.Manager.rpcClient = rpcClient
m.Manager.rpcTimeout = rpcTimeout
}
// InitKeystore sets key manager and key store.
func (m *GethManager) InitKeystore(keydir string) error {
m.mu.Lock()
defer m.mu.Unlock()
var err error
m.gethAccManager, err = makeAccountManager(keydir)
if err != nil {
return err
}
m.keystore, err = makeKeyStore(m.gethAccManager)
m.Keydir = keydir
return err
}
func (m *GethManager) GetManager() *accounts.Manager {
m.mu.RLock()
defer m.mu.RUnlock()
return m.gethAccManager
}