Skip to content

fix(dashpay): fund contested identity with the contested denomination - #866

Merged
romchornyi merged 1 commit into
swift-sdk-integrationfrom
fix/bug-01-contested-username-funding
Jul 24, 2026
Merged

romchornyi merged 1 commit into
swift-sdk-integrationfrom
fix/bug-01-contested-username-funding

Conversation

@romchornyi

Copy link
Copy Markdown
Contributor

Issue being fixed or feature implemented

Registering a contested username via the Core / Platform-Payment funding path under-funded the new identity. DWIdentityRegistrationCoordinator.startCreateUsername hardcoded DWDP_MIN_BALANCE_TO_CREATE_USERNAME (0.03 DASH) for both .core and .platformPayment, ignoring whether the name is contested (which needs DWDP_MIN_BALANCE_FOR_CONTESTED_USERNAME = 0.25 DASH). The identity was created with ~0.03, then DPNS registration failed with Insufficient identity balance (~0.028 vs the ~0.2 DASH a contested name requires), spending funds and leaving a funded orphan identity with no name and no retry path. The .shielded path was unaffected — it already used the contested denomination.

What was done?

Compute the funding amount once, branching on isContested, and use it for both funding paths:

let requiredIdentityFundingDuffs = isContestedSubmission
    ? DWDP_MIN_BALANCE_FOR_CONTESTED_USERNAME   // 0.25 DASH
    : DWDP_MIN_BALANCE_TO_CREATE_USERNAME        // 0.03 DASH
  • .core → registerIdentityWithFunding(amountDuffs: requiredIdentityFundingDuffs, …)
  • .platformPayment → targetCredits = UInt64(requiredIdentityFundingDuffs) * creditsPerDuff
  • Moved the existing isContestedSubmission computation up (removing the later duplicate) and added a diagnostic log line (identityFundingDuffs=…).

How Has This Been Tested?

Manual smoke on testnet, on device (iPhone 17 Pro):

  • Before: contested via Core funded 0.03 → Insufficient identity balance → orphan identity, no name.
  • After: fresh wallet, contested Addda via Core → identity funded 0.25 (funding tx +0.25, identity bb732e81… balance 0.24878120), username registered, no error, no orphan.
  • Recommended follow-up: confirm non-contested via Core still funds 0.03 — preserved by the ternary; the non-contested Core path passed before this change.

(No automated test added — the unit-test target is currently broken; verified via testnet smoke per the repo's current verification standard.)

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

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

`startCreateUsername` hardcoded `DWDP_MIN_BALANCE_TO_CREATE_USERNAME` (0.03 DASH)
for the `.core` and `.platformPayment` funding paths, so a contested username
registered via transparent funding under-provisioned the new identity. DPNS
registration then failed with "Insufficient identity balance" (~0.028 vs the
~0.2 DASH the contested name requires), spending funds and leaving a funded
orphan identity with no name and no retry path.

Branch the funding amount on `isContested`
(`DWDP_MIN_BALANCE_FOR_CONTESTED_USERNAME` = 0.25 DASH) for both `.core` and
`.platformPayment`; the shielded path already used the contested denomination.

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

coderabbitai Bot commented Jul 24, 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 Plus

Run ID: 8adc1944-c33a-46d0-8240-076a3c9e6952

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 fix/bug-01-contested-username-funding

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 requested a review from llbartekll July 24, 2026 07:33

@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 e7eb5f3 into swift-sdk-integration Jul 24, 2026
1 check passed
@romchornyi
romchornyi deleted the fix/bug-01-contested-username-funding branch July 24, 2026 12:06
romchornyi pushed a commit that referenced this pull request Jul 24, 2026
Why:
- PR #866 changed contested identity funding while PR #867 had added the registration recovery branch in the same coordinator.

What:
- keep the interrupted-registration recovery flow intact
- fund new contested Core and Platform identities with the contested amount

Validation:
- xcodebuild dashpay for a generic iOS Simulator succeeded
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