From 3f75fa5c204a342e79f5a7fd067c93ce54e7c05e Mon Sep 17 00:00:00 2001
From: poka <poka@p2p.legal>
Date: Tue, 7 Jun 2022 19:06:46 +0200
Subject: [PATCH] fix: do not valid mnemonic word if others exist in import

---
 lib/providers/generate_wallets.dart | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/lib/providers/generate_wallets.dart b/lib/providers/generate_wallets.dart
index 47150f95..9e4ec101 100644
--- a/lib/providers/generate_wallets.dart
+++ b/lib/providers/generate_wallets.dart
@@ -273,12 +273,25 @@ class GenerateWalletsProvider with ChangeNotifier {
   }
 
   bool isBipWord(String word) {
+    bool isValid = false;
     notifyListeners();
 
     // Needed for bad encoding of UTF-8
     word = word.replaceAll('é', 'é');
     word = word.replaceAll('è', 'è');
-    return bip39Words(appLang).contains(word.toLowerCase());
+
+    int nbrMatch = 0;
+    if (bip39Words(appLang).contains(word.toLowerCase())) {
+      for (var bipWord in bip39Words(appLang)) {
+        if (bipWord.startsWith(word)) {
+          log.d('ploppp : ' + nbrMatch.toString());
+          isValid = nbrMatch == 0 ? true : false;
+          nbrMatch = nbrMatch + 1;
+        }
+      }
+    }
+
+    return isValid;
   }
 
   bool isBipWordsList(List<String> words) {
-- 
GitLab