Set keystore dir & network id

This commit is contained in:
Andrea Maria Piana 2023-03-29 12:36:13 +01:00
parent 3b97f94ccc
commit 522c578a35
4 changed files with 16 additions and 4 deletions

View File

@ -90,7 +90,7 @@ func defaultSettings(generatedAccountInfo generator.GeneratedAccountInfo, derive
func defaultNodeConfig(installationID string, request *requests.CreateAccount) (*params.NodeConfig, error) {
// Set mainnet
nodeConfig := &params.NodeConfig{}
nodeConfig.NetworkID = 1
nodeConfig.NetworkID = request.NetworkID
nodeConfig.LogEnabled = request.LogEnabled
nodeConfig.LogFile = "geth.log"
nodeConfig.LogDir = request.LogFilePath

View File

@ -733,9 +733,7 @@ func (b *GethStatusBackend) GetKeyUIDByMnemonic(mnemonic string) (string, error)
}
func (b *GethStatusBackend) generateOrImportAccount(mnemonic string, request *requests.CreateAccount) error {
if err := b.accountManager.InitKeystore(filepath.Join(request.BackupDisabledDataDir, keystoreRelativePath)); err != nil {
return err
}
keystoreDir := filepath.Join(request.BackupDisabledDataDir, keystoreRelativePath)
b.UpdateRootDataDir(request.BackupDisabledDataDir)
err := b.OpenAccounts()
@ -768,6 +766,12 @@ func (b *GethStatusBackend) generateOrImportAccount(mnemonic string, request *re
return err
}
userKeyStoreDir := filepath.Join(keystoreDir, info.KeyUID)
// Initialize keystore dir with account
if err := b.accountManager.InitKeystore(userKeyStoreDir); err != nil {
return err
}
_, err = accountGenerator.StoreDerivedAccounts(info.ID, request.Password, paths)
if err != nil {
return err
@ -798,6 +802,8 @@ func (b *GethStatusBackend) generateOrImportAccount(mnemonic string, request *re
return err
}
nodeConfig.KeyStoreDir = userKeyStoreDir
walletDerivedAccount := derivedAddresses[pathDefaultWallet]
walletAccount := &accounts.Account{
PublicKey: types.Hex2Bytes(walletDerivedAccount.PublicKey),
@ -986,6 +992,7 @@ func (b *GethStatusBackend) StartNodeWithAccountAndInitialConfig(
nodecfg *params.NodeConfig,
subaccs []*accounts.Account,
) error {
b.log.Info("node config", "config", nodecfg)
err := b.SaveAccount(account)
if err != nil {
return err

View File

@ -1064,6 +1064,10 @@ func (m *Manager) DeleteCategory(request *requests.DeleteCommunityCategory) (*Co
}
func (m *Manager) HandleCommunityDescriptionMessage(signer *ecdsa.PublicKey, description *protobuf.CommunityDescription, payload []byte) (*CommunityResponse, error) {
if signer == nil {
return nil, errors.New("signer can't be nil")
}
id := crypto.CompressPubkey(signer)
community, err := m.persistence.GetByID(&m.identity.PublicKey, id)
if err != nil {

View File

@ -32,6 +32,7 @@ type CreateAccount struct {
LogEnabled bool `json:"logEnabled"`
PreviewPrivacy bool `json:"previewPrivacy"`
CurrentNetwork string `json:"currentNetwork"`
NetworkID uint64 `json:"networkId"`
}
func (c *CreateAccount) Validate() error {