Skip to content

fix(wallet): reject a Dash address as a swap destination - #863

Merged
romchornyi merged 2 commits into
masterfrom
fix/swap-reject-dash-destination-address
Jul 28, 2026
Merged

romchornyi merged 2 commits into
masterfrom
fix/swap-reject-dash-destination-address

Conversation

@romchornyi

@romchornyi romchornyi commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Issue being fixed or feature implemented

On Dash DEX → Sell DASH, the destination address must belong to the chosen destination coin (DASH itself is filtered out of the sell coin list). For loosely-validated chains — ADA, SOL, STRK, SUI, TON, TRON, XRP, ZEC — SwapAddressValidator fell through to a permissive default: return true branch and accepted a pasted Dash address. The order was then created and the Maya swap failed on-chain, surfacing to the user only as "Conversion failed".

What was done?

Reject a Dash mainnet Base58Check address (P2PKH X… / P2SH 7…, always 34 chars) up front in SwapAddressValidator.isValid for every non-Dash destination chain. The pattern matches only a genuine Dash address, so real destination addresses — including Solana — are unaffected. Added unit tests covering the guard and a non-regression check for legitimate destination addresses.

How Has This Been Tested?

  • Manual, on device: Sell DASH → SOL and USDC (SOL). Entering a Dash address is now blocked (Continue does not proceed); a real Solana address (9A7Nbez3va6r9Z6tG8cuPTcrMR8HfdHYMv2FUX3sQVDY) proceeds as before.
  • Unit tests in SwapAddressValidatorTests: Dash addresses rejected for default-branch chains (ZEC/XRP/TRON) and explicitly-validated chains (BTC/ETH/THOR); legitimate BTC/ETH/THOR destinations still valid.

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

Summary by CodeRabbit

  • Bug Fixes

    • Prevented Dash addresses from being incorrectly accepted when another destination network is selected.
    • Improved destination address validation across supported networks while preserving valid Bitcoin, Ethereum, and THOR addresses.
  • Tests

    • Added coverage for rejecting Dash addresses on incompatible networks.
    • Added checks confirming valid addresses for supported networks remain accepted.

When selling DASH, the destination address must belong to the chosen
coin (DASH is filtered out of the sell coin list). Loosely-validated
chains — ADA, SOL, STRK, SUI, TON, TRON, XRP, ZEC — fell through to the
permissive `default` branch in SwapAddressValidator, which accepted a
pasted Dash address. The order was created and the Maya swap then failed
on-chain, surfacing only as "Conversion failed".

Reject a Dash mainnet Base58Check address (P2PKH `X…` / P2SH `7…`, 34
chars) up front for every non-Dash chain. The pattern only matches a
genuine Dash address, so real destination addresses (incl. Solana) are
unaffected. Adds unit tests covering the guard and its non-regression.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 23, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@romchornyi, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 49 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0e89a3c6-a663-440d-b5df-3b7d39068d24

📥 Commits

Reviewing files that changed from the base of the PR and between cfdde69 and 8cfbdf8.

📒 Files selected for processing (1)
  • DashWalletTests/SwapAddressValidatorTests.swift
📝 Walkthrough

Walkthrough

Swap address validation now detects Dash mainnet P2PKH and P2SH addresses and rejects them for non-Dash destinations. Tests cover default and explicit validation paths plus valid BTC, ETH, and THOR addresses.

Changes

Dash address destination guard

Layer / File(s) Summary
Cross-chain guard and validation coverage
DashWallet/Sources/Models/Swap/SwapAddressValidator.swift, DashWalletTests/SwapAddressValidatorTests.swift
Dash mainnet address patterns are detected by prefix and length, rejected for non-Dash chains, and covered by rejection and non-regression tests.

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

Suggested reviewers: jeanpierreroma

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: rejecting Dash addresses as swap destinations.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/swap-reject-dash-destination-address

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.

@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 `@DashWalletTests/SwapAddressValidatorTests.swift`:
- Around line 143-155: The regression tests should exercise the default-branch
behavior rather than only validators that already reject Dash addresses. Update
testDashAddress_rejectedForExplicitlyValidatedChains or replace it with a
Solana/default-branch rejection case, and extend
testDashGuard_doesNotRejectLegitimateDestinationAddresses with a valid Solana
fixture and acceptance assertion. Use the existing Solana coin symbol and
validator API.
🪄 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 Plus

Run ID: 6a22de97-5821-4143-a1d9-123701dcb610

📥 Commits

Reviewing files that changed from the base of the PR and between 0bc4b5d and cfdde69.

📒 Files selected for processing (2)
  • DashWallet/Sources/Models/Swap/SwapAddressValidator.swift
  • DashWalletTests/SwapAddressValidatorTests.swift

@romchornyi romchornyi closed this Jul 23, 2026
@romchornyi romchornyi reopened this Jul 23, 2026
The previous explicit-chain assertions (BTC/ETH/THOR) passed even without
the guard, since those validators already reject Dash-shaped strings, so
they did not prove the new default-branch behavior. Replace them with SOL
coverage: a Dash address is rejected for SOL (a `default`-branch chain)
and a real Solana address is still accepted — the exact Sell DASH → SOL
scenario reproduced on device.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

@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 a941ce4 into master Jul 28, 2026
1 check passed
@romchornyi
romchornyi deleted the fix/swap-reject-dash-destination-address branch July 28, 2026 07:04
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