refactor(core): split per-share loop into a helper `_DisplayBackup` method
What changed, and why it matters
This commit is a simple code cleanup: it takes an existing loop that walks the user through backing up each recovery-share and moves that loop body into a new helper method named `_backup_share`. There is no change to what the code does, what data it handles, or how it interacts with the user. It is purely a structural refactor.
No action required. This is a non-functional refactor with no security implications.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff extracts the per-share backup loop from _DisplayBackup.__call__ into a new private async method _backup_share(self, share: ShareInfo). The logic, control flow, and calls to show_share_words and _share_words_confirmed remain identical. No security-relevant behavior is altered.
Changed components
core/src/apps/management/reset_device/layout.pyInspect captured patch +14 / −11
diff --git a/core/src/apps/management/reset_device/layout.py b/core/src/apps/management/reset_device/layout.py
index cb1efadb..ed72ba93 100644
--- a/core/src/apps/management/reset_device/layout.py
+++ b/core/src/apps/management/reset_device/layout.py
@@ -178,17 +178,20 @@ class _DisplayBackup:
# backup all shares
for share in iter_shares:
- while True:
- # display paginated share on the screen
- await show_share_words(
- share_words=share.words,
- share_index=share.index,
- group_index=share.group_index,
- )
-
- # make the user confirm words from the share
- if await _share_words_confirmed(share):
- break # this share is confirmed, go to next one
+ await self._backup_share(share)
+
+ async def _backup_share(self, share: ShareInfo) -> None:
+ while True:
+ # display paginated share on the screen
+ await show_share_words(
+ share_words=share.words,
+ share_index=share.index,
+ group_index=share.group_index,
+ )
+
+ # make the user confirm words from the share
+ if await _share_words_confirmed(share):
+ break # this share is confirmed, go to next one
async def choose_backup_handler(method: BackupMethod | None) -> BackupHandler:
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.