mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-13 18:10:25 +02:00
aezeed: fix mnemonic word validation
A user complained about getting a misleading error after a typo in the mnemonic. The word was `hear` and it passed the check even when it is not in the list of valid words. The reason is that we where checking if the word is in the variable `englishWordList` (which includes all the words) instead of checking if the variable is in the `defaultWordList` (which is basically `englishWoldList` split by spaces). That means that `hear` passed the check because `heart` appears in the list. Related issue [4733](https://github.com/lightningnetwork/lnd/issues/4733)
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
"encoding/binary"
|
||||
"hash/crc32"
|
||||
"io"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/Yawning/aez"
|
||||
@@ -506,8 +505,13 @@ func (m *Mnemonic) Decipher(pass []byte) ([DecipheredCipherSeedSize]byte, error)
|
||||
// Before we attempt to map the mnemonic back to the original
|
||||
// ciphertext, we'll ensure that all the word are actually a part of
|
||||
// the current default word list.
|
||||
wordDict := make(map[string]struct{}, len(defaultWordList))
|
||||
for _, word := range defaultWordList {
|
||||
wordDict[word] = struct{}{}
|
||||
}
|
||||
|
||||
for i, word := range m {
|
||||
if !strings.Contains(englishWordList, word) {
|
||||
if _, ok := wordDict[word]; !ok {
|
||||
emptySeed := [DecipheredCipherSeedSize]byte{}
|
||||
return emptySeed, ErrUnknownMnenomicWord{
|
||||
Word: word,
|
||||
|
Reference in New Issue
Block a user