Skip to content

gui: Let a mistyped passphrase be typed again - #220

Draft
BenWestgate wants to merge 4 commits into
claude/project-thread-p319g5from
claude/project-thread-ys17zs
Draft

BenWestgate wants to merge 4 commits into
claude/project-thread-p319g5from
claude/project-thread-ys17zs

Conversation

@BenWestgate

@BenWestgate BenWestgate commented Nov 10, 2026 •

Copy link
Copy Markdown
Owner

Requested by Ben · project thread

Stacked on #217 (head 6bcbfa0, which includes #223). This is one commit.

Bug. A wrong wallet passphrase ended on the "Stopped" page. Both of its buttons dropped the seed, so after a new backup, "Restore my wallet" meant typing every card in again. The CLI never asks for the passphrase, so it can't fail this way.

Change (revised after Ben's security review, findings A–E):

  • Failures once cards exist (_then's new again argument):
    • A step that changed nothing (refused passphrase, listing wallets, fingerprint check) goes back to the page that asked, with a dialog. _working records page.asker, and a worker started by another worker inherits it, so this never lands on a spinner (C).
    • A step that may have written (create or import) shows a list of empty wallets fresh from Core, with the error, instead of retrying (B). The library also refuses a wallet that is no longer empty. Only wallet_setup.Refused goes straight back to the unlock page.
  • Unlock page: one passphrase field, one Unlock button and a one-line console hint. work.watch polls Core off the main loop and moves on at most once, like the CLI's wait. It returns stop(): any attempt stops it, and only a refused passphrase (the page showing again) starts a new one (D).
  • Relocking: fill(encrypted=...) locks an encrypted wallet again on every way out, including one the operator unlocked in Core whose import fails before the library arms its own relock (A). A failed relock is still reported (E).
  • Line budget: the GUI is now 2,098 lines and BUDGET rises from 2,063 to 2,100 (Ben OK'd this).

Checked.

  • python -m pytest: 668 passed. The bip32-oracle modules are blocked here, so CI covers them.
  • New tests:
    • test_gui_watch.py: the polling, driven by a fake GLib loop.
    • test_gui_wallet_setup.py: relock after a Core-unlock early failure, a wallet closed mid-import, and Refused.
    • test_gui_unlock_flow.py: 6 tests on real GTK and libadwaita 1.5 under Xvfb, against a fake bitcoin-cli. They cover a typo then retry, an unlock in Core, a failed import with no retry, a typed unlock racing an unlock in Core, a failed relock, and a chained worker failing. The old head fails 5 of these scenarios.
    • CI has no GTK, so the 6 GTK tests skip there. Run them with xvfb-run -a python -m pytest tests/test_gui_unlock_flow.py.
  • ruff and mypy are clean.

VM smoke steps are in /mnt/project-files/pr220/vm-smoke.md in the project files. It still needs Ben's VM pass and security sign-off.

🤖 Generated with Claude Code

https://claude.ai/code/session_01N8jLK5fxFGLYhRkgPfn86t

Bitcoin Core resolves an import timestamp of "now" to its tip's median
time. On an offline signer that never synced, that is the genesis block,
so every new wallet was born in 2009, and the watch-only copy Bails
exports from it asks the online node to rescan from genesis, which a
pruned node cannot do.

A new wallet now takes this computer's clock, a day early like a
recorded creation date, so a clock running up to a day fast cannot skip
its first payments. Restores keep the recorded date.

On a Core 32.1 regtest signer at genesis, the descriptors were dated
1296688602 (genesis) before and the clock less a day after; the signer
still found a payment from blocks it synced later.

Claude-Session: https://claude.ai/code/session_01N8jLK61uohaW6W7Y8AHnMb
@BenWestgate BenWestgate self-assigned this Nov 10, 2026
Every page now asks the window to grow, never past the screen's height,
whenever its content is taller than the space it has: on arrival, when a
section opens, and when a message gets longer. A window the operator
shrinks grows back to fit. The scroller stays as the last resort on a
screen too short for the page.

Name-and-value rows (wallet identity, wallet record, new card) are one
line each, value on the right, so the finished page fits the default
880x620 window and reads straight down against the paper record.

The GUI size budget rises by the 13 lines this takes.

Claude-Session: https://claude.ai/code/session_01N8jLK9eptxLjUcNnMk1VGr
A wrong wallet passphrase ended on the "Stopped" page, whose buttons both
dropped the seed: after a new backup, "Restore my wallet" meant entering
every card again. The command line never loses the seed this way.

Once cards exist, a failed Bitcoin Core step no longer stops:
- A step that changed nothing (a refused passphrase, listing wallets, the
  fingerprint check) goes back to the page that asked, with the error in
  a dialog. A worker started by another worker inherits its asker, so
  this never goes back to a spinner.
- A step that may have written (creating or filling a wallet) shows a
  list of empty wallets fresh from Bitcoin Core, with the error, instead
  of retrying. The library refuses a wallet that is no longer empty.

The unlock page shrinks to one passphrase field and one Unlock button.
An unlock done in Bitcoin Core's console is noticed by polling, as the
command line waits, replacing the "I unlocked it myself" button. The
watch goes on at most once; a typed attempt stops it, and only a refused
passphrase starts a new one.

`fill` now locks an encrypted wallet again on every way out, including
one the operator unlocked in Bitcoin Core whose import fails before the
library arms its own relock. A failed relock is still reported.

The GUI budget rises from 2,063 to 2,100 lines (2,098 used).

Claude-Session: https://claude.ai/code/session_01N8jLK5fxFGLYhRkgPfn86t
@BenWestgate
BenWestgate force-pushed the claude/project-thread-ys17zs branch from ea568a9 to 24a5fa2 Compare November 17, 2026 20:41
@BenWestgate
BenWestgate force-pushed the claude/project-thread-p319g5 branch from 6bcbfa0 to dfb6905 Compare November 17, 2026 20:54

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant