feat: mobile status.go - getRandomMnemonic (#4712)
* feat: mobile status.go - getRandomMnemonic (#4712)
This commit is contained in:
parent
38ee792081
commit
54d0cf28c7
|
@ -114,16 +114,6 @@ func (m *DefaultManager) AccountsGenerator() *generator.Generator {
|
|||
return m.accountsGenerator
|
||||
}
|
||||
|
||||
func (m *DefaultManager) 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
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
"github.com/status-im/status-go/extkeys"
|
||||
"github.com/status-im/status-go/multiaccounts"
|
||||
)
|
||||
|
||||
|
@ -117,3 +118,13 @@ func ToAddress(accountAddress string) *types.Address {
|
|||
|
||||
return &to.Address
|
||||
}
|
||||
|
||||
func 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
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import (
|
|||
"github.com/status-im/zxcvbn-go/scoring"
|
||||
|
||||
abi_spec "github.com/status-im/status-go/abi-spec"
|
||||
"github.com/status-im/status-go/account"
|
||||
"github.com/status-im/status-go/api"
|
||||
"github.com/status-im/status-go/api/multiformat"
|
||||
"github.com/status-im/status-go/eth-node/crypto"
|
||||
|
@ -1327,3 +1328,11 @@ func InitLogging(logSettingsJSON string) string {
|
|||
|
||||
return makeJSONResponse(err)
|
||||
}
|
||||
|
||||
func GetRandomMnemonic() string {
|
||||
mnemonic, err := account.GetRandomMnemonic()
|
||||
if err != nil {
|
||||
return makeJSONResponse(err)
|
||||
}
|
||||
return mnemonic
|
||||
}
|
||||
|
|
|
@ -456,7 +456,7 @@ func (api *API) MakeSeedPhraseKeypairFullyOperable(ctx context.Context, mnemonic
|
|||
|
||||
// Creates a random new mnemonic.
|
||||
func (api *API) GetRandomMnemonic(ctx context.Context) (string, error) {
|
||||
return api.manager.GetRandomMnemonic()
|
||||
return account.GetRandomMnemonic()
|
||||
}
|
||||
|
||||
func (api *API) VerifyKeystoreFileForAccount(address types.Address, password string) bool {
|
||||
|
|
Loading…
Reference in New Issue