bitbox02_rust/ui: inline trinary_choice
What changed, and why it matters
This commit is a straightforward internal code cleanup: it removes a thin Rust wrapper around a three-option user-interface prompt and calls the underlying function directly. There is no visible change in behavior, no bug fix, and no security-relevant change.
No security action needed; review as normal code-quality refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch inlines workflow::trinary_choice::choose into the HAL UI implementations by calling bitbox02::ui::trinary_choice directly and using bitbox02::ui::TrinaryChoice as the return type. The workflow::trinary_choice module is deleted. Call sites in bip85.rs and mnemonic.rs are updated to import TrinaryChoice from bitbox02::ui. The diff is purely refactor-only (+9/-27) with no logic changes.
Changed components
src/rust/bitbox02-rust/src/hal/bitbox02/ui.rssrc/rust/bitbox02-rust/src/hal/testing/ui.rssrc/rust/bitbox02-rust/src/hal/ui.rssrc/rust/bitbox02-rust/src/hww/api/bip85.rssrc/rust/bitbox02-rust/src/workflow.rssrc/rust/bitbox02-rust/src/workflow/mnemonic.rssrc/rust/bitbox02-rust/src/workflow/trinary_choice.rsInspect captured patch +9 / −27
diff --git a/src/rust/bitbox02-rust/src/hal/bitbox02/ui.rs b/src/rust/bitbox02-rust/src/hal/bitbox02/ui.rs
index 02213d8..aebf319 100644
--- a/src/rust/bitbox02-rust/src/hal/bitbox02/ui.rs
+++ b/src/rust/bitbox02-rust/src/hal/bitbox02/ui.rs
@@ -3,9 +3,7 @@
use alloc::string::String;
use crate::hal::Ui;
-use crate::workflow::{
- cancel, confirm, mnemonic, sdcard, transaction, trinary_choice, trinary_input_string,
-};
+use crate::workflow::{cancel, confirm, mnemonic, sdcard, transaction, trinary_input_string};
pub(crate) struct BitBox02Ui;
@@ -96,8 +94,8 @@ impl Ui for BitBox02Ui {
label_left: Option<&str>,
label_middle: Option<&str>,
label_right: Option<&str>,
- ) -> trinary_choice::TrinaryChoice {
- trinary_choice::choose(message, label_left, label_middle, label_right).await
+ ) -> bitbox02::ui::TrinaryChoice {
+ bitbox02::ui::trinary_choice(message, label_left, label_middle, label_right).await
}
async fn show_mnemonic(&mut self, words: &[&str]) -> Result<(), cancel::Error> {
diff --git a/src/rust/bitbox02-rust/src/hal/testing/ui.rs b/src/rust/bitbox02-rust/src/hal/testing/ui.rs
index dbd0958..4525d8d 100644
--- a/src/rust/bitbox02-rust/src/hal/testing/ui.rs
+++ b/src/rust/bitbox02-rust/src/hal/testing/ui.rs
@@ -1,9 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
use crate::hal::Ui;
-use crate::workflow::{
- cancel, confirm, sdcard, transaction, trinary_choice, trinary_input_string,
-};
+use crate::workflow::{cancel, confirm, sdcard, transaction, trinary_input_string};
use alloc::boxed::Box;
use alloc::string::String;
@@ -146,7 +144,7 @@ impl Ui for TestingUi<'_> {
_label_left: Option<&str>,
_label_middle: Option<&str>,
_label_right: Option<&str>,
- ) -> trinary_choice::TrinaryChoice {
+ ) -> bitbox02::ui::TrinaryChoice {
todo!("not used in unit tests yet");
}
diff --git a/src/rust/bitbox02-rust/src/hal/ui.rs b/src/rust/bitbox02-rust/src/hal/ui.rs
index 12a9f97..e488fe1 100644
--- a/src/rust/bitbox02-rust/src/hal/ui.rs
+++ b/src/rust/bitbox02-rust/src/hal/ui.rs
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
-use crate::workflow::{cancel, confirm, mnemonic, sdcard, transaction, trinary_choice, trinary_input_string};
+use crate::workflow::{cancel, confirm, mnemonic, sdcard, transaction, trinary_input_string};
use alloc::string::String;
@@ -45,7 +45,7 @@ pub trait Ui {
label_left: Option<&str>,
label_middle: Option<&str>,
label_right: Option<&str>,
- ) -> trinary_choice::TrinaryChoice;
+ ) -> bitbox02::ui::TrinaryChoice;
/// Display the BIP39 mnemonic to the user.
async fn show_mnemonic(&mut self, words: &[&str]) -> Result<(), cancel::Error>;
diff --git a/src/rust/bitbox02-rust/src/hww/api/bip85.rs b/src/rust/bitbox02-rust/src/hww/api/bip85.rs
index 0286bb7..4bd3fbf 100644
--- a/src/rust/bitbox02-rust/src/hww/api/bip85.rs
+++ b/src/rust/bitbox02-rust/src/hww/api/bip85.rs
@@ -31,8 +31,8 @@ pub async fn process(
/// Derives and displays a BIP-39 seed according to BIP-85:
/// https://github.com/bitcoin/bips/blob/master/bip-0085.mediawiki#bip39.
async fn process_bip39(hal: &mut impl crate::hal::Hal) -> Result<(), Error> {
- use crate::workflow::trinary_choice::TrinaryChoice;
use crate::workflow::trinary_input_string;
+ use bitbox02::ui::TrinaryChoice;
hal.ui()
.confirm(&confirm::Params {
diff --git a/src/rust/bitbox02-rust/src/workflow.rs b/src/rust/bitbox02-rust/src/workflow.rs
index 08edc24..78e5551 100644
--- a/src/rust/bitbox02-rust/src/workflow.rs
+++ b/src/rust/bitbox02-rust/src/workflow.rs
@@ -12,7 +12,6 @@ pub mod pairing;
pub mod password;
pub mod sdcard;
pub mod transaction;
-pub mod trinary_choice;
pub mod trinary_input_string;
pub mod unlock;
pub mod unlock_animation;
diff --git a/src/rust/bitbox02-rust/src/workflow/mnemonic.rs b/src/rust/bitbox02-rust/src/workflow/mnemonic.rs
index f5bfe5f..a36a5a2 100644
--- a/src/rust/bitbox02-rust/src/workflow/mnemonic.rs
+++ b/src/rust/bitbox02-rust/src/workflow/mnemonic.rs
@@ -2,12 +2,12 @@
pub use super::cancel::Error as CancelError;
use super::confirm;
-use super::trinary_choice::TrinaryChoice;
use super::trinary_input_string;
use alloc::string::String;
use alloc::vec::Vec;
+use bitbox02::ui::TrinaryChoice;
use sha2::{Digest, Sha256};
const NUM_RANDOM_WORDS: u8 = 5;
diff --git a/src/rust/bitbox02-rust/src/workflow/trinary_choice.rs b/src/rust/bitbox02-rust/src/workflow/trinary_choice.rs
deleted file mode 100644
index dda1d7d..0000000
--- a/src/rust/bitbox02-rust/src/workflow/trinary_choice.rs
+++ /dev/null
@@ -1,13 +0,0 @@
-// SPDX-License-Identifier: Apache-2.0
-
-pub use bitbox02::ui::TrinaryChoice;
-use bitbox02::ui::trinary_choice;
-
-pub async fn choose(
- message: &str,
- label_left: Option<&str>,
- label_middle: Option<&str>,
- label_right: Option<&str>,
-) -> TrinaryChoice {
- trinary_choice(message, label_left, label_middle, label_right).await
-}
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.