feat: `GetRandomMnemonic` endpoint added to accounts api

This commit is contained in:
Sale Djenic 2023-03-21 13:14:51 +01:00 committed by saledjenic
parent d30c88b80e
commit 5d79b3514c
2 changed files with 15 additions and 0 deletions

View File

@ -90,6 +90,16 @@ func (m *Manager) AccountsGenerator() *generator.Generator {
return m.accountsGenerator
}
func (m *Manager) GetRandomMnemonic() (string, error) {
// generate mnemonic phrase
mn := extkeys.NewMnemonic()
mnemonic, err := mn.MnemonicPhrase(extkeys.EntropyStrength128, extkeys.EnglishLanguage)
if err != nil {
return "", fmt.Errorf("can not create mnemonic seed: %v", err)
}
return mnemonic, nil
}
// CreateAccount creates an internal geth account
// BIP44-compatible keys are generated: CKD#1 is stored as account key, CKD#2 stored as sub-account root
// Public key of CKD#1 is returned, with CKD#2 securely encoded into account key file (to be used for

View File

@ -214,6 +214,11 @@ func (api *API) ImportMnemonic(ctx context.Context, mnemonic string, password st
return err
}
// Creates a random new mnemonic.
func (api *API) GetRandomMnemonic(ctx context.Context) (string, error) {
return api.manager.GetRandomMnemonic()
}
func (api *API) VerifyPassword(password string) bool {
address, err := api.db.GetChatAddress()
if err != nil {