Skip to content

Commit 1914ace

Browse files
Daniel Newtonjgriffiths
authored andcommitted
ui: tidy up message/error activities
Fix spelling of "re-encrypt".
1 parent be7f66d commit 1914ace

25 files changed

Lines changed: 162 additions & 246 deletions

main/camera.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,8 +569,7 @@ void jade_camera_process_images(camera_process_fn_t fn, void* ctx, const bool sh
569569
progress_bar_t* progress_bar)
570570
{
571571
JADE_LOGW("No camera supported for this device");
572-
const char* message[] = { "No camera detected" };
573-
await_error_activity(message, 1);
572+
await_error("No camera detected");
574573
}
575574

576575
#endif // CONFIG_HAS_CAMERA

main/process/auth_user.c

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ static void check_wallet_erase_pin(jade_process_t* process, const uint8_t* pin_e
4444
// Show/return 'Internal Error' message, and shut-down
4545
jade_process_reject_message(process, CBOR_RPC_INTERNAL_ERROR, "Internal Error");
4646

47-
const char* message[] = { "Internal Error!" };
48-
await_error_activity(message, 1);
47+
await_error("Internal Error!");
4948
power_shutdown();
5049
}
5150
}
@@ -222,8 +221,7 @@ static bool get_pin_load_keys(jade_process_t* process, const bool suppress_pin_c
222221

223222
jade_process_reply_to_message_fail(process);
224223

225-
const char* message[] = { "Incorrect PIN!" };
226-
await_error_activity(message, 1);
224+
await_error("Incorrect PIN!");
227225
goto cleanup;
228226
}
229227

@@ -245,8 +243,7 @@ static bool get_pin_load_keys(jade_process_t* process, const bool suppress_pin_c
245243
JADE_LOGE("Failed to derive wallet");
246244
jade_process_reject_message(process, CBOR_RPC_INTERNAL_ERROR, "Failed to derive wallet");
247245

248-
const char* message[] = { "Failed to derive wallet" };
249-
await_error_activity(message, 1);
246+
await_error("Failed to derive wallet");
250247
goto cleanup;
251248
}
252249
SENSITIVE_POP(passphrase);
@@ -268,17 +265,14 @@ static bool get_pin_load_keys(jade_process_t* process, const bool suppress_pin_c
268265
if (set_pin_get_aeskey(process, "Enter New PIN", pin, sizeof(pin), aeskey_new, sizeof(aeskey_new))) {
269266
JADE_LOGI("PIN changed on server");
270267
if (keychain_reencrypt(aeskey, sizeof(aeskey), aeskey_new, sizeof(aeskey_new))) {
271-
const char* message[] = { "PIN changed" };
272-
await_message_activity(message, 1);
268+
await_message("PIN changed");
273269
} else {
274270
JADE_LOGE("Failed to re-encrypt with changed PIN data");
275-
const char* message[] = { "Failed to re-encypt key data!" };
276-
await_error_activity(message, 1);
271+
await_error("Failed to re-encrypt key data!");
277272
}
278273
} else {
279274
JADE_LOGW("Abandoned change-PIN");
280-
const char* message[] = { "Change-PIN abandoned" };
281-
await_error_activity(message, 1);
275+
await_error("Change-PIN abandoned");
282276
}
283277
SENSITIVE_POP(aeskey_new);
284278
}
@@ -322,8 +316,7 @@ static bool set_pin_save_keys(jade_process_t* process)
322316
jade_process_reject_message(
323317
process, CBOR_RPC_INTERNAL_ERROR, "Failed to store key data encrypted in flash memory");
324318

325-
const char* message[] = { "Failed to persist key data" };
326-
await_error_activity(message, 1);
319+
await_error("Failed to persist key data");
327320
goto cleanup;
328321
}
329322

main/process/dashboard.c

