Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions docs/jade-emulator.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
56 changes: 43 additions & 13 deletions scripts/jade-fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -172,6 +174,31 @@ 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_retrying(size)
for attempt in range(BUTTON_ATTEMPTS):
press(name)
deadline = time.monotonic() + BUTTON_ADVANCE_TIMEOUT_S
now = read_display_retrying(size)
while now == before and time.monotonic() < deadline:
time.sleep(0.25)
now = read_display_retrying(size)
if now != 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
Expand Down Expand Up @@ -227,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 = []
Expand All @@ -252,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:
Expand Down Expand Up @@ -492,7 +522,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":
Expand Down