feat: `GetRandomMnemonic` endpoint added to accounts api
This commit is contained in:
parent
d30c88b80e
commit
5d79b3514c
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue