Skip to content

feat(wallet): block Core-funded sends until the chain has synced - #843

Merged
QuantumExplorer merged 1 commit into
swift-sdk-integrationfrom
feat/core-send-sync-gate
Jul 17, 2026
Merged

QuantumExplorer merged 1 commit into
swift-sdk-integrationfrom
feat/core-send-sync-gate

Conversation

@QuantumExplorer

Copy link
Copy Markdown
Member

What

Core-funded sends are now blocked until the L1 chain sync completes. Before SyncingActivityMonitor reports .syncDone, the persisted UTXO set can be stale — already-spent inputs or missing recent funds — so a built transaction could be rejected or, worse, double-spend a UTXO consumed while the wallet was offline.

  • Boundary guard (WalletSendService.ensureChainSynced()): prepareStandardSendForConfirmation, send(...), and sendToContact throw a localized chainNotSynced error while unsynced — covering every programmatic path (payment processor, scan-QR pay flow, DashPay contact payments). CoinJoin sweep is deliberately not gated (recovery to the wallet's own address).
  • UI gates: SendViewModel and InternalTransferViewModel observe the monitor; Continue is disabled for any route that spends Core UTXOs — coreToCore, coreToShielded, coreToPlatform, including the balance-row sheets' pinned variants.
  • Honest affordance: a shared SyncGateNote banner on the Send and Internal transfer screens explains why Continue is disabled ("Your wallet is still syncing…") instead of leaving a dead button.

Platform- and Shielded-funded routes (platform→platform/core/shielded, shielded→anything) stay available during sync — their balances come from the Platform-side syncs, not the L1 UTXO set.

Per the repo guardrail, gating is on SyncingActivityMonitor (.syncDone), never raw SPV state (dash-spv's synced steady state is waitForEvents).

Implementation notes

  • The monitor's observer array holds strongly, so both VMs remove themselves in deinit (same pattern as SyncingAlertViewModel).
  • Observer callbacks hop to the main actor before touching @Published state.

Testing

Testnet smoke on QA-iPhone16 / iPhone 16 Pro sims: fresh launch mid-sync shows the banner and a disabled Continue on Send (Core destination) and on Transparent-funded internal transfers, while Shielded→Core stays enabled; once the monitor flips to synced the banner disappears and sends work; scan-QR pay during sync surfaces the localized error instead of building a tx. Unit-test target pre-existing-broken per CLAUDE.md.

🤖 Generated with Claude Code

Before SyncingActivityMonitor reports .syncDone the persisted UTXO set
can be stale (spent inputs, missing recent funds), so a Core-funded
spend could be rejected or double-spend a UTXO consumed while offline.

- WalletSendService.ensureChainSynced(): boundary guard on
  prepareStandardSendForConfirmation / send / sendToContact, throwing a
  localized chainNotSynced error — covers every programmatic path
  (payment processor, scan-QR, contact payments). CoinJoin sweep stays
  ungated (recovery to the wallet's own address).
- SendViewModel + InternalTransferViewModel observe the monitor (with
  deinit removal — the observer array holds strongly); Continue is
  disabled for routes that spend Core UTXOs (coreToCore,
  coreToShielded, coreToPlatform, incl. the pinned sheet variants).
- Shared SyncGateNote banner on both screens says why Continue is off
  instead of leaving a dead button.

Platform- and Shielded-funded routes stay available during sync — their
balances come from Platform-side syncs, not the L1 UTXO set. Gating is
on SyncingActivityMonitor per the repo guardrail (never raw SPV state).

Co-Authored-By: Claude Fable 5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 17, 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: b1dbf1cf-c23a-4d51-a344-d5b63eecdd7b

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 feat/core-send-sync-gate

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.

@QuantumExplorer
QuantumExplorer merged commit 2bd296b into swift-sdk-integration Jul 17, 2026
1 check passed
@QuantumExplorer
QuantumExplorer deleted the feat/core-send-sync-gate branch August 7, 2026 08:22
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