From 40fc241dac5d7e8b096d05785d78765c189431a0 Mon Sep 17 00:00:00 2001 From: Florian Lenz Date: Thu, 3 May 2018 19:36:01 +0200 Subject: [PATCH] [mobile] added method to check if mnemotic is valid --- mobile/utils.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mobile/utils.go b/mobile/utils.go index 298d270..1810948 100644 --- a/mobile/utils.go +++ b/mobile/utils.go @@ -8,6 +8,8 @@ import ( "github.com/Bit-Nation/panthalassa/keyManager" "github.com/Bit-Nation/panthalassa/keyStore" mnemonic "github.com/Bit-Nation/panthalassa/mnemonic" + "github.com/tyler-smith/go-bip39" + "strings" ) //Encrypt's data @@ -87,3 +89,15 @@ func CIDSha256(value string) (string, error) { func IsValidCID(c string) bool { return cid.IsValidCid(c) } + +//Check if mnemonic is valid +func IsValidMnemonic(mne string) bool { + + words := strings.Split(mne, " ") + + if len(words) != 24 { + return false + } + + return bip39.IsMnemonicValid(mne) +}