Skip to content

Commit b79c420

Browse files
committed
Fix checkInputPrefix logic
1 parent d6aa06c commit b79c420

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

bip39gen/cmd/mnemonic.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,24 @@ func validateHexEntropyFlagInput(str string) error {
6767

6868
// Check if string contain hex or binary prefix and return string without it
6969
func checkInputPrefix(str string) (string, error) {
70-
if len(str) > 2 {
71-
switch str[0:2] {
72-
case "0x":
70+
if hex && len(str) > 2 {
71+
if str[0:2] == "0x" {
7372
if err := validateHexEntropyFlagInput(str[2:]); err != nil {
7473
return "", err
7574
}
7675
return strings.TrimSpace(str[2:]), nil
77-
case "0b":
76+
}
77+
}
78+
if !hex && len(str) > 2 {
79+
if str[0:2] == "0b" {
7880
if err := validateEntropyFlagInput(str[2:]); err != nil {
7981
return "", err
8082
}
8183
return strings.TrimSpace(str[2:]), nil
8284
}
85+
8386
}
87+
8488
return str, nil
8589
}
8690
func processSHA256() error {

0 commit comments

Comments
 (0)