44 "context"
55 "fmt"
66 "io/ioutil"
7+ "sort"
78 "strconv"
89 "strings"
910
@@ -12,6 +13,8 @@ import (
1213 "github.com/prysmaticlabs/prysm/validator/flags"
1314 v2keymanager "github.com/prysmaticlabs/prysm/validator/keymanager/v2"
1415 "github.com/prysmaticlabs/prysm/validator/keymanager/v2/derived"
16+ "github.com/tyler-smith/go-bip39"
17+ "github.com/tyler-smith/go-bip39/wordlists"
1518 "github.com/urfave/cli/v2"
1619)
1720
@@ -99,6 +102,34 @@ func inputMnemonic(cliCtx *cli.Context) (string, error) {
99102 }
100103 return enteredMnemonic , nil
101104 }
105+ allowedLanguages := map [string ][]string {
106+ "english" : wordlists .English ,
107+ "chinese_simplified" : wordlists .ChineseSimplified ,
108+ "chinese_traditional" : wordlists .ChineseTraditional ,
109+ "french" : wordlists .French ,
110+ "italian" : wordlists .Italian ,
111+ "japanese" : wordlists .Japanese ,
112+ "korean" : wordlists .Korean ,
113+ "spanish" : wordlists .Spanish ,
114+ }
115+ languages := make ([]string , 0 )
116+ for k := range allowedLanguages {
117+ languages = append (languages , k )
118+ }
119+ sort .Strings (languages )
120+ selectedLanguage , err := promptutil .ValidatePrompt (
121+ fmt .Sprintf ("Enter the language of your seed phrase: %s" , strings .Join (languages , ", " )),
122+ func (input string ) error {
123+ if _ , ok := allowedLanguages [input ]; ! ok {
124+ return errors .New ("input not in the list of allowed languages" )
125+ }
126+ return nil
127+ },
128+ )
129+ if err != nil {
130+ return "" , fmt .Errorf ("could not get mnemonic language: %v" , err )
131+ }
132+ bip39 .SetWordList (allowedLanguages [selectedLanguage ])
102133 mnemonicPhrase , err := promptutil .ValidatePrompt ("Enter the seed phrase for the wallet you would like to recover" , validateMnemonic )
103134 if err != nil {
104135 return "" , fmt .Errorf ("could not get mnemonic phrase: %v" , err )
0 commit comments