Skip to content

feat(wallet): block core sends while the device is offline - #853

Merged
romchornyi merged 1 commit into
swift-sdk-integrationfrom
fix/send-offline-reachability
Jul 22, 2026
Merged

romchornyi merged 1 commit into
swift-sdk-integrationfrom
fix/send-offline-reachability

Conversation

@romchornyi

Copy link
Copy Markdown
Contributor

Issue being fixed or feature implemented

A core send confirmed while the device is offline is silently accepted with no feedback. Repro: start a send, authenticate, and on the confirm sheet enable airplane mode, then tap Confirm — nothing visible happens; the transaction only broadcasts once connectivity returns.

Root cause: the SDK's broadcast accepts a transaction offline (queuing it to send on reconnect) without throwing, and the send path had no reachability check — only ensureChainSynced(), which gates on sync state, not connectivity (a wallet that reached .syncDone before airplane mode stays .syncDone). With no error thrown, the UI has nothing to report. Beyond the missing feedback, a user who assumes the send failed can retry into a double-spend.

What was done?

Added a shared WalletSendService.ensureOnline() gate (mirroring the existing ensureChainSynced()) and called it from both send paths:

  • PreparedStandardSend.broadcast() — the interactive confirm-sheet path (the reported repro).
  • send() right after the sync gate — covers the selected-input/sweep path, whose buildAndSignFromAddress broadcasts internally and never reaches broadcast().

It only blocks when the reachability monitor is live and reports offline (isMonitoring && !isReachable); if monitoring hasn't started it falls through (fail-open) rather than block a send on an unknown signal. Reuses the existing NetworkReachability (NWPathMonitor) already started at app launch.

How Has This Been Tested?

Not yet run through a device build (Xcode was open on the project; CLI build skipped to avoid a build.db collision). Recommended testnet smoke: start a core send, authenticate, enable airplane mode on the confirm sheet, tap Confirm — expect a clear "No internet connection" error and no queued/silent broadcast; then disable airplane mode and confirm no phantom/duplicate transaction. Regression-check a normal online send still works.

Breaking Changes

None.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

The SDK's broadcast accepts a transaction offline (queuing it to send on
reconnect) without throwing, so a send confirmed after airplane mode was
enabled on the confirm sheet silently "succeeded" with no feedback — and a
user who assumed it failed could retry into a double-spend.

Add a shared WalletSendService.ensureOnline() gate (mirroring
ensureChainSynced) and call it from both send paths: PreparedStandardSend
.broadcast() (the interactive confirm-sheet path) and send() after the sync
gate (covers the selected-input path, whose buildAndSignFromAddress
broadcasts internally and never reaches broadcast()). Only blocks when the
reachability monitor is live and reports offline; fails open otherwise.
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c045037c-ee18-45fd-bb54-3b01c1ed5304

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/send-offline-reachability

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@llbartekll llbartekll left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@romchornyi
romchornyi merged commit 9759030 into swift-sdk-integration Jul 22, 2026
1 check passed
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.

3 participants