Skip to content

Commit

Permalink
[mobile] added method to check if mnemotic is valid
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Lenz committed May 3, 2018
1 parent 1f3c123 commit 40fc241
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions mobile/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}

0 comments on commit 40fc241

Please sign in to comment.