diff --git a/VERSION b/VERSION index 8e0e24f97..03cdbb553 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.141.1 +0.141.2 diff --git a/api/geth_backend.go b/api/geth_backend.go index 961a589fd..b7e118afb 100644 --- a/api/geth_backend.go +++ b/api/geth_backend.go @@ -721,6 +721,17 @@ func (b *GethStatusBackend) RestoreAccountAndLogin(request *requests.RestoreAcco return b.generateOrImportAccount(request.Mnemonic, &request.CreateAccount) } +func (b *GethStatusBackend) GetKeyUIDByMnemonic(mnemonic string) (string, error) { + accountGenerator := b.accountManager.AccountsGenerator() + + info, err := accountGenerator.ImportMnemonic(mnemonic, "") + if err != nil { + return "", err + } + + return info.KeyUID, nil +} + func (b *GethStatusBackend) generateOrImportAccount(mnemonic string, request *requests.CreateAccount) error { if err := b.accountManager.InitKeystore(filepath.Join(request.BackupDisabledDataDir, keystoreRelativePath)); err != nil { return err diff --git a/mobile/status.go b/mobile/status.go index 01a2b39db..d4602be1e 100644 --- a/mobile/status.go +++ b/mobile/status.go @@ -792,7 +792,22 @@ func ColorID(pk string) string { func ValidateMnemonic(mnemonic string) string { m := extkeys.NewMnemonic() err := m.ValidateMnemonic(mnemonic, extkeys.Language(0)) - return makeJSONResponse(err) + if err != nil { + return makeJSONResponse(err) + } + + keyUID, err := statusBackend.GetKeyUIDByMnemonic(mnemonic) + + if err != nil { + return makeJSONResponse(err) + } + + response := &APIKeyUIDResponse{KeyUID: keyUID} + data, err := json.Marshal(response) + if err != nil { + return makeJSONResponse(err) + } + return string(data) } // DecompressPublicKey decompresses 33-byte compressed format to uncompressed 65-byte format. diff --git a/mobile/types.go b/mobile/types.go index 928c094e3..1a35e9d43 100644 --- a/mobile/types.go +++ b/mobile/types.go @@ -11,6 +11,11 @@ type APIResponse struct { Error string `json:"error"` } +// APIKeyUIDResponse +type APIKeyUIDResponse struct { + KeyUID string `json:"keyUID"` +} + // APIDetailedResponse represents a generic response // with possible errors. type APIDetailedResponse struct {