From 4be9a1f6067a08adf9144a1f31eb520ddaabc8c7 Mon Sep 17 00:00:00 2001 From: munzzyy Date: Mon, 3 Aug 2026 12:59:15 -0500 Subject: [PATCH] fix: never offer the correct seed word twice when verifying The pick-the-correct-word screen built its options by taking 5 words off the top of a shuffled wordlist and then appending the answer, so whenever the answer was already among those 5 it was listed twice. The toSet() call meant to catch that threw its result away. The shuffle also ran on the caller's list rather than a copy, which permanently reordered Bip39.english for the rest of the session. --- lib/view_model/verify_seed_view_model.dart | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/view_model/verify_seed_view_model.dart b/lib/view_model/verify_seed_view_model.dart index 73eba30..e235c2e 100644 --- a/lib/view_model/verify_seed_view_model.dart +++ b/lib/view_model/verify_seed_view_model.dart @@ -26,12 +26,11 @@ abstract class VerifySeedViewModelBase extends ViewModel with Store { String get randomWord => seedWords[randomIndex]; late final List randomWords = () { - final w = wordList; - w.shuffle(Random.secure()); - final elms = w.take(5).toList(); - elms.add(randomWord); - elms.toSet(); // in case we got a duplicate - return elms.toList()..shuffle(Random.secure()); + // Copy before shuffling, wordList is shared (Bip39.english is a static). + final shuffled = List.of(wordList)..shuffle(Random.secure()); + // Drop the correct word so it cannot show up as a decoy as well. + final decoys = shuffled.toSet()..remove(randomWord); + return [...decoys.take(5), randomWord]..shuffle(Random.secure()); }(); bool result(final String guessedWord) {