ui: tidy up message/error activities
What changed, and why it matters
This commit is a straightforward code cleanup. It replaces a verbose way of showing on-screen messages and errors with simpler helper functions, and fixes a spelling mistake ('re-encypt' to 're-encrypt'). There is no change to security logic, no bug fix, and no vulnerability addressed.
No security action required. Treat as normal code maintenance.
Security signals we found
No security-relevant logic changes
Refactoring only: API simplification for UI message display
Spelling correction in user-facing error string
Evidence from the diff
The change refactors UI message/error display across the Jade firmware. The old API required callers to build a const char* message[] array and pass its length to await_message_activity() or await_error_activity(). The new API exposes variadic-style helpers such as await_message(), await_message_2(), await_error(), await_error_3(), etc. The underlying await_message_activity() is now static and still used internally. The only functional text change is correcting the spelling of ‘Failed to re-encypt key data!’ to ‘Failed to re-encrypt key data!’. No security-sensitive behavior is altered.
Changed components
main/ui.hmain/ui/dialogs.cmultiple process files using message/error activitiesInspect captured patch +162 / −246
diff --git a/main/camera.c b/main/camera.c
index 74a45fb..e2e826c 100644
--- a/main/camera.c
+++ b/main/camera.c
@@ -569,8 +569,7 @@ void jade_camera_process_images(camera_process_fn_t fn, void* ctx, const bool sh
progress_bar_t* progress_bar)
{
JADE_LOGW("No camera supported for this device");
- const char* message[] = { "No camera detected" };
- await_error_activity(message, 1);
+ await_error("No camera detected");
}
#endif // CONFIG_HAS_CAMERA
diff --git a/main/process/auth_user.c b/main/process/auth_user.c
index ac61af5..3e7cd24 100644
--- a/main/process/auth_user.c
+++ b/main/process/auth_user.c
@@ -44,8 +44,7 @@ static void check_wallet_erase_pin(jade_process_t* process, const uint8_t* pin_e
// Show/return 'Internal Error' message, and shut-down
jade_process_reject_message(process, CBOR_RPC_INTERNAL_ERROR, "Internal Error");
- const char* message[] = { "Internal Error!" };
- await_error_activity(message, 1);
+ await_error("Internal Error!");
power_shutdown();
}
}
@@ -222,8 +221,7 @@ static bool get_pin_load_keys(jade_process_t* process, const bool suppress_pin_c
jade_process_reply_to_message_fail(process);
- const char* message[] = { "Incorrect PIN!" };
- await_error_activity(message, 1);
+ await_error("Incorrect PIN!");
goto cleanup;
}
@@ -245,8 +243,7 @@ static bool get_pin_load_keys(jade_process_t* process, const bool suppress_pin_c
JADE_LOGE("Failed to derive wallet");
jade_process_reject_message(process, CBOR_RPC_INTERNAL_ERROR, "Failed to derive wallet");
- const char* message[] = { "Failed to derive wallet" };
- await_error_activity(message, 1);
+ await_error("Failed to derive wallet");
goto cleanup;
}
SENSITIVE_POP(passphrase);
@@ -268,17 +265,14 @@ static bool get_pin_load_keys(jade_process_t* process, const bool suppress_pin_c
if (set_pin_get_aeskey(process, "Enter New PIN", pin, sizeof(pin), aeskey_new, sizeof(aeskey_new))) {
JADE_LOGI("PIN changed on server");
if (keychain_reencrypt(aeskey, sizeof(aeskey), aeskey_new, sizeof(aeskey_new))) {
- const char* message[] = { "PIN changed" };
- await_message_activity(message, 1);
+ await_message("PIN changed");
} else {
JADE_LOGE("Failed to re-encrypt with changed PIN data");
- const char* message[] = { "Failed to re-encypt key data!" };
- await_error_activity(message, 1);
+ await_error("Failed to re-encrypt key data!");
}
} else {
JADE_LOGW("Abandoned change-PIN");
- const char* message[] = { "Change-PIN abandoned" };
- await_error_activity(message, 1);
+ await_error("Change-PIN abandoned");
}
SENSITIVE_POP(aeskey_new);
}
@@ -322,8 +316,7 @@ static bool set_pin_save_keys(jade_process_t* process)
jade_process_reject_message(
process, CBOR_RPC_INTERNAL_ERROR, "Failed to store key data encrypted in flash memory");
- const char* message[] = { "Failed to persist key data" };
- await_error_activity(message, 1);
+ await_error("Failed to persist key data");
goto cleanup;
}
diff --git a/main/process/dashboard.c b/main/process/dashboard.c
index caf55f0..bb3a443 100644
--- a/main/process/dashboard.c
+++ b/main/process/dashboard.c
@@ -705,14 +705,12 @@ static void offer_jade_reset(void)
} else {
// Erase failed ? What can we do other than alert the user ?
JADE_LOGE("Factory reset failed!");
- const char* message[] = { "Unable to completely", "reset Jade." };
- await_error_activity(message, 2);
+ await_error_2("Unable to completely", "reset Jade.");
}
} else {
// Incorrect - continue to boot screen
JADE_LOGI("User confirmation number incorrect, not wiping data.");
- const char* message[] = { "Confirmation number", "incorrect!" };
- await_error_activity(message, 2);
+ await_error_2("Confirmation number", "incorrect!");
}
}
@@ -908,11 +906,9 @@ static void handle_ble_reset(void)
}
if (ble_remove_all_devices()) {
- const char* message[] = { "Bluetooth pairings", "deleted" };
- await_message_activity(message, 2);
+ await_message_2("Bluetooth pairings", "deleted");
} else {
- const char* message[] = { "Failed to remove all", "Bluetooth pairings!" };
- await_error_activity(message, 2);
+ await_error_2("Failed to remove all", "Bluetooth pairings!");
}
}
@@ -967,8 +963,7 @@ static void handle_ble(void)
if (keychain_get_userdata() == SOURCE_NONE) {
ble_start();
} else {
- const char* message[] = { "Bluetooth will be", "started on logout", "or disconnection" };
- await_message_activity(message, 3);
+ await_message_3("Bluetooth will be", "started on logout", "or disconnection");
}
}
ble_flags |= BLE_ENABLED;
@@ -992,11 +987,7 @@ static void handle_ble(void)
}
}
#else
-static void handle_ble(void)
-{
- const char* message[] = { "BLE disabled in", "this firmware" };
- await_message_activity(message, 2);
-}
+static void handle_ble(void) { await_message_2("BLE disabled in", "this firmware"); }
#endif // CONFIG_BT_ENABLED
@@ -1046,13 +1037,11 @@ static bool offer_delete_registered_wallet(const char* name, const bool is_multi
const bool erased
= is_multisig ? storage_erase_multisig_registration(name) : storage_erase_descriptor_registration(name);
if (!erased) {
- const char* message[] = { "Failed to delete", "registered wallet!" };
- await_error_activity(message, 2);
+ await_error_2("Failed to delete", "registered wallet!");
return false;
}
- const char* message[] = { "Registered Wallet", "Deleted" };
- await_message_activity(message, 2);
+ await_message_2("Registered Wallet", "Deleted");
return true;
}
@@ -1072,8 +1061,7 @@ static void handle_registered_wallets(void)
const size_t num_registered_wallets = num_multisigs + num_descriptors;
if (!num_registered_wallets) {
- const char* message[] = { "No additional wallets", "registered" };
- await_message_activity(message, 2);
+ await_message_2("No additional wallets", "registered");
return;
}
@@ -1132,17 +1120,15 @@ static void handle_registered_wallets(void)
// Export as QR
if (!is_valid || num_signer_details != multisig_data.num_xpubs) {
JADE_LOGW("Unable to export multisig details - invalid or incomplete");
- const char* message[] = { "Unable to export", "wallet details" };
- await_error_activity(message, 2);
+ await_error_2("Unable to export", "wallet details");
continue;
}
// Warning for unsorted multisig, as this is not strictly handled by the origial
// common file format and may not be supported by the imprting wallet.
if (!multisig_data.sorted) {
- const char* message[] = { "Exporting unsorted", "multisig - ensure the", "wallet app supports",
- "this configuration" };
- await_message_activity(message, 4);
+ await_message_4(
+ "Exporting unsorted", "multisig - ensure the", "wallet app supports", "this configuration");
}
display_processing_message_activity();
@@ -1153,8 +1139,7 @@ static void handle_registered_wallets(void)
if (!multisig_create_export_file(wallet_name, &multisig_data, signer_details, num_signer_details,
output, output_len, &written)) {
JADE_LOGE("Failed to export multisig details");
- const char* message[] = { "Unable to export", "wallet details" };
- await_error_activity(message, 2);
+ await_error_2("Unable to export", "wallet details");
free(output);
continue;
}
@@ -1163,8 +1148,7 @@ static void handle_registered_wallets(void)
const char* message[] = { "Export", "Multisig", "wallet" };
if (!display_bcur_bytes_qr(message, 3, (const uint8_t*)output, written, "blkstrm.com/wallets")) {
JADE_LOGE("Failed to create multisig export details QR code");
- const char* message[] = { "Unable to export", "wallet details" };
- await_error_activity(message, 2);
+ await_error_2("Unable to export", "wallet details");
free(output);
continue;
}
@@ -1214,8 +1198,7 @@ static void handle_registered_wallets(void)
if (!descriptor_get_signers(wallet_name, &descriptor, NETWORK_NONE, NULL, signer_details,
MAX_ALLOWED_SIGNERS, &num_signer_details, &errmsg)) {
JADE_LOGE("Failed to load signer information from descriptor data");
- const char* message[] = { "Unable to load", "signer details" };
- await_error_activity(message, 2);
+ await_error_2("Unable to load", "signer details");
continue;
}
@@ -1314,8 +1297,7 @@ static void handle_wallet_erase_pin(void)
JADE_LOGI("Erasing Wallet-Erase PIN");
storage_erase_wallet_erase_pin();
- const char* message[] = { "Wallet-Erase PIN", "deleted" };
- await_message_activity(message, 2);
+ await_message_2("Wallet-Erase PIN", "deleted");
} else if (ev_id == BTN_WALLET_ERASE_PIN_HELP) {
await_qr_help_activity("blkstrm.com/duress");
} else if (ev_id == BTN_WALLET_ERASE_PIN_EXIT) {
@@ -1429,13 +1411,11 @@ static bool delete_otp_record(const char* otpname)
}
if (!storage_erase_otp(otpname)) {
- const char* message[] = { "Failed to delete", "OTP record!" };
- await_error_activity(message, 2);
+ await_error_2("Failed to delete", "OTP record!");
return false;
}
- const char* message[] = { "OTP Record Deleted" };
- await_message_activity(message, 1);
+ await_message("OTP Record Deleted");
return true;
}
@@ -1532,13 +1512,11 @@ static bool display_totp_screen(otpauth_ctx_t* otp_ctx, uint64_t epoch_value, ch
if (auto_update) {
switch (otp_set_default_value(otp_ctx, &epoch_value)) {
case OTP_ERR_TOTP_TIME: {
- const char* msg_totp[] = { "Failed to fetch time.", "Unlock with the", "Blockstream app." };
- await_error_activity(msg_totp, 3);
+ await_error_3("Failed to fetch time.", "Unlock with the", "Blockstream app.");
return false;
}
case OTP_ERR_HOTP_COUNTER: {
- const char* msg_hotp[] = { "Failed to fetch", "counter!" };
- await_error_activity(msg_hotp, 2);
+ await_error_2("Failed to fetch", "counter!");
return false;
}
case OTP_ERR_OK:
@@ -1551,8 +1529,7 @@ static bool display_totp_screen(otpauth_ctx_t* otp_ctx, uint64_t epoch_value, ch
if (count < last_count) {
// Wrapped - token code should have changed
if (!otp_get_auth_code(otp_ctx, token, token_len)) {
- const char* message[] = { "Failed to calculate", "OTP!" };
- await_error_activity(message, 2);
+ await_error_2("Failed to calculate", "OTP!");
return false;
}
gui_update_text(txt_code, token);
@@ -1617,13 +1594,11 @@ static bool show_otp_code(otpauth_ctx_t* otp_ctx)
uint64_t value = 0;
switch (otp_set_default_value(otp_ctx, &value)) {
case OTP_ERR_TOTP_TIME: {
- const char* msg_totp[] = { "Failed to fetch time.", "Unlock with the", "Blockstream app." };
- await_error_activity(msg_totp, 3);
+ await_error_3("Failed to fetch time.", "Unlock with the", "Blockstream app.");
return false;
}
case OTP_ERR_HOTP_COUNTER: {
- const char* msg_hotp[] = { "Failed to fetch", "counter!" };
- await_error_activity(msg_hotp, 2);
+ await_error_2("Failed to fetch", "counter!");
return false;
}
case OTP_ERR_OK:
@@ -1633,8 +1608,7 @@ static bool show_otp_code(otpauth_ctx_t* otp_ctx)
// Calculate token
char token[OTP_MAX_TOKEN_LEN];
if (!otp_get_auth_code(otp_ctx, token, sizeof(token))) {
- const char* message[] = { "Failed to calculate", "OTP!" };
- await_error_activity(message, 2);
+ await_error_2("Failed to calculate", "OTP!");
return false;
}
@@ -1654,8 +1628,7 @@ static void handle_view_otps(void)
JADE_ASSERT(done);
if (num_otp_records == 0) {
- const char* message[] = { "No OTP records", "registered" };
- await_message_activity(message, 2);
+ await_message_2("No OTP records", "registered");
return;
}
@@ -1937,8 +1910,7 @@ static void handle_pinserver_scan(void)
{
if (keychain_has_pin()) {
// Not allowed if wallet initialised
- const char* message[] = { "Set Oracle not", "permitted once", "wallet initialized" };
- await_error_activity(message, 3);
+ await_error_3("Set Oracle not", "permitted once", "wallet initialized");
return;
}
@@ -1953,8 +1925,7 @@ static void handle_pinserver_scan(void)
}
if (!type || strcasecmp(type, BCUR_TYPE_JADE_UPDPS) || !data || !data_len) {
- const char* message[] = { "Failed to parse Oracle data" };
- await_error_activity(message, 1);
+ await_error("Failed to parse Oracle data");
goto cleanup;
}
@@ -1963,8 +1934,7 @@ static void handle_pinserver_scan(void)
goto cleanup;
}
- const char* message[] = { "Oracle details updated" };
- await_message_activity(message, 1);
+ await_message("Oracle details updated");
cleanup:
free(type);
@@ -1976,16 +1946,14 @@ static void handle_pinserver_reset(void)
{
if (keychain_has_pin()) {
// Not allowed if wallet initialised
- const char* message[] = { "Reset Oracle not", "permitted once", "wallet initialized" };
- await_error_activity(message, 3);
+ await_error_3("Reset Oracle not", "permitted once", "wallet initialized");
return;
}
const char* question[] = { "Reset Oracle details", "and certificate?" };
if (await_yesno_activity("Reset Oracle", question, 2, false, NULL)) {
if (!reset_pinserver()) {
- const char* message[] = { "Error resetting Oracle" };
- await_error_activity(message, 1);
+ await_error("Error resetting Oracle");
}
}
}
@@ -1995,8 +1963,7 @@ static void handle_storage(void)
{
size_t entries_used, entries_free;
if (!storage_get_stats(&entries_used, &entries_free)) {
- const char* message[] = { "Error accessing storage!" };
- await_error_activity(message, 1);
+ await_error("Error accessing storage!");
return;
}
@@ -2377,8 +2344,7 @@ static void handle_settings(const bool startup_menu)
tolerate_usb_disconnection = true;
done = usbstorage_firmware_ota(NULL);
} else {
- const char* message[] = { "Unlock with PIN before", "initiating firmware update" };
- await_error_activity(message, 2);
+ await_error_2("Unlock with PIN before", "initiating firmware update");
}
break;
diff --git a/main/process/debug_clean.c b/main/process/debug_clean.c
index feb565b..6aee99c 100644
--- a/main/process/debug_clean.c
+++ b/main/process/debug_clean.c
@@ -20,8 +20,7 @@ void debug_clean_reset_process(void* process_ptr)
ASSERT_CURRENT_MESSAGE(process, "debug_clean_reset");
// Pop up a notification that the wallet is being wiped
- const char* message[] = { "Warning: debug wipe" };
- await_message_activity(message, 1);
+ await_message("Warning: debug wipe");
vTaskDelay(250 / portTICK_PERIOD_MS);
// Clean keychain from memory and storage
diff --git a/main/process/debug_set_mnemonic.c b/main/process/debug_set_mnemonic.c
index a2c3478..e272a8c 100644
--- a/main/process/debug_set_mnemonic.c
+++ b/main/process/debug_set_mnemonic.c
@@ -103,8 +103,7 @@ void debug_set_mnemonic_process(void* process_ptr)
// Pop up a notification that the wallet has been injected
// (In a 'real' scenario the wallet is not set without some gui activity)
- const char* message[] = { "Warning: debug wallet" };
- await_message_activity(message, 1);
+ await_message("Warning: debug wallet");
vTaskDelay(250 / portTICK_PERIOD_MS);
// Copy temporary keychain into a new global keychain
diff --git a/main/process/get_bip85_entropy.c b/main/process/get_bip85_entropy.c
index 2f1d7e3..43536f6 100644
--- a/main/process/get_bip85_entropy.c
+++ b/main/process/get_bip85_entropy.c
@@ -371,8 +371,7 @@ void show_bip85_bip39_entropy_process(void* process_ptr)
if (errcode) {
if (errcode != CBOR_RPC_USER_CANCELLED) {
JADE_LOGE("Error generating encrypted bip85 entropy: %s", errmsg);
- const char* message[] = { "Error in bip85/bip39", errmsg };
- await_error_activity(message, 2);
+ await_error_2("Error in bip85/bip39", errmsg);
}
// An error occurred, or the user cancelled the action
jade_process_reject_message(process, errcode, errmsg);
diff --git a/main/process/get_identity_pubkey.c b/main/process/get_identity_pubkey.c
index e5f2d27..7ed71c0 100644
--- a/main/process/get_identity_pubkey.c
+++ b/main/process/get_identity_pubkey.c
@@ -45,8 +45,7 @@ void get_identity_pubkey_process(void* process_ptr)
JADE_LOGE("No wallet seed available. Wallet must be re-initialised from mnemonic.");
jade_process_reject_message(process, CBOR_RPC_INTERNAL_ERROR, "Feature requires resetting Jade");
- const char* message[] = { "Feature requires Jade reset" };
- await_error_activity(message, 1);
+ await_error("Feature requires Jade reset");
goto cleanup;
}
diff --git a/main/process/get_identity_shared_key.c b/main/process/get_identity_shared_key.c
index 3d9be33..15ed9c5 100644
--- a/main/process/get_identity_shared_key.c
+++ b/main/process/get_identity_shared_key.c
@@ -44,8 +44,7 @@ void get_identity_shared_key_process(void* process_ptr)
JADE_LOGE("No wallet seed available. Wallet must be re-initialised from mnemonic.");
jade_process_reject_message(process, CBOR_RPC_INTERNAL_ERROR, "Feature requires resetting Jade");
- const char* message[] = { "Feature requires Jade reset" };
- await_error_activity(message, 1);
+ await_error("Feature requires Jade reset");
goto cleanup;
}
diff --git a/main/process/get_otp_code.c b/main/process/get_otp_code.c
index 3f1abce..9274414 100644
--- a/main/process/get_otp_code.c
+++ b/main/process/get_otp_code.c
@@ -41,8 +41,7 @@ void get_otp_code_process(void* process_ptr)
JADE_LOGE("No wallet seed available. Wallet must be re-initialised from mnemonic.");
jade_process_reject_message(process, CBOR_RPC_INTERNAL_ERROR, "Feature requires resetting Jade");
- const char* message[] = { "Feature requires Jade reset" };
- await_error_activity(message, 1);
+ await_error("Feature requires Jade reset");
goto cleanup;
}
diff --git a/main/process/get_receive_address.c b/main/process/get_receive_address.c
index 2edf469..974119c 100644
--- a/main/process/get_receive_address.c
+++ b/main/process/get_receive_address.c
@@ -260,8 +260,7 @@ void get_receive_address_process(void* process_ptr)
// Show warning if necessary
if (warning_msg[0] != '\0') {
- const char* message[] = { warning_msg };
- await_message_activity(message, 1);
+ await_message(warning_msg);
}
// Reply with the address
diff --git a/main/process/mnemonic.c b/main/process/mnemonic.c
index cf3cef7..fcb6edd 100644
--- a/main/process/mnemonic.c
+++ b/main/process/mnemonic.c
@@ -204,8 +204,7 @@ static bool mnemonic_export_qr(const char* mnemonic, bool* export_qr_verified)
jade_camera_scan_qr(&qr_data, "Scan QR to verify", QR_GUIDE_SHOW, "blkstrm.com/seedqr");
if (qr_data.len == entropy_len && !memcmp(qr_data.data, entropy, entropy_len)) {
// QR Code scanned, and it matched expected entropy
- const char* message[] = { "QR Code Verified" };
- await_message_activity(message, 1);
+ await_message("QR Code Verified");
*export_qr_verified = true;
break; // done
} else {
@@ -374,8 +373,7 @@ static bool display_confirm_mnemonic(const size_t nwords, char* mnemonic, const
// the wrong word has been selected
if (random_words[index] != selected) {
- const char* message[] = { "Incorrect. Check your", "recovery phrase and", "try again." };
- await_error_activity(message, 3);
+ await_error_3("Incorrect. Check your", "recovery phrase and", "try again.");
mnemonic_confirmed = false;
break;
}
@@ -898,8 +896,7 @@ static bool mnemonic_recover(const size_t nwords, const bool advanced_mode, char
if (words_entered != nwords || bip39_mnemonic_validate(NULL, mnemonic) != WALLY_OK) {
// Invalid mnemonic entered
JADE_LOGW("Invalid mnemonic entered");
- const char* message[] = { "Invalid recovery phrase" };
- await_error_activity(message, 1);
+ await_error("Invalid recovery phrase");
return false;
}
@@ -1135,8 +1132,7 @@ bool import_and_validate_mnemonic(qr_data_t* qr_data)
// Show the user that a valid qr was scanned, but the string data
// did not constitute (or expand to) a valid bip39 mnemonic string.
- const char* message[] = { "Invalid recovery phrase" };
- await_error_activity(message, 1);
+ await_error("Invalid recovery phrase");
qr_data->len = 0;
ret = false;
}
@@ -1401,8 +1397,7 @@ void initialise_with_mnemonic(const bool temporary_restore, const bool force_qr_
// c. qr-scanner includes a validation check before returning the scanned mnemonic
if (bip39_mnemonic_validate(NULL, mnemonic) != WALLY_OK) {
JADE_LOGE("Invalid mnemonic unexpected");
- const char* message[] = { "Invalid recovery phrase" };
- await_error_activity(message, 1);
+ await_error("Invalid recovery phrase");
goto cleanup;
}
@@ -1443,8 +1438,7 @@ void initialise_with_mnemonic(const bool temporary_restore, const bool force_qr_
if (!derive_keychain(temporary_restore, mnemonic)) {
// Error making wallet...
JADE_LOGE("Failed to derive keychain from valid mnemonic");
- const char* message[] = { "Failed to create wallet" };
- await_error_activity(message, 1);
+ await_error("Failed to create wallet");
goto cleanup;
}
@@ -1552,8 +1546,7 @@ void handle_bip85_mnemonic()
// Display and confirm mnemonic phrase
if (display_confirm_mnemonic(nwords, new_mnemonic, mnemonic_len)) {
- const char* message[] = { "Recovery Phrase", "Confirmed" };
- await_message_activity(message, 2);
+ await_message_2("Recovery Phrase", "Confirmed");
}
// Cleanup
diff --git a/main/process/ota_util.c b/main/process/ota_util.c
index 98b3c18..7dc91f4 100644
--- a/main/process/ota_util.c
+++ b/main/process/ota_util.c
@@ -393,7 +393,7 @@ error:
// If the error is not 'did not start' or 'user declined', show an error screen
if (joctx->ota_return_status != OTA_ERR_SETUP && joctx->ota_return_status != OTA_ERR_USERDECLINED) {
- await_error_activity(&status_text, 1);
+ await_error(status_text);
}
}
diff --git a/main/process/pinclient.c b/main/process/pinclient.c
index ed49c92..49645b0 100644
--- a/main/process/pinclient.c
+++ b/main/process/pinclient.c
@@ -550,8 +550,7 @@ static bool get_pinserver_aeskey(jade_process_t* process, const uint8_t* pin, co
JADE_LOGE("Failed to complete pinserver interaction");
jade_process_reject_message(process, pir.errorcode, pir.message);
- const char* message[] = { "Network or server", "error" };
- await_error_activity(message, 2);
+ await_error_2("Network or server", "error");
return false;
}
diff --git a/main/process/register_descriptor.c b/main/process/register_descriptor.c
index de67dba..386d577 100644
--- a/main/process/register_descriptor.c
+++ b/main/process/register_descriptor.c
@@ -137,8 +137,7 @@ static int register_descriptor(
if (!storage_set_descriptor_registration(descriptor_name, registration, registration_len)) {
*errmsg = "Failed to persist descriptor data";
- const char* message[] = { "Error saving descriptor" };
- await_error_activity(message, 1);
+ await_error("Error saving descriptor");
retval = CBOR_RPC_INTERNAL_ERROR;
goto cleanup;
}
diff --git a/main/process/register_multisig.c b/main/process/register_multisig.c
index eb78877..eff0d77 100644
--- a/main/process/register_multisig.c
+++ b/main/process/register_multisig.c
@@ -124,8 +124,7 @@ static int register_multisig(const char* multisig_name, const network_t network_
if (!storage_set_multisig_registration(multisig_name, registration, registration_len)) {
*errmsg = "Failed to persist multisig data";
- const char* message[] = { "Error saving multisig" };
- await_error_activity(message, 1);
+ await_error("Error saving multisig");
retval = CBOR_RPC_INTERNAL_ERROR;
goto cleanup;
diff --git a/main/process/register_otp.c b/main/process/register_otp.c
index 6e0fca5..c3ee0c6 100644
--- a/main/process/register_otp.c
+++ b/main/process/register_otp.c
@@ -127,8 +127,7 @@ void register_otp_process(void* process_ptr)
if (keychain_get()->seed_len == 0) {
JADE_LOGE("No wallet seed available. Wallet must be re-initialised from mnemonic.");
jade_process_reject_message(process, CBOR_RPC_INTERNAL_ERROR, "Feature requires resetting Jade");
- const char* message[] = { "Feature requires Jade reset" };
- await_error_activity(message, 1);
+ await_error("Feature requires Jade reset");
}
// Validate and persist the new otp uri
@@ -138,8 +137,7 @@ void register_otp_process(void* process_ptr)
// Display any internal error that may occur after the user has viewed
// and confirmed the OTP record (earlier errors are just messaged)
if (errcode == CBOR_RPC_INTERNAL_ERROR) {
- const char* message[] = { errmsg };
- await_error_activity(message, 1);
+ await_error(errmsg);
}
jade_process_reject_message(process, errcode, errmsg);
goto cleanup;
@@ -197,8 +195,7 @@ static bool get_otp_data_from_kb(
}
} else if (!validate_otp_name(kb_entry.strdata, &errmsg)) {
// Invalid otp name
- const char* message[] = { errmsg };
- await_error_activity(message, 1);
+ await_error(errmsg);
} else {
const char* question[] = { kb_entry.strdata };
done = await_yesno_activity("Confirm OTP Name", question, 1, true, "blkstrm.com/otp");
@@ -271,8 +268,7 @@ bool register_otp_kb_entry(void)
// Check keychain has seed data
if (keychain_get()->seed_len == 0) {
JADE_LOGE("No wallet seed available. Wallet must be re-initialised from mnemonic.");
- const char* message[] = { "Feature requires Jade reset" };
- await_error_activity(message, 1);
+ await_error("Feature requires Jade reset");
}
bool ret = false;
@@ -294,8 +290,7 @@ bool register_otp_kb_entry(void)
const int errcode = handle_new_otp_uri(otp_name, otp_uri, uri_written, &errmsg);
if (errcode && errcode != CBOR_RPC_USER_CANCELLED) {
// Display any error (ignoring explicit user cancel)
- const char* message[] = { errmsg };
- await_error_activity(message, 1);
+ await_error(errmsg);
goto cleanup;
}
@@ -361,8 +356,7 @@ int register_otp_string(const char* otp_uri, const size_t uri_len, const char**
if (keychain_get()->seed_len == 0) {
JADE_LOGE("No wallet seed available. Wallet must be re-initialised from mnemonic.");
*errmsg = "No wallet seed available";
- const char* message[] = { "Feature requires Jade wallet" };
- await_error_activity(message, 1);
+ await_error("Feature requires Jade wallet");
return CBOR_RPC_INTERNAL_ERROR;
}
@@ -429,8 +423,7 @@ bool register_otp_qr(void)
// Check keychain has seed data
if (keychain_get()->seed_len == 0) {
JADE_LOGE("No wallet seed available. Wallet must be re-initialised from mnemonic.");
- const char* message[] = { "Feature requires Jade reset" };
- await_error_activity(message, 1);
+ await_error("Feature requires Jade reset");
return false;
}
@@ -455,8 +448,7 @@ bool register_otp_qr(void)
if (errcode && errcode != CBOR_RPC_USER_CANCELLED) {
JADE_LOGE("Processing OTP URI failed: %s", errmsg);
// Display any error (ignoring explicit user cancel)
- const char* message[] = { errmsg };
- await_error_activity(message, 1);
+ await_error(errmsg);
goto cleanup;
}
}
@@ -470,8 +462,7 @@ bool register_otp_qr(void)
if (errcode && errcode != CBOR_RPC_USER_CANCELLED) {
JADE_LOGE("Processing OTP MIGRATE URI failed: %s", errmsg);
// Display any error (ignoring explicit user cancel)
- const char* message[] = { errmsg };
- await_error_activity(message, 1);
+ await_error(errmsg);
goto cleanup;
}
}
diff --git a/main/process/sign_identity.c b/main/process/sign_identity.c
index a5584aa..a9a3fa8 100644
--- a/main/process/sign_identity.c
+++ b/main/process/sign_identity.c
@@ -72,8 +72,7 @@ void sign_identity_process(void* process_ptr)
JADE_LOGE("No wallet seed available. Wallet must be re-initialised from mnemonic.");
jade_process_reject_message(process, CBOR_RPC_INTERNAL_ERROR, "Feature requires resetting Jade");
- const char* message[] = { "Feature requires Jade reset" };
- await_error_activity(message, 1);
+ await_error("Feature requires Jade reset");
goto cleanup;
}
diff --git a/main/process/sign_psbt.c b/main/process/sign_psbt.c
index 66b1697..f81b160 100644
--- a/main/process/sign_psbt.c
+++ b/main/process/sign_psbt.c
@@ -1038,8 +1038,7 @@ int sign_psbt(jade_process_t* process, CborValue* params, const network_t networ
// Show warning if nothing to sign
if (!signing_flags) {
- const char* message[] = { "There are no relevant", "inputs to be signed" };
- await_message_activity(message, 2);
+ await_message_2("There are no relevant", "inputs to be signed");
}
display_processing_message_activity();
diff --git a/main/process/sign_tx.c b/main/process/sign_tx.c
index 2e227ff..591c97a 100644
--- a/main/process/sign_tx.c
+++ b/main/process/sign_tx.c
@@ -884,8 +884,7 @@ static void sign_tx_impl(jade_process_t* process, const bool for_liquid)
// Show warning if nothing to sign
if (num_to_sign == 0) {
- const char* message[] = { "There are no relevant", "inputs to be signed" };
- await_message_activity(message, 2);
+ await_message_2("There are no relevant", "inputs to be signed");
}
display_processing_message_activity();
diff --git a/main/process/update_pinserver.c b/main/process/update_pinserver.c
index b31fb87..afb334b 100644
--- a/main/process/update_pinserver.c
+++ b/main/process/update_pinserver.c
@@ -41,8 +41,7 @@ void show_pinserver_details(void)
// If no pinserver set, show the help screen
if (!have_pubkey && !have_urlA && !have_urlB && !have_cert) {
- const char* message[] = { "Custom Oracle not set" };
- await_message_activity(message, 1);
+ await_message("Custom Oracle not set");
return;
}
diff --git a/main/qrmode.c b/main/qrmode.c
index 971f217..91e4899 100644
--- a/main/qrmode.c
+++ b/main/qrmode.c
@@ -360,8 +360,7 @@ bool handle_xpub_options(uint32_t* qr_flags, bool for_descriptor)
// Show message and retry
const int ret = snprintf(buf, sizeof(buf), "%u", ACCOUNT_INDEX_MAX);
JADE_ASSERT(ret > 0 && ret < sizeof(buf));
- const char* message[] = { "Account index must", "be less than", buf };
- await_error_activity(message, 3);
+ await_error_3("Account index must", "be less than", buf);
}
}
} else if (ev_id == BTN_XPUB_OPTIONS_HELP) {
@@ -456,8 +455,7 @@ static bool load_registered_wallet(const size_t script_type, char* name_out, con
if (is_multisig) {
multisig_data_t* const allocated = JADE_MALLOC(sizeof(multisig_data_t));
if (!multisig_load_from_storage(wallet_name, allocated, NULL, 0, NULL, &errmsg)) {
- const char* message[] = { "Failed to load multisig record" };
- await_error_activity(message, 1);
+ await_error("Failed to load multisig record");
free(allocated);
return false;
}
@@ -465,8 +463,7 @@ static bool load_registered_wallet(const size_t script_type, char* name_out, con
} else {
descriptor_data_t* const allocated = JADE_MALLOC(sizeof(descriptor_data_t));
if (!descriptor_load_from_storage(wallet_name, allocated, &errmsg)) {
- const char* message[] = { "Failed to load descriptor record" };
- await_error_activity(message, 1);
+ await_error("Failed to load descriptor record");
free(allocated);
return false;
}
@@ -599,8 +596,7 @@ static bool handle_address_options(const bool show_account, uint16_t* account_in
break;
} else {
- const char* message[] = { "Invalid index", "Please try again" };
- await_message_activity(message, 2);
+ await_message_2("Invalid index", "Please try again");
}
}
} else if (ev_id == BTN_SCAN_ADDRESS_OPTIONS_CHANGE) {
@@ -632,16 +628,14 @@ static bool verify_address(const address_data_t* const addr_data)
// check network - eg. testnet address, but this jade is setup for mainnet only
if (!keychain_is_network_id_consistent(addr_data->network_id)) {
- const char* message[] = { "Network type inconsistent" };
- await_error_activity(message, 1);
+ await_error("Network type inconsistent");
return false;
}
// Get the script type
size_t script_type = 0;
if (wally_scriptpubkey_get_type(addr_data->script, addr_data->script_len, &script_type) != WALLY_OK) {
- const char* message[] = { "Failed to parse scriptpubkey" };
- await_error_activity(message, 1);
+ await_error("Failed to parse scriptpubkey");
return false;
}
@@ -665,8 +659,7 @@ static bool verify_address(const address_data_t* const addr_data)
if (!load_registered_wallet(script_type, label, sizeof(label), &multisig_data, &descriptor)) {
JADE_ASSERT(!multisig_data && !descriptor);
JADE_LOGE("No relevant wallet records found/selected for address");
- const char* message[] = { "Register wallet record", "before attempting to", "verify address" };
- await_error_activity(message, 3);
+ await_error_3("Register wallet record", "before attempting to", "verify address");
return false;
}
JADE_ASSERT(!multisig_data != !descriptor); // Must be one or the other
@@ -692,8 +685,7 @@ static bool verify_address(const address_data_t* const addr_data)
JADE_ASSERT(!search_roots_len);
if (!get_singlesig_variant_from_script_type(script_type, &variant) || variant == GREEN) {
- const char* message[] = { "Address scriptpubkey unsupported" };
- await_error_activity(message, 1);
+ await_error("Address scriptpubkey unsupported");
return false;
}
@@ -826,11 +818,9 @@ static bool verify_address(const address_data_t* const addr_data)
char pathstr[48];
const int ret = snprintf(pathstr, sizeof(pathstr), "%s/%u", label, index);
JADE_ASSERT(ret > 0 && ret < sizeof(pathstr));
- const char* message[] = { "Address verified:", pathstr };
- await_message_activity(message, 2);
+ await_message_2("Address verified:", pathstr);
} else {
- const char* message[] = { "Address NOT verified!" };
- await_error_activity(message, 1);
+ await_error("Address NOT verified!");
}
// Free any allocated data
@@ -1004,8 +994,7 @@ static bool handle_qr_bytes(const uint8_t* bytes, const size_t bytes_len)
if (errcode) {
if (errcode != CBOR_RPC_USER_CANCELLED) {
JADE_LOGE("Processing 'signmessage' QR failed: %d, %s", errcode, errmsg);
- const char* message[] = { errmsg };
- await_error_activity(message, 1);
+ await_error(errmsg);
}
return false;
}
@@ -1052,8 +1041,7 @@ static bool handle_qr_bytes(const uint8_t* bytes, const size_t bytes_len)
if (errcode) {
if (errcode != CBOR_RPC_USER_CANCELLED) {
JADE_LOGE("Processing multisig file failed: %s", errmsg);
- const char* message[] = { errmsg };
- await_error_activity(message, 1);
+ await_error(errmsg);
}
return false;
}
@@ -1069,8 +1057,7 @@ static bool handle_qr_bytes(const uint8_t* bytes, const size_t bytes_len)
if (import_mnemonic(bytes, bytes_len, mnemonic, sizeof(mnemonic), &written) && written < sizeof(mnemonic)) {
if (!handle_mnemonic_qr(mnemonic)) {
JADE_LOGE("Handling new scanned mnemonic failed");
- const char* message[] = { "Failed loading wallet" };
- await_error_activity(message, 1);
+ await_error("Failed loading wallet");
SENSITIVE_POP(mnemonic);
return false;
}
@@ -1081,8 +1068,7 @@ static bool handle_qr_bytes(const uint8_t* bytes, const size_t bytes_len)
}
JADE_LOGW("Unhandled QR (bytes) message");
- const char* message[] = { "Unhandled QR payload" };
- await_error_activity(message, 1);
+ await_error("Unhandled QR payload");
return false;
}
@@ -1095,8 +1081,7 @@ static bool handle_bcur_bytes(const uint8_t* cbor, const size_t cbor_len)
const uint8_t* bytes = NULL;
size_t bytes_len = 0;
if (!bcur_parse_bytes(cbor, cbor_len, &bytes, &bytes_len)) {
- const char* message[] = { "Invalid QR/BYTES format" };
- await_error_activity(message, 1);
+ await_error("Invalid QR/BYTES format");
return false;
}
return handle_qr_bytes(bytes, bytes_len);
@@ -1112,8 +1097,7 @@ static bool parse_sign_display_bcur_psbt_qr(const uint8_t* cbor, const size_t cb
struct wally_psbt* psbt = NULL;
if (!bcur_parse_psbt(cbor, cbor_len, &psbt)) {
// Unexpected type/format
- const char* message[] = { "Unsupported QR/PSBT format" };
- await_error_activity(message, 1);
+ await_error("Unsupported QR/PSBT format");
return false;
}
@@ -1126,8 +1110,7 @@ static bool parse_sign_display_bcur_psbt_qr(const uint8_t* cbor, const size_t cb
const int errcode = sign_psbt(NULL, NULL, network_id, psbt, &errmsg);
if (errcode) {
if (errcode != CBOR_RPC_USER_CANCELLED) {
- const char* message[] = { errmsg };
- await_error_activity(message, 1);
+ await_error(errmsg);
}
goto cleanup;
}
@@ -1167,8 +1150,7 @@ static bool handle_bip85_bip39_request_qr(const uint8_t* cbor, const size_t cbor
CborParser parser;
if (!bcur_parse_jade_message(cbor, cbor_len, &parser, &root, NULL, NULL)) {
JADE_LOGE("Failed to parse Jade bip85/bip39 entropy request");
- const char* message[] = { "Error parsing message" };
- await_error_activity(message, 1);
+ await_error("Error parsing message");
return false;
}
@@ -1183,8 +1165,7 @@ static bool handle_bip85_bip39_request_qr(const uint8_t* cbor, const size_t cbor
if (errcode) {
if (errcode != CBOR_RPC_USER_CANCELLED) {
JADE_LOGE("Error generating encrypted bip85 entropy: %s", errmsg);
- const char* message[] = { "Error generating entropy", errmsg };
- await_error_activity(message, 2);
+ await_error_2("Error generating entropy", errmsg);
}
// An error occurred, or the user cancelled the action
SENSITIVE_POP(reply_cbor);
@@ -1211,8 +1192,7 @@ static bool handle_epoch_qr(const uint8_t* cbor, const size_t cbor_len)
CborParser parser;
if (!bcur_parse_jade_message(cbor, cbor_len, &parser, &root, "set_epoch", ¶ms)) {
JADE_LOGE("Failed to parse Jade epoch message");
- const char* message[] = { "Error parsing epoch data" };
- await_error_activity(message, 1);
+ await_error("Error parsing epoch data");
return false;
}
@@ -1221,8 +1201,7 @@ static bool handle_epoch_qr(const uint8_t* cbor, const size_t cbor_len)
if (errcode) {
if (errcode != CBOR_RPC_USER_CANCELLED) {
JADE_LOGE("Error setting epoch time: %s", errmsg);
- const char* message[] = { "Error setting epoch time", errmsg };
- await_error_activity(message, 2);
+ await_error_2("Error setting epoch time", errmsg);
}
return false;
}
@@ -1230,8 +1209,7 @@ static bool handle_epoch_qr(const uint8_t* cbor, const size_t cbor_len)
char timestr[32];
const uint64_t epoch_value = time(NULL);
ctime_r((const time_t*)&epoch_value, timestr);
- const char* message[] = { "Time set successfully", timestr };
- await_message_activity(message, 2);
+ await_message_2("Time set successfully", timestr);
return true;
}
@@ -1248,8 +1226,7 @@ bool handle_update_pinserver_qr(const uint8_t* cbor, const size_t cbor_len)
CborParser parser;
if (!bcur_parse_jade_message(cbor, cbor_len, &parser, &root, "update_pinserver", ¶ms)) {
JADE_LOGE("Failed to parse Jade pinserver message");
- const char* message[] = { "Error parsing Oracle data" };
- await_error_activity(message, 1);
+ await_error("Error parsing Oracle data");
return false;
}
@@ -1258,8 +1235,7 @@ bool handle_update_pinserver_qr(const uint8_t* cbor, const size_t cbor_len)
if (errcode) {
if (errcode != CBOR_RPC_USER_CANCELLED) {
JADE_LOGE("Error updating pinserver details: %s", errmsg);
- const char* message[] = { "Error updating Oracle", errmsg };
- await_error_activity(message, 2);
+ await_error_2("Error updating Oracle", errmsg);
}
return false;
}
@@ -1275,8 +1251,7 @@ static bool handle_bip39_qr(const uint8_t* cbor, const size_t cbor_len)
if (!bcur_parse_bip39(cbor, cbor_len, mnemonic, sizeof(mnemonic), &written) || written >= sizeof(mnemonic)
|| !handle_mnemonic_qr(mnemonic)) {
JADE_LOGE("Processing scanned mnemonic data failed");
- const char* message[] = { "Failed loading wallet" };
- await_error_activity(message, 1);
+ await_error("Failed loading wallet");
ret = false;
}
SENSITIVE_POP(mnemonic);
@@ -1332,8 +1307,7 @@ void handle_scan_qr(void)
} else {
// Other - unhandled
JADE_LOGW("Unhandled BC-UR type: %s", type);
- const char* message[] = { "Unhandled UR message" };
- await_error_activity(message, 1);
+ await_error("Unhandled UR message");
}
} else {
// Non-BC-UR (single frame) undifferentiated bytes
@@ -1516,14 +1490,12 @@ bool show_otp_uri_qr_activity(const otpauth_ctx_t* otp_ctx)
SENSITIVE_PUSH(uri, sizeof(uri));
if (!otp_load_uri(otp_ctx->name, uri, sizeof(uri), &written) || !written) {
- const char* msg[] = { "Failed to load", "OTP URI" };
- await_error_activity(msg, 2);
+ await_error_2("Failed to load", "OTP URI");
goto cleanup;
}
if (written >= MAX_QR_V6_DATA_LEN) {
- const char* msg[] = { "URI too long", "for QR" };
- await_error_activity(msg, 2);
+ await_error_2("URI too long", "for QR");
goto cleanup;
}
@@ -1706,16 +1678,14 @@ static bool scan_qr_post_in_message(const char* label, const char* expected_type
// Check if a non-bc-ur code frame was scanned
if (!type) {
JADE_LOGW("Scanning encountered a non-BC-UR QR code, when expecting BC-UR type %s", expected_type);
- const char* message[] = { "Unexpected QR payload" };
- await_error_activity(message, 1);
+ await_error("Unexpected QR payload");
goto cleanup;
}
// Check the type is as expected
if (strcasecmp(expected_type, type)) {
JADE_LOGW("Scanning returned unexpected type %s when expecting %s", type, expected_type);
- const char* message[] = { "Unexpected QR payload type" };
- await_error_activity(message, 1);
+ await_error("Unexpected QR payload type");
goto cleanup;
}
diff --git a/main/qrscan.c b/main/qrscan.c
index 3abf5b2..e96202c 100644
--- a/main/qrscan.c
+++ b/main/qrscan.c
@@ -197,8 +197,7 @@ bool jade_camera_scan_qr(
return qr_data->len > 0;
#else // CONFIG_HAS_CAMERA
JADE_LOGW("No camera supported for this device");
- const char* message[] = { "No camera detected" };
- await_error_activity(message, 1);
+ await_error("No camera detected");
return false;
#endif
}
diff --git a/main/ui.h b/main/ui.h
index 349d31a..85770d1 100644
--- a/main/ui.h
+++ b/main/ui.h
@@ -147,8 +147,13 @@ gui_activity_t* display_message_activity(const char* message[], size_t message_s
gui_activity_t* display_processing_message_activity();
// Run activity that displays a message and awaits an 'ack' button click
-void await_message_activity(const char* message[], size_t message_size);
-void await_error_activity(const char* message[], size_t message_size);
+void await_message(const char* msg);
+void await_message_2(const char* msg1, const char* msg2);
+void await_message_3(const char* msg1, const char* msg2, const char* msg3);
+void await_message_4(const char* msg1, const char* msg2, const char* msg3, const char* msg4);
+void await_error(const char* msg);
+void await_error_2(const char* msg1, const char* msg2);
+void await_error_3(const char* msg1, const char* msg2, const char* msg3);
// Activity that displays a message and awaits a 'Yes'/'Continue' or 'No'/'Skip'/'Back' event
bool await_yesno_activity(
diff --git a/main/ui/dialogs.c b/main/ui/dialogs.c
index 1261374..17147e1 100644
--- a/main/ui/dialogs.c
+++ b/main/ui/dialogs.c
@@ -468,7 +468,7 @@ static bool await_yesno_activity_loop(gui_activity_t* const act, const char* hel
}
// Run activity that displays a message and awaits an 'ack' button click
-void await_message_activity(const char* message[], const size_t message_size)
+static void await_message_activity(const char* message[], const size_t message_size)
{
btn_data_t ftrbtn = { .txt = "Continue", .font = GUI_DEFAULT_FONT, .ev_id = BTN_YES, .borders = GUI_BORDER_TOP };
@@ -478,9 +478,41 @@ void await_message_activity(const char* message[], const size_t message_size)
JADE_ASSERT(rslt);
}
-void await_error_activity(const char* message[], const size_t message_size)
+void await_message(const char* msg)
{
- await_message_activity(message, message_size);
+ const char* m[] = { msg };
+ await_message_activity(m, 1);
+}
+void await_message_2(const char* msg1, const char* msg2)
+{
+ const char* m[] = { msg1, msg2 };
+ await_message_activity(m, 2);
+}
+void await_message_3(const char* msg1, const char* msg2, const char* msg3)
+{
+ const char* m[] = { msg1, msg2, msg3 };
+ await_message_activity(m, 3);
+}
+void await_message_4(const char* msg1, const char* msg2, const char* msg3, const char* msg4)
+{
+ const char* m[] = { msg1, msg2, msg3, msg4 };
+ await_message_activity(m, 4);
+}
+
+void await_error(const char* msg)
+{
+ const char* m[] = { msg };
+ await_message_activity(m, 1);
+}
+void await_error_2(const char* msg1, const char* msg2)
+{
+ const char* m[] = { msg1, msg2 };
+ await_message_activity(m, 2);
+}
+void await_error_3(const char* msg1, const char* msg2, const char* msg3)
+{
+ const char* m[] = { msg1, msg2, msg3 };
+ await_message_activity(m, 3);
}
// Generic activity that displays a message and Yes/No buttons, and waits
diff --git a/main/usbhmsc/usbmode.c b/main/usbhmsc/usbmode.c
index f8fd07d..de4b797 100644
--- a/main/usbhmsc/usbmode.c
+++ b/main/usbhmsc/usbmode.c
@@ -144,8 +144,7 @@ static bool select_file_from_filtered_list(const char* title, const char* const
DIR* const dir = opendir(path);
if (!dir) {
- const char* message[] = { "Error opening USB storage" };
- await_message_activity(message, 1);
+ await_message("Error opening USB storage");
return false;
}
@@ -193,8 +192,7 @@ static bool select_file_from_filtered_list(const char* title, const char* const
if (!num_files) {
// No candidate files
- const char* message[] = { "No matching files found" };
- await_message_activity(message, 1);
+ await_message("No matching files found");
return false;
}
@@ -290,8 +288,7 @@ static bool handle_usbstorage_action(const char* title, usbstorage_action_fn_t u
EventGroupHandle_t usbstorage_handle = usbstorage_start();
if (!usbstorage_handle) {
JADE_LOGE("Failed to start USB storage!");
- const char* message[] = { "Failed to start", "usb storage!" };
- await_error_activity(message, 2);
+ await_error_2("Failed to start", "usb storage!");
// Jade may require restart to use usb storage or serial at this point ...
return false;
}
@@ -312,8 +309,7 @@ static bool handle_usbstorage_action(const char* title, usbstorage_action_fn_t u
if (usbstorage_events & USBSTORAGE_ERROR) {
// Error accessing USB storage: Show error and exit
- const char* message[] = { "Error accessing usb", "storage. Note: only", "FAT32 is supported." };
- await_error_activity(message, 3);
+ await_error_3("Error accessing usb", "storage. Note: only", "FAT32 is supported.");
break;
} else if (usbstorage_events == USBSTORAGE_AVAILABLE) {
// USB storage is mounted: run the action
@@ -726,8 +722,7 @@ static bool initiate_usb_ota(const usbstorage_action_context_t* ctx)
JADE_ASSERT(ret > 0 && ret < sizeof(hash_filename));
if (!read_hash_file_to_buffer(hash_filename, hash, sizeof(hash))) {
- const char* message[] = { "Failed to read", "hash file" };
- await_error_activity(message, 2);
+ await_error_2("Failed to read", "hash file");
return false;
}
}
@@ -735,8 +730,7 @@ static bool initiate_usb_ota(const usbstorage_action_context_t* ctx)
const size_t cmpsize = get_file_size(filename);
const size_t fwsize = read_fwsize(filename);
if (!cmpsize || !fwsize) {
- const char* message[] = { "Failed to parse", "firmware filename" };
- await_error_activity(message, 2);
+ await_error_2("Failed to parse", "firmware filename");
return false;
}
@@ -777,13 +771,11 @@ static bool sign_usb_psbt(const usbstorage_action_context_t* ctx)
// Sanity check file size
size_t psbt_len = get_file_size(filename);
if (psbt_len < MIN_PSBT_FILE_SIZE) {
- const char* message[] = { "Invalid PSBT file" };
- await_error_activity(message, 1);
+ await_error("Invalid PSBT file");
return false;
}
if (psbt_len > MAX_PSBT_FILE_SIZE) {
- const char* message[] = { "PSBT file too large" };
- await_error_activity(message, 1);
+ await_error("PSBT file too large");
return false;
}
@@ -813,8 +805,7 @@ static bool sign_usb_psbt(const usbstorage_action_context_t* ctx)
free(psbt64);
if (wret != WALLY_OK || !written || written > psbt_len) {
- const char* message[] = { "Failed to load PSBT" };
- await_error_activity(message, 1);
+ await_error("Failed to load PSBT");
goto cleanup;
}
psbt_len = written;
@@ -822,8 +813,7 @@ static bool sign_usb_psbt(const usbstorage_action_context_t* ctx)
// Deserialise bytes
if (!deserialise_psbt(psbt_bytes, psbt_len, &psbt) || !psbt) {
- const char* message[] = { "Failed to load PSBT" };
- await_error_activity(message, 1);
+ await_error("Failed to load PSBT");
goto cleanup;
}
}
@@ -841,8 +831,7 @@ static bool sign_usb_psbt(const usbstorage_action_context_t* ctx)
const int errcode = sign_psbt(NULL, NULL, network_id, psbt, &errmsg);
if (errcode) {
if (errcode != CBOR_RPC_USER_CANCELLED) {
- const char* message[] = { errmsg };
- await_error_activity(message, 1);
+ await_error(errmsg);
}
goto cleanup;
}
@@ -851,8 +840,7 @@ static bool sign_usb_psbt(const usbstorage_action_context_t* ctx)
// Create a new file if name not too long. If new name would be too long, overwrite existing file.
char output_filename[MAX_FILENAME_SIZE];
if (filename_len - strlen(PSBT_SUFFIX) + strlen(SIGNED_PSBT_SUFFIX) + 1 > MAX_FILENAME_SIZE) {
- const char* message[] = { "Warning: Long filename", "Overwriting existing", "psbt file" };
- await_error_activity(message, 3);
+ await_error_3("Warning: Long filename", "Overwriting existing", "psbt file");
strcpy(output_filename, filename);
} else {
const int ret = snprintf(output_filename, sizeof(output_filename), "%.*s%s", filename_len - strlen(PSBT_SUFFIX),
@@ -864,8 +852,7 @@ static bool sign_usb_psbt(const usbstorage_action_context_t* ctx)
// Encode to base64
char* psbt64 = NULL;
if (wally_psbt_to_base64(psbt, 0, &psbt64) != WALLY_OK || !psbt64) {
- const char* message[] = { "Failed to", "serialise PSBT" };
- await_error_activity(message, 2);
+ await_error_2("Failed to", "serialise PSBT");
goto cleanup;
}
const size_t psbt64_len = strlen(psbt64);
@@ -875,8 +862,7 @@ static bool sign_usb_psbt(const usbstorage_action_context_t* ctx)
} else {
// Serialise signed PSBT to bytes
if (!serialise_psbt(psbt, &psbt_bytes, &psbt_len)) {
- const char* message[] = { "Failed to", "serialise PSBT" };
- await_error_activity(message, 2);
+ await_error_2("Failed to", "serialise PSBT");
goto cleanup;
}
const size_t written = write_buffer_to_file(output_filename, psbt_bytes, psbt_len);
@@ -886,8 +872,7 @@ static bool sign_usb_psbt(const usbstorage_action_context_t* ctx)
const size_t mount_point_len = strlen(USBSTORAGE_MOUNT_POINT);
JADE_ASSERT(strlen(output_filename) > mount_point_len);
JADE_ASSERT(!memcmp(output_filename, USBSTORAGE_MOUNT_POINT, mount_point_len));
- const char* message[] = { "PSBT file saved:", output_filename + mount_point_len + 1 };
- await_error_activity(message, 2);
+ await_error_2("PSBT file saved:", output_filename + mount_point_len + 1);
retval = true;
cleanup:
@@ -1018,8 +1003,7 @@ static bool export_usb_xpub_fn(const usbstorage_action_context_t* ctx)
{
char* xpub = NULL;
if (!wallet_get_xpub(network_id, path, path_len, &xpub) || !xpub) {
- const char* msg[] = { "unable to get", "xpub from path" };
- await_error_activity(msg, 2);
+ await_error_2("unable to get", "xpub from path");
return false;
}
const size_t xpub_len = strlen(xpub);
@@ -1051,13 +1035,11 @@ static bool export_usb_xpub_fn(const usbstorage_action_context_t* ctx)
= write_buffer_to_file(USBSTORAGE_MOUNT_POINT "/jade-xpub.txt", (const uint8_t*)descriptor, descriptor_len);
if (written != descriptor_len) {
- const char* msg[] = { "Failed to save", "xpub file" };
- await_error_activity(msg, 2);
+ await_error_2("Failed to save", "xpub file");
return false;
}
- const char* msg[] = { "xpub saved to", "jade-xpub.txt" };
- await_message_activity(msg, 2);
+ await_message_2("xpub saved to", "jade-xpub.txt");
return true;
}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.