gui: share code to create qrcode nodes
What changed, and why it matters
This commit is a simple code cleanup in the user-interface code for Blockstream Jade, a hardware wallet. It extracts repeated code that builds QR-code display elements into a single shared helper function. There is no change to behavior, no bug fix, and no security relevance visible in the diff.
No security action needed. Treat as a normal refactoring review.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change refactors four call sites in main/ui/qrmode.c that each created a pale fill node, an icon node, aligned it, set its parent, and configured icon animation. The identical sequence is moved into a new static helper make_qrcode(). Parameters (parent, icons, num_icons, frames_per_qr_icon) are passed through unchanged. The third and fourth call sites previously reused a local variable name fill and shadowed it; the helper avoids that shadowing but does not alter the resulting widget tree or animation ownership comments.
Changed components
main/ui/qrmode.cInspect captured patch +19 / −33
diff --git a/main/ui/qrmode.c b/main/ui/qrmode.c
index 04add7b..7d7c46f 100644
--- a/main/ui/qrmode.c
+++ b/main/ui/qrmode.c
@@ -3,6 +3,20 @@
#include "../jade_assert.h"
#include "../ui.h"
+static void make_qrcode(gui_view_node_t* parent, Icon* icons, const size_t num_icons, const size_t frames_per_qr_icon)
+{
+ // qrcodes are a background fill node with the icon node on top
+ gui_view_node_t* fill;
+ gui_make_fill(&fill, GUI_BLOCKSTREAM_QR_PALE);
+ gui_set_parent(fill, parent);
+
+ gui_view_node_t* icon;
+ gui_make_icon(&icon, icons, TFT_BLACK, &GUI_BLOCKSTREAM_QR_PALE);
+ gui_set_align(icon, GUI_ALIGN_CENTER, GUI_ALIGN_MIDDLE);
+ gui_set_parent(icon, fill);
+ gui_set_icon_animation(icon, icons, num_icons, frames_per_qr_icon);
+}
+
gui_activity_t* make_show_xpub_qr_activity(
const char* label, const char* pathstr, Icon* icons, const size_t num_icons, const size_t frames_per_qr_icon)
{
@@ -46,14 +60,7 @@ gui_activity_t* make_show_xpub_qr_activity(
add_buttons(vsplit, UI_COLUMN, &ftrbtn, 1);
// RHS - QR icons
- gui_view_node_t* fill;
- gui_make_fill(&fill, GUI_BLOCKSTREAM_QR_PALE);
- gui_set_parent(fill, hsplit);
-
- gui_make_icon(&node, icons, TFT_BLACK, &GUI_BLOCKSTREAM_QR_PALE);
- gui_set_align(node, GUI_ALIGN_CENTER, GUI_ALIGN_MIDDLE);
- gui_set_parent(node, fill);
- gui_set_icon_animation(node, icons, num_icons, frames_per_qr_icon);
+ make_qrcode(hsplit, icons, num_icons, frames_per_qr_icon);
return act;
}
@@ -263,16 +270,7 @@ gui_activity_t* make_show_qr_activity(const char* message[], const size_t messag
}
// RHS - QR icons
- {
- gui_view_node_t* fill;
- gui_make_fill(&fill, GUI_BLOCKSTREAM_QR_PALE);
- gui_set_parent(fill, hsplit);
-
- gui_make_icon(&node, icons, TFT_BLACK, &GUI_BLOCKSTREAM_QR_PALE);
- gui_set_align(node, GUI_ALIGN_CENTER, GUI_ALIGN_MIDDLE);
- gui_set_parent(node, fill);
- gui_set_icon_animation(node, icons, num_icons, frames_per_qr_icon);
- }
+ make_qrcode(hsplit, icons, num_icons, frames_per_qr_icon);
return act;
}
@@ -339,14 +337,8 @@ gui_activity_t* make_show_qr_help_activity(const char* url, Icon* qr_icon)
gui_make_fill(&fill, TFT_BLACK);
gui_set_parent(fill, vsplit);
- // QR icon background
- gui_make_fill(&fill, GUI_BLOCKSTREAM_QR_PALE);
- gui_set_parent(fill, vsplit);
-
- gui_make_icon(&node, qr_icon, TFT_BLACK, &GUI_BLOCKSTREAM_QR_PALE);
- gui_set_align(node, GUI_ALIGN_CENTER, GUI_ALIGN_MIDDLE);
- gui_set_parent(node, fill);
- gui_set_icon_animation(node, qr_icon, 1, 0); // takes ownership of icon
+ // QR icon
+ make_qrcode(vsplit, qr_icon, 1, 0); // takes ownership of icon
gui_make_fill(&fill, TFT_BLACK);
gui_set_parent(fill, vsplit);
@@ -422,13 +414,7 @@ gui_activity_t* make_qr_back_continue_activity(
gui_set_parent(fill, vsplit);
// QR icon background
- gui_make_fill(&fill, GUI_BLOCKSTREAM_QR_PALE);
- gui_set_parent(fill, vsplit);
-
- gui_make_icon(&node, qr_icon, TFT_BLACK, &GUI_BLOCKSTREAM_QR_PALE);
- gui_set_align(node, GUI_ALIGN_CENTER, GUI_ALIGN_MIDDLE);
- gui_set_parent(node, fill);
- gui_set_icon_animation(node, qr_icon, 1, 0); // takes ownership of icon
+ make_qrcode(vsplit, qr_icon, 1, 0); // takes ownership of icon
gui_make_fill(&fill, TFT_BLACK);
gui_set_parent(fill, vsplit);
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.