From 57862631d3186cf8be019101007ebc847b5a5ecb Mon Sep 17 00:00:00 2001 From: Ovi Trif Date: Fri, 27 Nov 2026 16:09:33 +0100 Subject: [PATCH 1/2] fix: press the jade emulator buttons again when one is dropped On a busy host the emulator can drop a press, and the next ones land on the wrong screen: a dropped front before right front opens Scan QR instead of Log Out, and the stuck camera blocks every request. The press command now sends one button at a time and presses again, up to three times, when the screen does not change. Verified: press right left left on the interactive emulator (each press changed the screen); a simulated dropped press is pressed again and a press with no effect stops after three tries --- CHANGELOG.md | 1 + docs/jade-emulator.md | 5 +++-- scripts/jade-fixture.py | 27 ++++++++++++++++++++++++++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0e3eed..ad4a306 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Simplify LND funding step in README to a single command instead of clipboard-based two-step flow ### Fixed +- Press the Jade emulator's buttons again when a busy host drops one, so `./scripts/jade-emulator press` sequences reach the intended screen - Swap Spark leaves on the `spark` profile with Spark SDK 0.28.3 wallets, so a send pays any amount instead of only exact leaf sums - Build the `vss-server` image again: bump the submodule to synonymdev/vss-server#3, which moves its Dockerfile to Debian bookworm after bullseye's security packages left `deb.debian.org` - Split the USDT history smoke's 256-block mining step into sequential 16-block RPC calls to avoid timeouts on slower hosts diff --git a/docs/jade-emulator.md b/docs/jade-emulator.md index f01ee5f..015a5c3 100644 --- a/docs/jade-emulator.md +++ b/docs/jade-emulator.md @@ -24,8 +24,9 @@ deterministic test device for Bitkit's Jade flows. | `interactive` | 1.0.41, `--dev --psram --webdisplay` | Shows its real screens and waits for buttons: drive it with `press`, `pin` and `screen`. | | `old` | 1.0.33, CI build | Auto-confirming firmware older than taproot address support (1.0.34). | -`press` takes `left`, `right`, `click` (wheel press) and `front` (the select button), each -press 0.25 s apart. The interactive PIN pad starts every digit at 0, so `pin` steps right to +`press` takes `left`, `right`, `click` (wheel press) and `front` (the select button) and +presses them one at a time; a press that leaves the screen unchanged (a busy host can drop one) +is pressed again, up to three times. The interactive PIN pad starts every digit at 0, so `pin` steps right to each digit and selects it, waiting on the screen for each digit's box first, so it can run as soon as the app asks for the PIN. A digit whose box shows no change after its presses (a pad that just appeared can drop them) is pressed again. A wrong `pin` shows the device's own "Incorrect PIN!" screen; the diff --git a/scripts/jade-fixture.py b/scripts/jade-fixture.py index 4caeb9f..5c11cde 100644 --- a/scripts/jade-fixture.py +++ b/scripts/jade-fixture.py @@ -55,6 +55,8 @@ PIN_PAD_TIMEOUT_S = 30 PIN_ADVANCE_TIMEOUT_S = 3 PIN_PRESS_ATTEMPTS = 3 +BUTTON_ATTEMPTS = 3 +BUTTON_ADVANCE_TIMEOUT_S = 3 FRAME_ATTEMPTS = 3 TIMEOUT_SCREEN = "/tmp/jade-timeout.png" DEVICE = f"tcp:127.0.0.1:{PORT}" @@ -172,6 +174,29 @@ def is_continue_screen(): return all(sum(is_green(pixel) for pixel in rows[y]) >= 200 for y in (118, 128)) +def press_each(*names): + """Press buttons one at a time, pressing again when the screen shows no change. + + A busy host can drop a press, and the next ones then land on the wrong screen (a dropped + front before right front opens Scan QR instead of Log Out). A press with no visible effect + is retried, which for such a press only repeats nothing.""" + width, height = display_size() + size = width * height * 2 + for name in names: + before = read_display(size) + for attempt in range(BUTTON_ATTEMPTS): + press(name) + deadline = time.monotonic() + BUTTON_ADVANCE_TIMEOUT_S + while read_display(size) == before and time.monotonic() < deadline: + time.sleep(0.25) + if read_display(size) != before: + break + if attempt < BUTTON_ATTEMPTS - 1: + log(f"'{name}' left the device screen unchanged; pressing again") + else: + log(f"'{name}' left the device screen unchanged after {BUTTON_ATTEMPTS} presses") + + def screen_check(condition): # A busy host can stall the display socket for a moment; that only means not ready yet. import websocket # python3-websocket @@ -492,7 +517,7 @@ def status(): elif command == "status": sys.exit(status()) elif command == "press": - press(*sys.argv[2:]) + press_each(*sys.argv[2:]) elif command == "pin": type_pin(sys.argv[2]) elif command == "passphrase": From 45ebdf7b0818180a8a4ea97f63253efa415d58f5 Mon Sep 17 00:00:00 2001 From: Ovi Trif Date: Fri, 27 Nov 2026 16:13:10 +0100 Subject: [PATCH 2/2] fix: retry a stalled screen read while pressing jade buttons The press check reads the display through the same retry frame() uses, so one stalled read on a busy host no longer ends a press sequence, and each poll reads the screen once. Verified: simulated stalled read and dropped press against the fixture's press command --- scripts/jade-fixture.py | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/scripts/jade-fixture.py b/scripts/jade-fixture.py index 5c11cde..41e7b3d 100644 --- a/scripts/jade-fixture.py +++ b/scripts/jade-fixture.py @@ -183,13 +183,15 @@ def press_each(*names): width, height = display_size() size = width * height * 2 for name in names: - before = read_display(size) + before = read_display_retrying(size) for attempt in range(BUTTON_ATTEMPTS): press(name) deadline = time.monotonic() + BUTTON_ADVANCE_TIMEOUT_S - while read_display(size) == before and time.monotonic() < deadline: + now = read_display_retrying(size) + while now == before and time.monotonic() < deadline: time.sleep(0.25) - if read_display(size) != before: + now = read_display_retrying(size) + if now != before: break if attempt < BUTTON_ATTEMPTS - 1: log(f"'{name}' left the device screen unchanged; pressing again") @@ -252,19 +254,8 @@ def pad_ready(index): def frame(): """The display as rows of (r, g, b) tuples.""" - import websocket # python3-websocket - width, height = display_size() - # A busy host can stall the display socket for a moment, so a read is retried before it fails. - for attempt in range(FRAME_ATTEMPTS): - try: - pixels = read_display(width * height * 2) - break - except (OSError, websocket.WebSocketException) as error: - if attempt == FRAME_ATTEMPTS - 1: - raise - log(f"device screen unreadable, retrying: {error}") - time.sleep(1) + pixels = read_display_retrying(width * height * 2) rows = [] for y in range(height): row = [] @@ -277,6 +268,20 @@ def frame(): return rows +def read_display_retrying(size): + import websocket # python3-websocket + + # A busy host can stall the display socket for a moment, so a read is retried before it fails. + for attempt in range(FRAME_ATTEMPTS): + try: + return read_display(size) + except (OSError, websocket.WebSocketException) as error: + if attempt == FRAME_ATTEMPTS - 1: + raise + log(f"device screen unreadable, retrying: {error}") + time.sleep(1) + + def read_display(size): ws = display() try: