Skip to content

fix(wallet): live balance refresh and withhold the Dash DEX shortcut - #806

Merged
QuantumExplorer merged 2 commits into
swift-sdk-integrationfrom
fix/home-balance-live-refresh
Jul 16, 2026
Merged

QuantumExplorer merged 2 commits into
swift-sdk-integrationfrom
fix/home-balance-live-refresh

Conversation

@romchornyi

@romchornyi romchornyi commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Issue being fixed or feature implemented

Two related post-merge fixes on swift-sdk-integration:

  1. Home balance didn't update on incoming payments until the app was re-foregrounded/relaunched. Reproduced with the testnet faucet (tap tDash → funds arrive → balance stays stale, transaction list updates fine).
  2. Dash DEX was still reachable via the shortcut bar, even though it's withheld for this migration release — its swap path builds through frozen DashSync and can't complete.

What was done?

Balance refresh (d3a27f0) — Device logs show the SDK emits TransactionDetected / TransactionInstantLocked wallet events with the new balance, and Rust's persister writes PersistentTransaction rows → NSManagedObjectContextDidSave. The home tx list already reloads on that signal, but the balance was refreshed only by refreshBalanceBridge() on SPV start and on sync-progress ticks — which stop once the chain is fully synced (steady state). So an incoming payment while synced never updated the balance. Fix: subscribe the balance bridge to the same NSManagedObjectContextDidSave signal (throttled 1s to coalesce the sync-time save storm), reusing the existing refreshBalanceBridge(); cancelled in performStop.

Dash DEX shortcut (aacb286) — The release merge gated only the Buy & Sell portal card (showsSwapKit = false) and left the .dashDEX shortcut reachable. Removed .dashDEX from customizableActions (can't be added to the bar) and degrade an already-saved .dashDEX shortcut to .spend (same pattern as getTestDash/switchWallet). The enum case + icon/title are kept so persisted-config raw values stay stable and DEX returns if restored.

How Has This Been Tested?

  • dashwallet-dashpay scheme builds clean on the iOS Simulator (ARCHS=arm64).
  • The balance fix is grounded in the attached device logs — the NSManagedObjectContextDidSave signal it hooks demonstrably fires live (the tx list updated to 3 txs in the same logs where the balance stayed stale).
  • Pending: live on-device confirmation of the faucet flow (tap tDash → balance updates without relaunch). The DEX shortcut change is static/config and covered by the build.

Breaking Changes

None. Dash DEX remains withheld (now consistently); no API or data changes.

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

Summary by CodeRabbit

  • Bug Fixes

    • Wallet balances now refresh automatically after saved data changes, with updates stopped when wallet synchronization ends.
    • Existing Dash DEX shortcuts now safely display as Spend shortcuts when restored.
  • Changes

    • Dash DEX is temporarily unavailable as a customizable shortcut option.

The published balance was refreshed only by refreshBalanceBridge() on SPV
start and on sync-progress ticks. Once the chain is fully synced the client
sits in steady state with no progress ticks, so an incoming payment (e.g. the
testnet faucet) updated the transaction list — which reloads on
NSManagedObjectContextDidSave — but not the balance, until the next
foreground/restart re-ran the bridge.

Subscribe the balance bridge to the same NSManagedObjectContextDidSave signal
(Rust's persister writes PersistentTransaction rows on a detected/instant-locked
tx), throttled 1s to coalesce the sync-time save storm. Reuses the existing
refreshBalanceBridge(); cancelled in performStop.
Dash DEX has two entry points; the release merge gated only the Buy & Sell
portal card (showsSwapKit = false) and left the .dashDEX shortcut reachable,
which routes to the SwapKit swap flow built on frozen DashSync.

- Remove .dashDEX from customizableActions so it can't be added to the bar.
- Degrade an already-saved .dashDEX shortcut to .spend (same pattern as
  getTestDash/switchWallet); the saved raw value is untouched, so it returns
  if DEX is restored.

The enum case + icon/title are kept for persisted-config raw-value stability.
@coderabbitai

coderabbitai Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

SPV balance refreshes are triggered by managed-object-context save notifications with throttling and stop-time cleanup. Home shortcut configuration excludes Dash DEX and converts saved Dash DEX shortcuts to spend during restoration.

Changes

Wallet and shortcut behavior

Layer / File(s) Summary
SPV balance refresh lifecycle
DashWallet/Sources/Infrastructure/SwiftDashSDK/SwiftDashSDKSPVCoordinator.swift
A throttled managed-object-context save subscription refreshes the balance, and its cancellable is cleared when SPV stops.
Dash DEX shortcut gating and restoration
DashWallet/Sources/UI/Home/Views/Shortcuts/Models/ShortcutAction.swift, DashWallet/Sources/UI/Home/Views/HomeViewModel.swift
Dash DEX is removed from customizable actions, while saved Dash DEX shortcuts reload as spend shortcuts.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: quantumexplorer, jeanpierreroma, llbartekll

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the two main wallet changes: live balance refresh and withholding the Dash DEX shortcut.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/home-balance-live-refresh

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.

@romchornyi romchornyi changed the title fix(home): live balance refresh and withhold the Dash DEX shortcut fix(wallet): live balance refresh and withhold the Dash DEX shortcut Jul 15, 2026
@romchornyi

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@DashWallet/Sources/UI/Home/Views/HomeViewModel.swift`:
- Around line 884-889: Update the restored shortcut handling around the
.dashDEX-to-.spend mapping so it checks whether a .spend shortcut already exists
before applying the fallback. Preserve the saved configuration when the fallback
would create a duplicate, and ensure the final restored list remains unique
without changing the saved configuration.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d6a91cdd-b032-4376-9c79-7b0b4dac12dd

📥 Commits

Reviewing files that changed from the base of the PR and between 1ca07eb and aacb286.

📒 Files selected for processing (3)
  • DashWallet/Sources/Infrastructure/SwiftDashSDK/SwiftDashSDKSPVCoordinator.swift
  • DashWallet/Sources/UI/Home/Views/HomeViewModel.swift
  • DashWallet/Sources/UI/Home/Views/Shortcuts/Models/ShortcutAction.swift

Comment on lines +884 to +889
// Dash DEX is withheld for the migration release (frozen-DashSync
// swap path); a saved DEX shortcut degrades to Spend. The saved
// config is untouched, so it returns if DEX is restored.
if type == .dashDEX {
type = .spend
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Avoid duplicate Spend shortcuts during DEX restoration.

If a saved configuration contains both .spend and .dashDEX, this mapping produces two .spend actions. Since the item count remains valid, the duplicate list is accepted and one distinct shortcut is lost. Use a uniqueness-aware fallback before accepting the restored configuration.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@DashWallet/Sources/UI/Home/Views/HomeViewModel.swift` around lines 884 - 889,
Update the restored shortcut handling around the .dashDEX-to-.spend mapping so
it checks whether a .spend shortcut already exists before applying the fallback.
Preserve the saved configuration when the fallback would create a duplicate, and
ensure the final restored list remains unique without changing the saved
configuration.

@QuantumExplorer
QuantumExplorer merged commit fb9815d into swift-sdk-integration Jul 16, 2026
2 of 3 checks 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