What changed, and why it matters
This commit is a routine code cleanup: it removes two unused or trivial UI helper files (entry_screen and confirm_button) and inlines their simple behavior directly where needed. There is no security-relevant change, no bug fix, and no functional change to how the device handles sensitive actions like confirming transactions or entering passwords.
No security action required. Treat as normal refactoring/technical-debt cleanup.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit deletes src/ui/components/confirm_button.c/h and src/ui/components/entry_screen.c/h, removes them from CMake and Rust build.rs, and updates confirm_transaction.c and trinary_input_string.c to call confirm_gesture_create() or icon_button_create() directly instead of going through the confirm_button_create() wrapper. The inlined logic preserves the original behavior: longtouch still uses confirm_gesture_create(), non-longtouch still creates an icon button that emits/triggers the same confirmation callback. entry_screen was unused and is simply removed.
Changed components
src/ui/components/confirm_button.csrc/ui/components/confirm_button.hsrc/ui/components/entry_screen.csrc/ui/components/entry_screen.hsrc/ui/components/confirm_transaction.csrc/ui/components/trinary_input_string.csrc/CMakeLists.txtsrc/rust/bitbox02-sys/build.rsInspect captured patch +36 / −185
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b3bde96..c6344c5 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -74,7 +74,6 @@ set(DBB-FIRMWARE-UI-SOURCES
${CMAKE_SOURCE_DIR}/src/ui/components/trinary_input_string.c
${CMAKE_SOURCE_DIR}/src/ui/components/waiting.c
${CMAKE_SOURCE_DIR}/src/ui/components/screensaver.c
- ${CMAKE_SOURCE_DIR}/src/ui/components/entry_screen.c
${CMAKE_SOURCE_DIR}/src/ui/components/knight_rider.c
${CMAKE_SOURCE_DIR}/src/ui/components/right_arrow.c
${CMAKE_SOURCE_DIR}/src/ui/components/left_arrow.c
@@ -82,7 +81,6 @@ set(DBB-FIRMWARE-UI-SOURCES
${CMAKE_SOURCE_DIR}/src/ui/components/confirm_gesture.c
${CMAKE_SOURCE_DIR}/src/ui/components/label.c
${CMAKE_SOURCE_DIR}/src/ui/components/confirm.c
- ${CMAKE_SOURCE_DIR}/src/ui/components/confirm_button.c
${CMAKE_SOURCE_DIR}/src/ui/components/keyboard_switch.c
${CMAKE_SOURCE_DIR}/src/ui/components/orientation_arrows.c
${CMAKE_SOURCE_DIR}/src/ui/components/info_centered.c
diff --git a/src/rust/bitbox02-sys/build.rs b/src/rust/bitbox02-sys/build.rs
index a70d9e4..98af9f8 100644
--- a/src/rust/bitbox02-sys/build.rs
+++ b/src/rust/bitbox02-sys/build.rs
@@ -200,12 +200,10 @@ const BITBOX02_SOURCES: &[&str] = &[
"src/u2f/u2f_app.c",
"src/u2f/u2f_packet.c",
"src/ui/components/button.c",
- "src/ui/components/confirm_button.c",
"src/ui/components/confirm_gesture.c",
"src/ui/components/confirm_transaction.c",
"src/ui/components/confirm.c",
"src/ui/components/empty.c",
- "src/ui/components/entry_screen.c",
"src/ui/components/icon_button.c",
"src/ui/components/image.c",
"src/ui/components/info_centered.c",
diff --git a/src/ui/components/confirm_button.c b/src/ui/components/confirm_button.c
deleted file mode 100644
index 0d67d4a..0000000
--- a/src/ui/components/confirm_button.c
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2019 Shift Cryptosecurity AG
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "confirm_button.h"
-#include "../event.h"
-#include "../event_handler.h"
-#include "confirm_gesture.h"
-
-static void _confirm(component_t* confirm_button)
-{
- (void)confirm_button;
- event_t event;
- event.id = EVENT_CONFIRM;
- emit_event(&event);
-}
-
-component_t* confirm_button_create(bool longtouch, icon_button_type_t button_type)
-{
- if (longtouch) {
- return confirm_gesture_create();
- }
- return icon_button_create(top_slider, button_type, _confirm);
-}
diff --git a/src/ui/components/confirm_button.h b/src/ui/components/confirm_button.h
deleted file mode 100644
index 47fd29a..0000000
--- a/src/ui/components/confirm_button.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2019 Shift Cryptosecurity AG
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef _UI_CONFIRM_BUTTON_H_
-#define _UI_CONFIRM_BUTTON_H_
-
-#include "icon_button.h"
-#include <ui/component.h>
-
-#include <stdbool.h>
-
-/**
- * Creates a confirm button. Confirming emits the EVENT_CONFIRM event.
- * @param[in] longtouch if true, hold gesture is required, otherwise a simple tap.
- * @param[in] button_type if not longtouch, defines the icon to show.
- */
-component_t* confirm_button_create(bool longtouch, icon_button_type_t button_type);
-
-#endif
diff --git a/src/ui/components/confirm_transaction.c b/src/ui/components/confirm_transaction.c
index 357d186..ce73dda 100644
--- a/src/ui/components/confirm_transaction.c
+++ b/src/ui/components/confirm_transaction.c
@@ -13,7 +13,7 @@
// limitations under the License.
#include "confirm_transaction.h"
-#include "confirm_button.h"
+#include "confirm_gesture.h"
#include "icon_button.h"
#include "label.h"
#include "ui_images.h"
@@ -71,6 +71,16 @@ static void _cancel(component_t* cancel_button)
}
}
+static void _confirm_button_cb(component_t* confirm_button)
+{
+ component_t* component = confirm_button->parent;
+ data_t* data = (data_t*)component->data;
+ if (data->callback) {
+ data->callback(true, data->user_data);
+ data->callback = NULL;
+ }
+}
+
/********************************** Component Functions **********************************/
/**
@@ -120,7 +130,12 @@ static component_t* _confirm_transaction_create(
ui_util_add_sub_component(confirm, icon_button_create(top_slider, ICON_BUTTON_CROSS, _cancel));
- ui_util_add_sub_component(confirm, confirm_button_create(longtouch, ICON_BUTTON_NEXT));
+ if (longtouch) {
+ ui_util_add_sub_component(confirm, confirm_gesture_create());
+ } else {
+ ui_util_add_sub_component(
+ confirm, icon_button_create(top_slider, ICON_BUTTON_NEXT, _confirm_button_cb));
+ }
if (data->has_address) {
ui_util_add_sub_component(
diff --git a/src/ui/components/entry_screen.c b/src/ui/components/entry_screen.c
deleted file mode 100644
index ee182d2..0000000
--- a/src/ui/components/entry_screen.c
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright 2019 Shift Cryptosecurity AG
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "entry_screen.h"
-#include "knight_rider.h"
-#include "label.h"
-
-#include <stdbool.h>
-#include <stdint.h>
-#include <string.h>
-
-#include <hardfault.h>
-#include <ui/ui_util.h>
-
-typedef struct {
- uint16_t screen_count;
- void (*done_callback)(void);
-} entry_screen_data_t;
-
-static void _on_event(const event_t* event, component_t* component)
-{
- entry_screen_data_t* data = (entry_screen_data_t*)component->data;
- switch (event->id) {
- case EVENT_BOTTOM_CONTINUOUS_TAP:
- case EVENT_BOTTOM_SLIDE:
- data->done_callback();
- break;
- default:
- break;
- }
-}
-
-static component_functions_t _component_functions = {
- .cleanup = ui_util_component_cleanup,
- .render = ui_util_component_render_subcomponents,
- .on_event = _on_event,
-};
-
-/********************************** Create Instance **********************************/
-
-/**
- * Creates an entry screen.
- * @param[in] done_callback The callback that is called when the user touches to enter.
- */
-component_t* entry_screen_create(const char* text, void (*done_callback)(void))
-{
- component_t* entry_screen = malloc(sizeof(component_t));
- if (!entry_screen) {
- Abort("Error: malloc entry_screen");
- }
- entry_screen_data_t* data = malloc(sizeof(entry_screen_data_t));
- if (!data) {
- Abort("Error: malloc entry_screen data");
- }
- memset(entry_screen, 0, sizeof(component_t));
- memset(data, 0, sizeof(entry_screen_data_t));
-
- data->screen_count = 0;
- data->done_callback = done_callback;
-
- entry_screen->data = data;
- entry_screen->parent = NULL;
- entry_screen->f = &_component_functions;
- entry_screen->dimension.width = SCREEN_WIDTH;
- entry_screen->dimension.height = SCREEN_HEIGHT;
- entry_screen->position.top = 0;
- entry_screen->position.left = 0;
-
- ui_util_add_sub_component(entry_screen, knight_rider_create(entry_screen, SCREEN_HEIGHT - 1));
- ui_util_add_sub_component(entry_screen, label_create(text, NULL, CENTER, entry_screen));
-
- return entry_screen;
-}
diff --git a/src/ui/components/entry_screen.h b/src/ui/components/entry_screen.h
deleted file mode 100644
index f78e292..0000000
--- a/src/ui/components/entry_screen.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2019 Shift Cryptosecurity AG
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef _ENTRY_SCREEN_H_
-#define _ENTRY_SCREEN_H_
-
-#include <screen.h>
-#include <ui/component.h>
-
-/********************************** Create Instance **********************************/
-
-/**
- * Creates an entry screen.
- * @param[in] done_callback The callback that is called when the user touches to enter.
- */
-component_t* entry_screen_create(const char* text, void (*done_callback)(void));
-
-#endif
diff --git a/src/ui/components/trinary_input_string.c b/src/ui/components/trinary_input_string.c
index de3a915..0ceb177 100644
--- a/src/ui/components/trinary_input_string.c
+++ b/src/ui/components/trinary_input_string.c
@@ -13,8 +13,8 @@
// limitations under the License.
#include "trinary_input_string.h"
-#include "confirm_button.h"
#include "confirm_gesture.h"
+#include "icon_button.h"
#include "keyboard_switch.h"
#include "label.h"
#include "left_arrow.h"
@@ -389,6 +389,18 @@ static void _on_event(const event_t* event, component_t* component)
}
}
+static void _confirm_button_cb(component_t* confirm_button)
+{
+ component_t* component = confirm_button->parent;
+ data_t* data = (data_t*)component->data;
+ if (data->can_confirm) {
+ if (data->confirm_cb) {
+ data->confirm_cb(data->string, data->confirm_user_data);
+ data->confirm_cb = NULL;
+ }
+ }
+}
+
static void _cancel(component_t* cancel_button)
{
component_t* component = cancel_button->parent;
@@ -484,7 +496,12 @@ component_t* trinary_input_string_create(
data->left_arrow_component = left_arrow_create(top_slider, component);
ui_util_add_sub_component(component, data->left_arrow_component);
- data->confirm_component = confirm_button_create(params->longtouch, ICON_BUTTON_CHECK);
+ if (params->longtouch) {
+ data->confirm_component = confirm_gesture_create();
+ } else {
+ data->confirm_component =
+ icon_button_create(top_slider, ICON_BUTTON_CHECK, _confirm_button_cb);
+ }
ui_util_add_sub_component(component, data->confirm_component);
if (params->wordlist == NULL && !params->number_input) {
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.