bitbox02_rust/ui: inline confirm wrapper
What changed, and why it matters
This commit is a small internal code cleanup. It moves the logic that converts a user's approve/cancel response into a success or error result from a shared helper function directly into the user-interface implementation for the BitBox02 device. No behavior changes; no security relevance.
No action required; treat as routine refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch inlines workflow::confirm::confirm() into hal::bitbox02::ui::BitBox02Ui::confirm(). The same match on bitbox02::ui::ConfirmResponse (Approved -> Ok, Cancelled -> Err(UserAbort)) is preserved, and the now-redundant wrapper is removed. A doc comment is added to the trait method. This is a pure refactor with identical semantics.
Changed components
src/rust/bitbox02-rust/src/hal/bitbox02/ui.rssrc/rust/bitbox02-rust/src/hal/ui.rssrc/rust/bitbox02-rust/src/workflow/confirm.rsInspect captured patch +5 / −9
diff --git a/src/rust/bitbox02-rust/src/hal/bitbox02/ui.rs b/src/rust/bitbox02-rust/src/hal/bitbox02/ui.rs
index 7d0db89..d6f568a 100644
--- a/src/rust/bitbox02-rust/src/hal/bitbox02/ui.rs
+++ b/src/rust/bitbox02-rust/src/hal/bitbox02/ui.rs
@@ -13,7 +13,10 @@ pub(crate) struct BitBox02Ui;
impl Ui for BitBox02Ui {
#[inline(always)]
async fn confirm(&mut self, params: &confirm::Params<'_>) -> Result<(), confirm::UserAbort> {
- confirm::confirm(params).await
+ match bitbox02::ui::confirm(params).await {
+ bitbox02::ui::ConfirmResponse::Approved => Ok(()),
+ bitbox02::ui::ConfirmResponse::Cancelled => Err(confirm::UserAbort),
+ }
}
#[inline(always)]
diff --git a/src/rust/bitbox02-rust/src/hal/ui.rs b/src/rust/bitbox02-rust/src/hal/ui.rs
index 5f26e25..1c74a1e 100644
--- a/src/rust/bitbox02-rust/src/hal/ui.rs
+++ b/src/rust/bitbox02-rust/src/hal/ui.rs
@@ -8,6 +8,7 @@ use alloc::string::String;
#[allow(async_fn_in_trait)]
pub trait Ui {
+ /// Returns `Ok(())` if the user accepts, `Err(confirm::UserAbort)` if the user rejects.
async fn confirm(&mut self, params: &confirm::Params<'_>) -> Result<(), confirm::UserAbort>;
async fn verify_recipient(
diff --git a/src/rust/bitbox02-rust/src/workflow/confirm.rs b/src/rust/bitbox02-rust/src/workflow/confirm.rs
index 95c9628..46d0081 100644
--- a/src/rust/bitbox02-rust/src/workflow/confirm.rs
+++ b/src/rust/bitbox02-rust/src/workflow/confirm.rs
@@ -3,11 +3,3 @@
pub use bitbox02::ui::{ConfirmParams as Params, Font};
pub struct UserAbort;
-
-/// Returns `Ok(())` if the user accepts, `Err(UserAbort)` if the user rejects.
-pub async fn confirm(params: &Params<'_>) -> Result<(), UserAbort> {
- match bitbox02::ui::confirm(params).await {
- bitbox02::ui::ConfirmResponse::Approved => Ok(()),
- bitbox02::ui::ConfirmResponse::Cancelled => Err(UserAbort),
- }
-}
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.