Lines changed: 32 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -705,14 +705,12 @@ static void offer_jade_reset(void)
705705
} else {
706706
// Erase failed ? What can we do other than alert the user ?
707707
JADE_LOGE("Factory reset failed!");
708-
const char* message[] = { "Unable to completely", "reset Jade." };
709-
await_error_activity(message, 2);
708+
await_error_2("Unable to completely", "reset Jade.");
710709
}
711710
} else {
712711
// Incorrect - continue to boot screen
713712
JADE_LOGI("User confirmation number incorrect, not wiping data.");
714-
const char* message[] = { "Confirmation number", "incorrect!" };
715-
await_error_activity(message, 2);
713+
await_error_2("Confirmation number", "incorrect!");
716714
}
717715
}
718716

@@ -908,11 +906,9 @@ static void handle_ble_reset(void)
908906
}
909907

910908
if (ble_remove_all_devices()) {
911-
const char* message[] = { "Bluetooth pairings", "deleted" };
912-
await_message_activity(message, 2);
909+
await_message_2("Bluetooth pairings", "deleted");
913910
} else {
914-
const char* message[] = { "Failed to remove all", "Bluetooth pairings!" };
915-
await_error_activity(message, 2);
911+
await_error_2("Failed to remove all", "Bluetooth pairings!");
916912
}
917913
}
918914

@@ -967,8 +963,7 @@ static void handle_ble(void)
967963
if (keychain_get_userdata() == SOURCE_NONE) {
968964
ble_start();
969965
} else {
970-
const char* message[] = { "Bluetooth will be", "started on logout", "or disconnection" };
971-
await_message_activity(message, 3);
966+
await_message_3("Bluetooth will be", "started on logout", "or disconnection");
972967
}
973968
}
974969
ble_flags |= BLE_ENABLED;
@@ -992,11 +987,7 @@ static void handle_ble(void)
992987
}
993988
}
994989
#else
995-
static void handle_ble(void)
996-
{
997-
const char* message[] = { "BLE disabled in", "this firmware" };
998-
await_message_activity(message, 2);
999-
}
990+
static void handle_ble(void) { await_message_2("BLE disabled in", "this firmware"); }
1000991

1001992
#endif // CONFIG_BT_ENABLED
1002993

@@ -1046,13 +1037,11 @@ static bool offer_delete_registered_wallet(const char* name, const bool is_multi
10461037
const bool erased
10471038
= is_multisig ? storage_erase_multisig_registration(name) : storage_erase_descriptor_registration(name);
10481039
if (!erased) {
1049-
const char* message[] = { "Failed to delete", "registered wallet!" };
1050-
await_error_activity(message, 2);
1040+
await_error_2("Failed to delete", "registered wallet!");
10511041
return false;
10521042
}
10531043

1054-
const char* message[] = { "Registered Wallet", "Deleted" };
1055-
await_message_activity(message, 2);
1044+
await_message_2("Registered Wallet", "Deleted");
10561045
return true;
10571046
}
10581047

@@ -1072,8 +1061,7 @@ static void handle_registered_wallets(void)
10721061

10731062
const size_t num_registered_wallets = num_multisigs + num_descriptors;
10741063
if (!num_registered_wallets) {
1075-
const char* message[] = { "No additional wallets", "registered" };
1076-
await_message_activity(message, 2);
1064+
await_message_2("No additional wallets", "registered");
10771065
return;
10781066
}
10791067

@@ -1132,17 +1120,15 @@ static void handle_registered_wallets(void)
11321120
// Export as QR
11331121
if (!is_valid || num_signer_details != multisig_data.num_xpubs) {
11341122
JADE_LOGW("Unable to export multisig details - invalid or incomplete");
1135-
const char* message[] = { "Unable to export", "wallet details" };
1136-
await_error_activity(message, 2);
1123+
await_error_2("Unable to export", "wallet details");
11371124
continue;
11381125
}
11391126

