status-go/account/accounts_geth.go
Pascal Precht 6859a1d3b7 Add methods to sign and recover messages/signatures to AccountManager
Also, make AccountManager a dependency of Messenger.
This is needed for community token permissions as we'll need a way to access wallet accounts
and sign messages when sending requests to join a community.

The APIs have been mostly taken from GethStatusBackend and personal service.
2023-03-16 12:25:06 +01:00

52 lines
1.1 KiB
Go

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
}