Repository navigation
fix: ask for the pin when a logged-out jade is used - #2140
Conversation
A Jade logged out on the device (Session > Log Out, or a timeout) answered Verify on Device and Sign With Jade with DeviceLocked, which showed as busy. Like iOS, the request now unlocks the Jade through the pinserver, checks it opened the same wallet, and runs once more. Verified: just compile, just test, just lint and assembleDevDebug passed on this change.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 76ccd79e6c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
[Medium impact] The change affects two Jade actions in the hardware-wallet workflow. The PR appears safe to merge, with a non-blocking timeout issue for users who need longer to enter their Jade PIN. Findings
SummaryThe PR asks for the Jade PIN when address verification or signing reports a locked device.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Verify address or sign] --> B{Device locked?}
B -- No --> C[Return result]
B -- Yes --> D[Ask for PIN]
D --> E[Read wallet identity]
E --> F{Same wallet?}
F -- No --> G[Return wallet mismatch]
F -- Yes --> H[Retry request once]
H --> C
Reviews (1) · Last reviewed commit: "fix: ask for the pin when a logged-out j..." · Reviewed by Greptile |
Regtest APKDownload bitkit-dev-debug universal APK (expires in 30 days). |
talosmachina
left a comment
There was a problem hiding this comment.
No findings. Retries a Jade request once after DeviceLocked: marks the session locked, unlocks through ensureConnected, refuses a Jade that opens another wallet, then reruns verifyAddress / signPsbt. Reviewed 76ccd79e6, full tier.
What I checked, and 2 candidates I ruled out
Read in full: JadeRepo.kt (ensureConnected, connectDevice, openedWallet, unlockConnected, retryingOnceIfLocked), JadeExceptionExt.kt, the Jade paths of HwWalletRepo.kt (signJadeFunding, verifyJadeReceiveAddress, ensureConnected), JadeRepoTest.kt additions.
Call sites traced: jadeRepo.signPsbt (only HwWalletRepo.signJadeFunding), jadeRepo.verifyAddress (only verifyJadeReceiveAddress).
CI at this head: build-and-test, lint, detekt, build-local green; e2e shards and compose-ui still pending. Static review: on bitkit-android the PR's branch is not built or run by this reviewer, so this rests on the code and on CI.
Ruled out
- Retry loops: one retry only; a second
DeviceLockedpropagates and keeps the busy message, as the body's Out of Scope says. - Wrong-wallet signature after unlock:
ensureConnectedre-reads the accounts andopenedWalletrejects an unknown seed; a passphrase wallet on the same Jade yields anotherwalletId, which the new check refuses before the second call. Covered bysignPsbt refuses a jade logged out on the device that unlocks into another wallet.
Merge confidence: 4/5, no findings and the change is unit tested, but the e2e shards are still running and the branch was not run here.
Reviewer model: claude-opus-5-5
Reasoning effort: Not exposed (the session metadata names the model, not a reasoning setting)
A Jade logged out on the device now marks its session locked on any DeviceLocked answer, and the caller's connect step unlocks it: Verify on Device and the send sheet's compose and sign. The PIN prompt then gets the Jade reconnect budget, the sheet can still be left while it waits, and the fingerprint read before composing is covered too. Verified: just compile, just test, just lint and assembleDevDebug passed on this change.
jvsena42
left a comment
There was a problem hiding this comment.
Code scan at 3e14830: no HIGH/MEDIUM. One LOW, inline.
Checked and clean:
- No different PSBT, double sign or double broadcast. The compose retry runs before anything is sent to the device, and the sign retry re-sends the same
funding.DeviceLockedcomes only from the device'sHW_LOCKED(-32002) refusal, before any signature. There's one retry; a secondDeviceLockedgets the busy toast.pendingBroadcastis set once. - After the PIN,
JadeRepo.ensureConnectedexports accounts andopenedWalletrejects a foreign seed.requireWallet(walletId)andisSessionOfre-check before signing, and a passphrase wallet opened on the device givesHwWalletMismatchError. - Classification:
isJadeDeviceLockedmatches onlyDeviceLocked.DeviceBusy,UserCancelled(a decline on the device) and session failures aren't retried.isJadeDeviceBusystill includes locked, soretryAutoReconnectandHwConnectViewModelbehave as before. - Cancel/Back: both send retries run through
ensureConnectedwithisConnectingDeviceset, so the sheet is leavable, andcancel()disconnects the LOCKED session. The PIN waits are bounded (send 5 min; verify 7 min). The verify recover order is locked, then session failure, then mismatch. jade-device-locked.xmlis byte-identical to the copy on synonymdev/bitkit-ios#1441, and its steps match the verify path at head.
perf: not relevant (one bounded retry under the existing reconnect budget).
Device gate (partial): 3e14830 — not run yet; Jade emulator run of J1 plus Sign With Jade after a logout to follow.
Reviewer model: Opus 5.5 (claude-opus-5-5) coordinating; Fable 5.2 (claude-fable-5-2) primary review
Reasoning effort: Not exposed
piotr-iohk
left a comment
There was a problem hiding this comment.
QA review
Scope: full PR diff against its merge base, at 3e14830.
No new actionable code findings.
No actionable code findings. A DeviceLocked answer to verifyAddress, signPsbt or getMasterFingerprint now marks the Jade session locked. The caller's connect step then unlocks it: JadeRepo.ensureConnected asks for the PIN, re-exports the accounts and runs openedWallet, then HwWalletRepo.ensureConnected runs requireWallet. After that the request runs once more. Traced paths:
- Receive verify: the locked retry runs before the session-failure and mismatch recovery, inside the
VERIFY_TIMEOUT + reconnectTimeoutbudget. - Send compose: the fingerprint read is retried after unlocking.
- Send sign: the same
fundingPSBT is re-sent after unlocking. Nothing was signed before the locked refusal, andpendingBroadcastis set once. - Cancel and Back: both send retries unlock through
HwSendViewModel.ensureConnected. That setsisConnectingDevice, socanLeavestays true and the PIN wait gets the 5-minute Jade reconnect timeout. The same view model also backsSpendingHwSignScreen, so transfer to spending gets the same behaviour. - A Jade unlocked into another seed or passphrase wallet still ends in
HwWalletMismatchErrorbefore anything is signed.
Earlier review threads: the Codex style notes, Greptile's 120-second PIN budget, and both of Ben's concerns (the fingerprint read before compose, and leaving the sheet during the PIN prompt) are marked resolved. I checked each against this head and they are fixed. One thread is still open: jvsena42's LOW coverage note on jade-device-locked.xml, which says the send/sign retry has no emulator journey. I agree it is a coverage gap, not a code defect.
Parity: compared with bitkit-ios main at d30d2d6 (JadeManager.retryingOnceIfLocked). Android follows the same approach: retry once after unlocking, and refuse a Jade that opened another wallet. Android also covers the fingerprint read before compose, which iOS does not yet do (bitkit-ios#1517).
Validation: the CI run at 3e14830 passed (build-and-test, lint, compose-ui). The author's J1 journey evidence is from the previous head, 76ccd79. The retry logic has since moved from JadeRepo into HwWalletRepo and HwSendViewModel, and the author reports the re-run at 3e14830 as in progress. No unit test covers the Jade locked-retry branch in HwWalletRepo.verifyJadeReceiveAddress. The new tests cover only the JadeRepo state change and the send view model. I did not trace the mapping from the device's HW_LOCKED to JadeException.DeviceLocked inside jade-client-rs; the author's journey observation supports it.
Recommended before device testing: wait for the author's J1 and Sign With Jade re-run at 3e14830.
Device testing: not performed in this review.
Suggested additional test cases:
- Android, Jade emulator (
JADE_MODE=interactive), funded paired wallet. Pair the Jade, choose Session → Log Out on the device, then start Transfer to Spending with the Jade and tap the sign button. Expected: the Jade shows its PIN pad. While it waits, the sheet can still be left. Afterpin 012345and approving on the device, exactly one funding transaction is broadcast. - Android, Jade emulator with
JADE_PASSPHRASE=always. Pair the standard wallet, log out on the device, tap Verify on Device, enter the PIN, then type a different passphrase on the device. Expected: the wallet-mismatch error shows and no address is confirmed for the paired wallet. - Android, Jade emulator. Log out on the device, start Send → Sign With Jade, and press Back while the PIN pad shows. Expected: the sheet closes and nothing is signed or broadcast. A new Sign With Jade asks for the PIN again and completes.
Reviewer model: claude-opus-5-5
Reasoning effort: high
Verified: xmllint on the journey; its send steps ran on the Android emulator against the interactive Jade emulator on 3e14830.
The locked journey also signs a send after a logout, as on Android (synonymdev/bitkit-android#2140). iOS does not retry the fingerprint read on Sign With Jade yet, so that step can still report busy until #1517. Verified: xmllint on the journey
piotr-iohk
left a comment
There was a problem hiding this comment.
QA review
Scope: changes since 3e14830, including affected code paths and prior findings, at ba7ac08. Baseline: previous QA review. The merge base is unchanged and 3e14830 is an ancestor of ba7ac08. The only new commit changes journeys/hardware-wallet/jade-device-locked.xml and the hardware-wallet README. Coverage of the unchanged app code, unit tests, changelog fragment and iOS parity check is inherited from the baseline.
No new actionable code findings.
No new actionable code findings in the follow-up.
The new journey steps log the Jade out again after Verify on Device, then run Send → Sign With Jade → PIN pad → approve → one payment sent. They match the source at this head:
- The test tags
Send,AssetButton-switch,ContinueAmount,HardwareSendOpenTrezorConnectandSendSuccessall exist. - The amount, swipe and device button-press sequence is the same as in the existing
jade-sign-on-device.xmljourney. - The PIN prompt appears where the step says it does.
HwSendViewModel.prepareSignedTransactioncomposes the transaction, and the fingerprint read inside it gets a locked answer. The retry then unlocks the Jade inensureConnected, which setsisConnectingDevice, socanLeavestays true while the PIN pad is shown. - The README rows now describe this flow instead of the old busy-message wording.
Checks run: git diff --check on the delta passed and the journey XML parses. No build was run: the delta is documentation only.
Non-blocking consistency suggestions
- The step "Verify … the sheet's Back button is still shown" passes whatever the app does.
HwSendSignContentalways shows the top-bar Back button;canLeaveonly decides whether tapping it closes the sheet (HwSendSignScreen.kt:81). To test the PIN-wait behaviour the PR adds, tap Back instead (see the suggested test case below), or say in the step that only visibility is checked.
Earlier review threads: all 8 threads are resolved. jvsena42's LOW thread about journey coverage of the send path is fixed in the code at ba7ac08, which adds the Sign With Jade steps. The other 7 threads were fixed at 3e14830, as the baseline review recorded, and none of that code has changed since.
Parity: the Android journey now has send steps that are not in the iOS copy. jvsena42 says the two copies were byte-identical at 3e14830 and that iOS does not retry the fingerprint read yet (bitkit-ios#1517). I did not check this against iOS source in this pass. It is a difference between the two journey copies, not an Android defect.
Ready for device testing: the journey setup needs an interactive Jade emulator with funds on the Jade's regtest addresses. Device testing was not performed in this review.
Suggested additional test cases
- Android, interactive Jade emulator, paired and funded: log out on the device (
press front right front), start Send from the Jade, swipe to confirm and tap Sign With Jade. While the Jade shows its PIN pad, tap the sheet's Back button. Expected: the sheet closes, no payment is sent and no error toast appears. A new Sign With Jade attempt then asks for the PIN again and can complete.
Reviewer model: claude-opus-5-5
Reasoning effort: high
Verified: xmllint and git diff --check on the journey; bitkit-docker 48b6c9f exposes electrs on 60001 and ./bitcoin-cli.
@piotr-iohk Dropped in 1a49aab: the step now checks only that the Jade shows its PIN pad. |
|
Device gate (partial): 3e14830, Android emulator against the bitkit-docker Jade emulator (interactive mode), staging regtest.
Still running: the full runbook drive, including cancel during the PIN wait. |
The description names the bitkit-docker Electrum and the funding command for the send steps, and the PIN pad step no longer checks the sheet's Back button, as on Android (synonymdev/bitkit-android#2140). Verified: xmllint on the journey
jvsena42
left a comment
There was a problem hiding this comment.
Approving at 1a49aab. The journey LOW is fixed in ba7ac08: jade-device-locked.xml now covers Sign With Jade after a logout.
Device gate: 1a49aab (app code 3e14830; the two later commits are journey and README only). Journeys: 1 passed (jade-device-locked.xml as at 1a49aab, every action, including the new send steps). Android emulator, bitkit-docker Jade emulator in interactive mode, staging regtest.
- Verify after logout: PIN pad in under 2 s, no toast, Verify Address 2 s after the PIN, button returns with no error.
- Sign With Jade after logout: PIN pad 3 s after the tap, no busy toast, Output screen 10 s after the PIN. One payment (52 000 + 141), one Sent row, one
Created sent onchain activity, unchanged after 30 s. - Decline on device after the PIN: no payment, no toast, no retry.
- Back or drag-dismiss during the PIN wait: back to Confirm or Home with no payment.
- Logged out again during the retry: a second PIN pad (one retry per stage), no loop. The same-stage busy toast couldn't be reached on the emulator in 3 attempts (the device answers before a third logout lands).
- The journey's bitkit-docker Electrum and funding steps were replaced by staging Electrum with an already-funded Jade.
21:22:32.759 INFO [JadeRepo.kt:735] Marked Jade 'jade:serial:000000000000' locked after it logged out on the device
21:22:32.760 ERROR [JadeRepo.kt:385] Jade getMasterFingerprint failed [AppError='']
21:23:26.4 INFO Created sent onchain activity for txid 7ae5dbcf…0708f6
perf: not relevant (Sign tap → PIN pad 3 s; approve → sent 1.0–1.4 s); l10n: no UI text changed.
Two things I saw that this PR doesn't cause are in a separate comment.
Reviewer model: Opus 5.5 (claude-opus-5-5) coordinating; Fable 5.2 (claude-fable-5-2, reasoning medium) primary review and device runbook; Sonnet 5.5 (claude-sonnet-5-5, reasoning low) device driver
Reasoning effort: Not exposed (coordinator)
|
Outside this PR's scope; no change needed here. 1. Cancelling during the Jade's PIN wait leaves the device on its PIN pad, and the next attempt fails with a raw error. Repo: bitkit-android, Reproduction (Android emulator, Jade emulator interactive, 3e14830)Log out on the Jade → Sign With Jade → PIN pad shows → Back → Sign With Jade again → enter PIN: Same without a logout: cancel a locked connect during its PIN wait → 2. Fee shown vs fee signed differs on the Jade too. Signing on an already-unlocked session, the app's confirm screen showed ₿ 141 and the Jade showed (and paid) 0.00000209 BTC. That's #1818, now seen with Jade as well as Trezor; no new issue needed. |
@jvsena42 Filed as #2145 in 3.3.0. The fee difference stays with #1818. Merging: approved at 1a49aab, all checks pass, no open threads, and the Jade emulator runs passed (app code at 3e14830; later commits change only the journey and README). |
Closes #2050
Refs:
Description
DeviceLockedwas reported as busy. ADeviceLockedanswer to verify, sign or the fingerprint read now marks the session locked, and the caller's connect step asks for the PIN on the device, checks that the Jade opened the same wallet (otherwise the wallet-mismatch error), and runs the request once more.retryingOnceIfLocked, so that the PIN gets the Jade reconnect budget, the sheet can still be left while the Jade waits for it, and the fingerprint read before composing is covered too.jade-device-locked.xmland the hardware-wallet journeys README: after a logout the PIN pad shows again and Verify on Device goes through, and after a second logout Sign With Jade does too.Out of Scope
Design
N/A — no UI changes.
Preview
J1: logged out on the Jade, Verify on Device asks for the PIN on the Jade, then the address is confirmed with no error (2x):
j1-3e148302x.mp4
Sign With Jade after a logout: the Jade asks for its PIN while the sheet can still be left, then shows the output and fee, and the payment is sent (2x):
sign-reconnect-3e148302x.mp4
QA Notes
Setup
feat/jade-emulator):docker compose up -d, thenJADE_MODE=interactive ./scripts/jade-emulator start.JADE_EMULATOR=trueinlocal.properties, on an Android emulator (it reaches the Jade at10.0.2.2:30121).10.0.2.2, port60001, TCP../bitcoin-cli sendtoaddress <jade address> 0.001and./bitcoin-cli -generate 1.Journeys
jade-device-locked.xml— Verify on Device and then Sign With Jade, each after a logout on the Jade, ask for the PIN on the device, then verify with no error and send one paymentManual Tests
Automated Checks
JadeRepoTest.ktcase — a locked answer marks the session locked, andensureConnectedthen unlocks it into the same walletHwSendViewModelTest.ktcase — a locked compose and a locked sign each unlock in the connect step and run againEvidence
just compile,just test,just lintandassembleDevDebugpass.Gaps
Models used
Claude Opus 5.5(reasoning:medium)Claude Opus 5.5(reasoning:medium)