Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Correct exit msg for clear device data #453

Merged
merged 1 commit into from
Jan 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/settings/factory_reset.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,14 @@ static bool filter_common_wallet(bool match_found);
* found in 2 X1 cards.
*
* @param wallets_in_vault
* @param exit_msgs
* @return true If wallet share is present in atleast 2 X1 cards for each wallet
* present on the device.
* @return false If wallet share is NOT present in atleast 2 X1 cards, or any
* error occured in the card flow
*/
static bool safe_to_delete_wallet_share(wallet_list_t *wallets_in_vault);
static bool safe_to_delete_wallet_share(wallet_list_t *wallets_in_vault,
const char *exit_msgs[]);

/*****************************************************************************
* STATIC VARIABLES
Expand Down Expand Up @@ -253,7 +255,8 @@ static bool get_wallet_list_from_two_cards(wallet_list_t *wallet_list) {
return true;
}

static bool safe_to_delete_wallet_share(wallet_list_t *wallets_in_vault) {
static bool safe_to_delete_wallet_share(wallet_list_t *wallets_in_vault,
const char *exit_msgs[]) {
wallet_list_t wallets_in_cards = {0};
if (!get_wallet_list_from_two_cards(&wallets_in_cards)) {
return false;
Expand All @@ -272,8 +275,7 @@ static bool safe_to_delete_wallet_share(wallet_list_t *wallets_in_vault) {
// TODO: Update message to show ALL missing wallets instead of just one
// wallet
char msg[64];
const char *msg_list[3] = {
msg, ui_text_reset_exit[0], ui_text_reset_exit[1]};
const char *msg_list[3] = {msg, exit_msgs[0], exit_msgs[1]};

snprintf(msg,
sizeof(msg),
Expand Down Expand Up @@ -307,7 +309,8 @@ void factory_reset(void) {

// If there is atleast one valid wallet on the device, ensure that it is
// present in atleast 2 X1 cards
if (0 < valid_wallets && !safe_to_delete_wallet_share(&wallets_in_vault)) {
if (0 < valid_wallets &&
!safe_to_delete_wallet_share(&wallets_in_vault, ui_text_reset_exit)) {
return;
}

Expand Down Expand Up @@ -342,7 +345,9 @@ void clear_device_data(void) {

// If there is atleast one valid wallet on the device, ensure that it is
// present in atleast 2 X1 cards
if (0 < valid_wallets && !safe_to_delete_wallet_share(&wallets_in_vault)) {
if (0 < valid_wallets &&
!safe_to_delete_wallet_share(&wallets_in_vault,
ui_text_clear_wallet_data_exit)) {
return;
}

Expand Down