workflow/restore_from_mnemonic: split assembling phrase
Before, querying the words and assembling the phrase was done in the
same loop.
Put it into two loops so we can implement the 'edit previous word'
functionality more easily.
@@ -113,18 +113,22 @@ static bool _get_mnemonic(char* mnemonic_out)
snprintf(num_words_success_msg, sizeof(num_words_success_msg), "Enter %d words", num_words);
workflow_status_blocking(num_words_success_msg, true);
+ char words[WORKFLOW_RESTORE_FROM_MNEMONIC_MAX_WORDS]
+ [WORKFLOW_TRINARY_INPUT_MAX_WORD_LENGTH + 1] = {0};
+
for (uint8_t word_idx = 0; word_idx < num_words; word_idx++) {
- char word[WORKFLOW_TRINARY_INPUT_MAX_WORD_LENGTH + 1] = {0};
char title[50] = {0};
_set_title(word_idx, title, sizeof(title));
if (!workflow_trinary_input_wordlist(
- title, (const char* const*)wordlist, BIP39_WORDLIST_LEN, word)) {
+ title, (const char* const*)wordlist, BIP39_WORDLIST_LEN, words[word_idx])) {
return false;
}
+ }
+ for (uint8_t word_idx = 0; word_idx < num_words; word_idx++) {
if (word_idx != 0) {
strcat(mnemonic_out, " "); // NOLINT (gcc and clang cannot agree on best practice here)
}
- strncat(mnemonic_out, word, WORKFLOW_TRINARY_INPUT_MAX_WORD_LENGTH);
+ strncat(mnemonic_out, words[word_idx], WORKFLOW_TRINARY_INPUT_MAX_WORD_LENGTH);
}
return true;
}
