Repository navigation
fix(wallet): reject a Dash address as a swap destination - #863
Conversation
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]>
|
Warning Review limit reached
Next review available in: 49 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughSwap 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. ChangesDash address destination guard
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
There was a problem hiding this comment.
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
📒 Files selected for processing (2)
DashWallet/Sources/Models/Swap/SwapAddressValidator.swiftDashWalletTests/SwapAddressValidatorTests.swift
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]>
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 —
SwapAddressValidatorfell through to a permissivedefault: return truebranch 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…/ P2SH7…, always 34 chars) up front inSwapAddressValidator.isValidfor 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?
9A7Nbez3va6r9Z6tG8cuPTcrMR8HfdHYMv2FUX3sQVDY) proceeds as before.SwapAddressValidatorTests: Dash addresses rejected fordefault-branch chains (ZEC/XRP/TRON) and explicitly-validated chains (BTC/ETH/THOR); legitimate BTC/ETH/THOR destinations still valid.Breaking Changes
None.
Checklist:
Summary by CodeRabbit
Bug Fixes
Tests