11401127
// Warning for unsorted multisig, as this is not strictly handled by the origial
11411128
// common file format and may not be supported by the imprting wallet.
11421129
if (!multisig_data.sorted) {
1143-
const char* message[] = { "Exporting unsorted", "multisig - ensure the", "wallet app supports",
1144-
"this configuration" };
1145-
await_message_activity(message, 4);
1130+
await_message_4(
1131+
"Exporting unsorted", "multisig - ensure the", "wallet app supports", "this configuration");
11461132
}
11471133
display_processing_message_activity();
11481134

@@ -1153,8 +1139,7 @@ static void handle_registered_wallets(void)
11531139
if (!multisig_create_export_file(wallet_name, &multisig_data, signer_details, num_signer_details,
11541140
output, output_len, &written)) {
11551141
JADE_LOGE("Failed to export multisig details");
1156-
const char* message[] = { "Unable to export", "wallet details" };
1157-
await_error_activity(message, 2);
1142+
await_error_2("Unable to export", "wallet details");
11581143
free(output);
11591144
continue;
11601145
}
@@ -1163,8 +1148,7 @@ static void handle_registered_wallets(void)
11631148
const char* message[] = { "Export", "Multisig", "wallet" };
11641149
if (!display_bcur_bytes_qr(message, 3, (const uint8_t*)output, written, "blkstrm.com/wallets")) {
11651150
JADE_LOGE("Failed to create multisig export details QR code");
1166-
const char* message[] = { "Unable to export", "wallet details" };
1167-
await_error_activity(message, 2);
1151+
await_error_2("Unable to export", "wallet details");
11681152
free(output);
11691153
continue;
11701154
}
@@ -1214,8 +1198,7 @@ static void handle_registered_wallets(void)
12141198
if (!descriptor_get_signers(wallet_name, &descriptor, NETWORK_NONE, NULL, signer_details,
12151199
MAX_ALLOWED_SIGNERS, &num_signer_details, &errmsg)) {
12161200
JADE_LOGE("Failed to load signer information from descriptor data");
1217-
const char* message[] = { "Unable to load", "signer details" };
1218-
await_error_activity(message, 2);
1201+
await_error_2("Unable to load", "signer details");
12191202
continue;
12201203
}
12211204

@@ -1314,8 +1297,7 @@ static void handle_wallet_erase_pin(void)
13141297
JADE_LOGI("Erasing Wallet-Erase PIN");
13151298
storage_erase_wallet_erase_pin();
13161299

1317-
const char* message[] = { "Wallet-Erase PIN", "deleted" };
1318-
await_message_activity(message, 2);
1300+
await_message_2("Wallet-Erase PIN", "deleted");
13191301
} else if (ev_id == BTN_WALLET_ERASE_PIN_HELP) {
13201302
await_qr_help_activity("blkstrm.com/duress");
13211303
} else if (ev_id == BTN_WALLET_ERASE_PIN_EXIT) {
@@ -1429,13 +1411,11 @@ static bool delete_otp_record(const char* otpname)
14291411
}
14301412

14311413
if (!storage_erase_otp(otpname)) {
1432-
const char* message[] = { "Failed to delete", "OTP record!" };
1433-
await_error_activity(message, 2);
1414+
await_error_2("Failed to delete", "OTP record!");
14341415
return false;
14351416
}
14361417

1437-
const char* message[] = { "OTP Record Deleted" };
1438-
await_message_activity(message, 1);
1418+
await_message("OTP Record Deleted");
14391419
return true;
14401420
}
14411421

