Skip to content

Fix: Auto-register wallet for existing users#219

Draft
TaprootFreak wants to merge 3 commits intodevelopfrom
feature/auto-wallet-registration
Draft

Fix: Auto-register wallet for existing users#219
TaprootFreak wants to merge 3 commits intodevelopfrom
feature/auto-wallet-registration

Conversation

@TaprootFreak
Copy link
Copy Markdown
Contributor

Bug

When a user has multiple wallets or creates a new wallet, they may encounter the "Registrierung erforderlich" (Registration required) error on the Buy page, even though they already have completed registration with another wallet.

Root cause: Registration in the DFX system works on two levels:

  • Account level: User data (name, address, email, etc.) - stored once per user
  • Wallet level: Each wallet must be individually registered with DFX

When a user with existing account data tries to buy with a new/unregistered wallet, the API returns REGISTRATION_REQUIRED. Previously, the app would show an error message and require the user to manually go through the KYC/registration flow again - even though all their data is already in the system.

Solution

When the REGISTRATION_REQUIRED error is returned:

  1. Check if user data already exists via getWalletStatus()
  2. If userData exists → automatically call registerWallet() to register the current wallet
  3. If successful → retry getting payment info (seamless UX)
  4. If no user data exists or registration fails → fall back to showing the original error

This provides a seamless experience for existing users adding new wallets.

Changes

  • BuyPaymentInfoCubit: Added _tryAutoRegisterWallet() method that attempts automatic wallet registration
  • BuyPage: Added required service dependencies
  • Tests: Updated mocks for new dependencies

Test plan

  • Existing user with registered wallet: Buy flow works as before
  • Existing user with new/unregistered wallet: Wallet is auto-registered, buy flow continues without interruption
  • New user without account data: Shows "Registrierung erforderlich" as before

When a user already has account data but the current wallet is not
registered, automatically register the wallet in the background
instead of showing the "Registrierung erforderlich" error.
@TaprootFreak TaprootFreak marked this pull request as ready for review March 27, 2026 10:51
@TaprootFreak TaprootFreak requested a review from xlamn March 27, 2026 11:47
Copy link
Copy Markdown
Collaborator

@xlamn xlamn left a comment

Choose a reason for hiding this comment

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

Wrong approach by claude. Wait for #218 and then I do it myself.

@TaprootFreak TaprootFreak marked this pull request as draft March 30, 2026 13:03
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.

2 participants