Skip to content

feat: report pending wear payments and tell their outcome - #2193

Draft
jvsena42 wants to merge 64 commits into
feat/wear-nfcfrom
feat/wear-pending-payments
Draft

jvsena42 wants to merge 64 commits into
feat/wear-nfcfrom
feat/wear-pending-payments

Conversation

@jvsena42

@jvsena42 jvsena42 commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

Part of #2105
Source: self, #2182

Warning

Do not publish the Wear app until #2152 ships. The watch runs the same Spark wallet as the phone, and Spark real-time sync is off (realTimeSyncServerUrl = null), so two live instances share no state. Mainnet is also gated off in this build (Env.IS_MAINNET_ENABLED = false).

Stacked on #2192 (feat/wear-nfc). An audit of payments that take long to confirm (hold invoices, slow routes) found that the watch showed a misleading "Waiting for network" for about 60 s, a 3 s "Pending" that was easy to miss, and never told the wearer when a pending payment later succeeded or failed. This PR fixes that, without system notifications.

Description

  • Shows Pending 10 s after the hold instead of 60 s, as the phone does; the payment keeps settling in the background. "Waiting for network" shows only while the watch syncs before sending, or while it is offline during a send.
  • Makes the Pending result show the amount, play a soft haptic and stay 5 s (readable without the amount in ambient). If the payment settles or fails while it shows, the same line switches to Sent or "Payment failed".
  • Remembers payments the watch reported as Pending or Unknown (newest 20, 30 days, cleared by the wipe). When one resolves, live or at the next open, a haptic and a 2 s ✓ or ✕ with the amount show. The outcome is kept until it was shown, waits while a send flow is on screen, the receive QR shows, the watch is locked or in ambient, and a new send waits until earlier outcomes were shown.
  • Keeps Spark connected for up to 3 min while a payment from this watch settles, even if the app leaves the screen; a lock still disconnects at once.
  • Checks invoices already paid or in flight before Review, so reopening a pending invoice shows Pending without a second hold, and releases a QuickPay payment from the day's count when it later fails.
  • Fixes a send-flow bug found in feat: pay and receive by nfc tap on the watch #2192's journey run: after a return from the background the hold was enabled while Spark was still reconnecting, and the hold ended on "Wallet not ready". Pause and lock now mark the wallet before they disconnect it, and a hold that still meets a disconnected wallet goes back to Review and reconnects.
  • Makes the outcome overlay a pane that screen readers can announce, and the send result one live line, so the Pending → Sent/Failed switch is announced (designed; not yet tried with TalkBack, see manual test 1).
  • Adds docs (docs/wear.md › Pending payments) and hold-invoice journeys on the local stack.

Out of Scope

  • wear: no system notifications for outcomes while the app is closed; the outcome shows at the next open.
  • wear: keeping Spark connected for 3 min in the background is best effort: Android may freeze the process earlier. The next open finds the outcome either way.
  • wear: an Unknown send that never reached Spark is never listed, so nothing is told and its QuickPay count stays until the entry expires after 30 days.
  • wear: two resumes in a row can briefly flip a ready wallet to Connecting, so a link opened at that moment can end on "Wallet not ready" — fix: keep a ready wear wallet ready on a second resume #2194
  • wear: an invoice the phone paid moments ago is caught at the hold, not before Review (the watch does not sync before Review, to keep taps and QuickPay fast).

Design

N/A — no design available. #2105 is a prototype with no Figma.

Preview

Large round emulator (454 px, Wear OS 7), local ./spark stack with Alice's hold invoices.

Pending with the amount ✓ when settled ✕ when cancelled Offline
Pending with 1 000 after about 10 s Check overlay with the amount after the hold invoice settled Cross overlay with the amount after the hold invoice was cancelled Can't pay offline after the app was paused

Recordings:

  • A hold invoice settles: Pending, then ✓ Sent:
send-hold-invoice-settle.mp4
  • A hold invoice is cancelled: Pending, then ✕ failed:
send-hold-invoice-cancel.mp4
  • The app is killed while pending; the outcome shows at the next open:
send-outcome-after-restart.mp4

QA Notes

Setup

  • Watch emulator Wear_Large_Round_API37 with the local-stack build (journeys/wear/README.md › Local ./spark stack). Hold invoices come from the stack's Lightning node (Alice): journeys/wear/README.md › Payments › Hold invoices has the bolt11-receive-for-hash, bolt11-claim-for-hash and bolt11-fail-for-hash commands. The test wallet funded on the local chain.