@@ -1532,13 +1512,11 @@ static bool display_totp_screen(otpauth_ctx_t* otp_ctx, uint64_t epoch_value, ch
15321512
if (auto_update) {
15331513
switch (otp_set_default_value(otp_ctx, &epoch_value)) {
15341514
case OTP_ERR_TOTP_TIME: {
1535-
const char* msg_totp[] = { "Failed to fetch time.", "Unlock with the", "Blockstream app." };
1536-
await_error_activity(msg_totp, 3);
1515+
await_error_3("Failed to fetch time.", "Unlock with the", "Blockstream app.");
15371516
return false;
15381517
}
15391518
case OTP_ERR_HOTP_COUNTER: {
1540-
const char* msg_hotp[] = { "Failed to fetch", "counter!" };
1541-
await_error_activity(msg_hotp, 2);
1519+
await_error_2("Failed to fetch", "counter!");
15421520
return false;
15431521
}
15441522
case OTP_ERR_OK:
@@ -1551,8 +1529,7 @@ static bool display_totp_screen(otpauth_ctx_t* otp_ctx, uint64_t epoch_value, ch
15511529
if (count < last_count) {
15521530
// Wrapped - token code should have changed
15531531
if (!otp_get_auth_code(otp_ctx, token, token_len)) {
1554-
const char* message[] = { "Failed to calculate", "OTP!" };
1555-
await_error_activity(message, 2);
1532+
await_error_2("Failed to calculate", "OTP!");
15561533
return false;
15571534
}
15581535
gui_update_text(txt_code, token);
@@ -1617,13 +1594,11 @@ static bool show_otp_code(otpauth_ctx_t* otp_ctx)
16171594
uint64_t value = 0;
16181595
switch (otp_set_default_value(otp_ctx, &value)) {
16191596
case OTP_ERR_TOTP_TIME: {
1620-
const char* msg_totp[] = { "Failed to fetch time.", "Unlock with the", "Blockstream app." };
1621-
await_error_activity(msg_totp, 3);
1597+
await_error_3("Failed to fetch time.", "Unlock with the", "Blockstream app.");
16221598
return false;
16231599
}
16241600
case OTP_ERR_HOTP_COUNTER: {
1625-
const char* msg_hotp[] = { "Failed to fetch", "counter!" };
1626-
await_error_activity(msg_hotp, 2);
1601+
await_error_2("Failed to fetch", "counter!");
16271602
return false;
16281603
}
16291604
case OTP_ERR_OK:
@@ -1633,8 +1608,7 @@ static bool show_otp_code(otpauth_ctx_t* otp_ctx)
16331608
// Calculate token
16341609
char token[OTP_MAX_TOKEN_LEN];
16351610
if (!otp_get_auth_code(otp_ctx, token, sizeof(token))) {
1636-
const char* message[] = { "Failed to calculate", "OTP!" };
1637-
await_error_activity(message, 2);
1611+
await_error_2("Failed to calculate", "OTP!");
16381612
return false;
16391613
}
16401614

@@ -1654,8 +1628,7 @@ static void handle_view_otps(void)
16541628
JADE_ASSERT(done);
16551629

16561630
if (num_otp_records == 0) {
1657-
const char* message[] = { "No OTP records", "registered" };
1658-
await_message_activity(message, 2);
1631+
await_message_2("No OTP records", "registered");
16591632
return;
16601633
}
16611634

@@ -1937,8 +1910,7 @@ static void handle_pinserver_scan(void)
19371910
{
19381911
if (keychain_has_pin()) {
19391912
// Not allowed if wallet initialised
1940-
const char* message[] = { "Set Oracle not", "permitted once", "wallet initialized" };
1941-
await_error_activity(message, 3);
1913+
await_error_3("Set Oracle not", "permitted once", "wallet initialized");
19421914
return;
19431915
}
19441916

@@ -1953,8 +1925,7 @@ static void handle_pinserver_scan(void)
19531925
}
19541926

19551927
if (!type || strcasecmp(type, BCUR_TYPE_JADE_UPDPS) || !data || !data_len) {
1956-
const char* message[] = { "Failed to parse Oracle data" };
1957-
await_error_activity(message, 1);
1928+
await_error("Failed to parse Oracle data");
19581929
goto cleanup;
19591930
}
19601931

@@ -1963,8 +1934,7 @@ static void handle_pinserver_scan(void)
19631934
goto cleanup;
19641935
}
19651936

1966-
const char* message[] = { "Oracle details updated" };
1967-
await_message_activity(message, 1);
1937+
await_message("Oracle details updated");
19681938

19691939
cleanup:
19701940
free(type);
@@ -1976,16 +1946,14 @@ static void handle_pinserver_reset(void)
19761946
{
19771947
if (keychain_has_pin()) {
19781948
// Not allowed if wallet initialised
1979-
const char* message[] = { "Reset Oracle not", "permitted once", "wallet initialized" };
1980-
await_error_activity(message, 3);
1949+
await_error_3("Reset Oracle not", "permitted once", "wallet initialized");
19811950
return;
19821951
}
19831952

19841953
const char* question[] = { "Reset Oracle details", "and certificate?" };
19851954
if (await_yesno_activity("Reset Oracle", question, 2, false, NULL)) {
19861955
if (!reset_pinserver()) {
1987-
const char* message[] = { "Error resetting Oracle" };
1988-
await_error_activity(message, 1);
1956+
await_error("Error resetting Oracle");
19891957
}
19901958
}
19911959
}
@@ -1995,8 +1963,7 @@ static void handle_storage(void)
19951963
{
19961964
size_t entries_used, entries_free;
19971965
if (!storage_get_stats(&entries_used, &entries_free)) {
1998-
const char* message[] = { "Error accessing storage!" };
1999-
await_error_activity(message, 1);
1966+
await_error("Error accessing storage!");
20001967
return;
20011968
}
20021969

@@ -2377,8 +2344,7 @@ static void handle_settings(const bool startup_menu)
23772344
tolerate_usb_disconnection = true;
23782345
done = usbstorage_firmware_ota(NULL);
23792346
} else {
2380-
const char* message[] = { "Unlock with PIN before", "initiating firmware update" };
2381-
await_error_activity(message, 2);
2347+
await_error_2("Unlock with PIN before", "initiating firmware update");
23822348
}
23832349
break;
23842350

main/process/debug_clean.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ void debug_clean_reset_process(void* process_ptr)
2020
ASSERT_CURRENT_MESSAGE(process, "debug_clean_reset");
2121

2222
// Pop up a notification that the wallet is being wiped
23-
const char* message[] = { "Warning: debug wipe" };
24-
await_message_activity(message, 1);
23+
await_message("Warning: debug wipe");
2524
vTaskDelay(250 / portTICK_PERIOD_MS);
2625

2726
// Clean keychain from memory and storage

main/process/debug_set_mnemonic.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ void debug_set_mnemonic_process(void* process_ptr)
103103

104104
// Pop up a notification that the wallet has been injected
105105
// (In a 'real' scenario the wallet is not set without some gui activity)
106-
const char* message[] = { "Warning: debug wallet" };
107-
await_message_activity(message, 1);
106+
await_message("Warning: debug wallet");
108107
vTaskDelay(250 / portTICK_PERIOD_MS);
109108

110109
// Copy temporary keychain into a new global keychain

main/process/get_bip85_entropy.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,7 @@ void show_bip85_bip39_entropy_process(void* process_ptr)
371371
if (errcode) {
372372
if (errcode != CBOR_RPC_USER_CANCELLED) {
373373
JADE_LOGE("Error generating encrypted bip85 entropy: %s", errmsg);
374-
const char* message[] = { "Error in bip85/bip39", errmsg };
375-
await_error_activity(message, 2);
374+
await_error_2("Error in bip85/bip39", errmsg);
376375
}
377376
// An error occurred, or the user cancelled the action
378377
jade_process_reject_message(process, errcode, errmsg);

main/process/get_identity_pubkey.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ void get_identity_pubkey_process(void* process_ptr)
4545
JADE_LOGE("No wallet seed available. Wallet must be re-initialised from mnemonic.");
4646
jade_process_reject_message(process, CBOR_RPC_INTERNAL_ERROR, "Feature requires resetting Jade");
4747

48-
const char* message[] = { "Feature requires Jade reset" };
49-
await_error_activity(message, 1);
48+
await_error("Feature requires Jade reset");
5049

5150
goto cleanup;
5251
}

0 commit comments

Comments
 (0)