Skip to content

fix(dashpay): recover an interrupted identity registration instead of double-charging - #867

Merged
romchornyi merged 2 commits into
swift-sdk-integrationfrom
fix/bug-02-registration-interruption-recovery
Jul 24, 2026
Merged

romchornyi merged 2 commits into
swift-sdk-integrationfrom
fix/bug-02-registration-interruption-recovery

Conversation

@romchornyi

Copy link
Copy Markdown
Contributor

Issue being fixed or feature implemented

An interrupted create-username flow (force-quit after the Core asset lock was broadcast but before the identity / DPNS name completed) was left stuck "Pending" forever with no resume path. Re-entering the flow was not blocked and did not resume — it started a fresh registration that:

  • stranded a second Core asset lock (double-charge), and
  • failed with SDK error: Drive internal error: … a unique key with that hash already exists once the first attempt had already registered the identity keys on Platform,

leaving a funded identity with no name and no retry path (P0).

What was done?

On re-entry, DWIdentityRegistrationCoordinator.startCreateUsername now detects a recoverable Core asset lock (RegistrationRecoveryLock, keyed by the persisted outpoint) and recovers instead of re-paying:

  • resumes the original asset lock via resumeIdentityWithAssetLock (no new payment);
  • skips IdentityCreate when the identity already exists locally or on Platform (handles the "unique key already exists" seam);
  • reconciles the consumed lock row to Consumed.

UI:

  • CreateUsernameViewModel.hasPendingRegistrationRecovery drives a "Finish your registration" banner ("Your previous payment was found. Continue to finish creating the identity and username without paying again."), the primary action becomes "Finish registration", and no second payment is requested.
  • The pending funding row on Home now reads "Pending — tap to finish".

Added DWRegistrationPhaseAdapterTests cases for the recovery phase mapping.

How Has This Been Tested?

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

  • Fresh wallet → start a Core-funded registration → force-quit during identity creation → relaunch.
  • Home history shows "Pending — tap to finish"; re-entering create-username shows the "Finish your registration" banner + "Finish registration" button with no payment prompt.
  • Completing it finishes the registration with no second asset lock (single funding deduction) and no "unique key already exists" error.

Known follow-up (out of scope here): the recovery persists only the asset-lock outpoint, not the intended username — so the name is re-typed on resume and could diverge from the original. No fund loss (the identity is name-independent); tracked as a separate P2/P3 to persist + pre-fill the intended label.

(No runnable automated test — the unit-test target is currently broken; the new DWRegistrationPhaseAdapterTests cases are compile-ready, verified via testnet smoke.)

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

… double-charging

When a create-username flow was interrupted (force-quit) after the Core asset
lock was broadcast but before the identity/DPNS name completed, the registration
was stuck "Pending" forever with no resume path. Re-entering the flow started a
fresh registration that stranded a second asset lock (double-charge) and failed
with "a unique key with that hash already exists" once the first attempt had
registered the identity keys on Platform — leaving a funded identity with no
name and no retry.

Detect a recoverable Core asset lock on re-entry (`RegistrationRecoveryLock`):
resume the original outpoint via `resumeIdentityWithAssetLock` (no new payment),
skip `IdentityCreate` when the identity already exists locally or on Platform,
and reconcile the consumed lock. The create-username screen surfaces this as a
"Finish your registration" banner + "Finish registration" action (no second
payment); the pending funding row reads "Pending — tap to finish".

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: 6a33c46e-4799-42d3-8df8-38979e19a1b5

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-02-registration-interruption-recovery

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 08:23

@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

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
@romchornyi
romchornyi merged commit 50cb57d into swift-sdk-integration Jul 24, 2026
1 check passed
@romchornyi
romchornyi deleted the fix/bug-02-registration-interruption-recovery branch July 24, 2026 12:21
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