Journeys

  • J1: new send-hold-invoice-pending.xml — paying a hold invoice shows Pending with the amount after about 10 s
  • J2: new send-hold-invoice-settle.xml — settling the hold invoice tells ✓ Sent
  • J3: new send-hold-invoice-cancel.xml — cancelling it tells ✕ failed and refunds the balance
  • J4: new send-pending-reopen.xml — reopening the pending invoice shows Pending with no second hold
  • J5: new send-paid-reopen.xml — reopening a paid invoice is refused before Review
  • J6: new send-outcome-after-restart.xml — an outcome reached while the app was killed shows at the next open
  • J7: new send-outcome-before-next-send.xml — a new send waits until an earlier outcome was shown

Manual Tests

  • 1. With TalkBack on (emulator or watch, local stack), pay a hold invoice and settle it → TalkBack reads "Pending", then the switch to "Sent", and the overlay "Sent, ₿ …" when it shows (manual test 7 in journeys/wear/README.md)

Automated Checks

  • added SendOutcomeRepoTest.kt — watching, resolving live and at the next open, keeping an outcome until shown, the 3 min connection hold, QuickPay release, wipe races
  • added SendOutcomeViewModelTest.kt, SendOutcomeOverlayTest.kt — when the overlay shows and waits (send flow, receive QR, lock, ambient), the pane title
  • added SendResultTest.kt — one live status line across Pending → Sent and Pending → Failed, OK only on failure
  • updated SendViewModelTest.kt — Pending after 10 s, live switch, waiting for earlier outcomes, reconnect after a NotReady hold, outcome under the lock screen
  • updated PaymentsRepoTest.kt, UncertainSendStoreTest.kt — paid and in-flight invoices refused before Review, watched entries, a retry under a watched key told once
  • updated WalletRepoTest.kt, WalletWipeRecoveryTest.kt — pause and lock mark the wallet before they disconnect, an unlock during a lock's disconnect ends connected

Evidence

  • Gate on bc97b190d: just compile, just test (with :wear:testDevDebugUnitTest --rerun, 750 wear tests), just lint all passed.
  • J1, J2, J4–J7 passed on Wear_Large_Round_API37 (Wear OS 7) at 80e7b827b against the local ./spark stack: Pending with 1 000 about 10 s after the hold and no "Waiting for network"; settling showed ✓ once; reopening a pending invoice showed Pending without a hold, a paid one "Already paid"; after am kill the outcome showed once at the next open; a new send waited until an earlier ✕ was shown. A regression pass of send-deeplink-bolt11, send-insufficient, send-own-invoice-guard and nfc-pay-background passed too.
  • J3 at 80e7b827b showed ✕ "Payment failed, ₿ 1 000" but the balance stayed deducted until a reopen; fixed in 2d7de6802 (sync after an outcome) and checked on the emulator: the refund shows as the ✕ clears.
  • send-offline-error.xml failed at 80e7b827b when the app had been in the background as the network went: on the local stack (reached through adb reverse, which survives airplane mode) a paused wallet came back Ready offline. Older than this PR; fixed in 2b07fa9e7 (a sync without a network ends Offline) and the journey passes on the emulator with the fix, also after a pause.
  • Three review rounds (domain and UI); the last found only Lows, which are fixed.

Gaps

  • J3's Activity-detail steps were not rerun after the balance fix.
  • TalkBack (manual test 1) was not tried.
  • The 3 min connection hold in the background was not measured against Android freezing the process.

Models used

  • Planning/scoping: claude-opus-5-5 (reasoning: medium)
  • Implementation: claude-fable-5-2 (reasoning: medium)
  • Review: claude-fable-5-2 (reasoning: medium), claude-opus-5-5 (reasoning: medium)
  • Review rounds: 3
  • Journey runs: claude-sonnet-5-5 (reasoning: medium)

🤖 Generated with Claude Code

jvsena42 and others added 30 commits November 28, 2026 11:20
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…sends

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
jvsena42 and others added 23 commits November 28, 2026 11:21
…e wait

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…schemes

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…fixes

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ow from quickpay

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…gain

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Regtest APK

Built from bc97b19 (run).

Download bitkit-dev-debug universal APK (expires in 30 days).

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