status-go/account/accounts_geth.go

44 lines
879 B
Go
Raw Normal View History

package account
import (
"github.com/ethereum/go-ethereum/accounts"
2020-01-02 09:10:19 +00:00
"github.com/status-im/status-go/account/generator"
)
// GethManager represents account manager interface.
type GethManager struct {
2019-12-30 09:43:51 +00:00
*Manager
2019-12-30 09:43:51 +00:00
gethAccManager *accounts.Manager
}
2019-11-27 12:22:23 +00:00
// NewGethManager returns new node account manager.
func NewGethManager() *GethManager {
m := &GethManager{}
2019-12-30 09:43:51 +00:00
m.Manager = &Manager{accountsGenerator: generator.New(m)}
return m
}
// InitKeystore sets key manager and key store.
func (m *GethManager) InitKeystore(keydir string) error {
m.mu.Lock()
defer m.mu.Unlock()
var err error
2019-12-30 09:43:51 +00:00
m.gethAccManager, err = makeAccountManager(keydir)
if err != nil {
return err
}
2019-12-30 09:43:51 +00:00
m.keystore, err = makeKeyStore(m.gethAccManager)
m.Keydir = keydir
return err
}
func (m *GethManager) GetManager() *accounts.Manager {
m.mu.RLock()
defer m.mu.RUnlock()
2019-12-30 09:43:51 +00:00
return m.gethAccManager
}