Repository navigation
feat(wallet): block core sends while the device is offline - #853
Merged
Merged
Conversation
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.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.syncDonebefore 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 existingensureChainSynced()) 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, whosebuildAndSignFromAddressbroadcasts internally and never reachesbroadcast().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 existingNetworkReachability(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:
For repository code-owners and collaborators only