feat(wallet): validate wallet name and allow import renaming#2792
feat(wallet): validate wallet name and allow import renaming#2792
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughAdds wallet-name validation and rename prompt across wallet handling and import flows, introduces a reusable wallet rename dialog, and adds related English translation strings. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant U as User
participant WM as Wallet Flow (Manager/Import)
participant WR as WalletsRepository
participant RD as Rename Dialog
U->>WM: Start open/import wallet
WM->>WR: validateWalletName(proposedName)
WR-->>WM: error or ok
alt Name invalid/in use
WM->>RD: walletRenameDialog(initialName)
RD-->>WM: newName or null
opt If newName provided
WM->>WR: validateWalletName(newName)
WR-->>WM: ok
WM->>WM: Apply newName
end
opt If canceled (null)
WM->>U: Abort operation
end
else Name valid
WM->>WM: Proceed with flow
end
Note over WM: If proceeding, continue to login/import logic
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
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 |
|
Visit the preview URL for this PR (updated for commit e162ca3): https://walletrc--pull-2792-merge-ayliimy4.web.app (expires Thu, 02 Oct 2025 15:50:11 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: f66a4ff03faa546f12f0ae5a841bd9eff2714dcc |
|
As with the weak passwords, we need to ensure that older wallets which may include these chars are not affected. The only way to really do this is via a settings config param. Does this affect diacritical marks or non-latin chars (e.g. Cyrillic, Coptic, Runes, Cuneiform etc)? I am certain some users do use their native script for wallet names. |
@smk762 We should be fine to enforce this only for new wallets. KDF does not enforce the wallet name policy for wasm, and currently, we do not have a production-deployed version of the native app (users will have to import seed manually). Is native desktop seed file export cross-compatible with KW web seed import? |
It is not. For reference, the legacy desktop necrypt / decrypt code is in https://github.com/KomodoPlatform/komodo-wallet-desktop/blob/dev/src/core/atomicdex/utilities/security.utilities.cpp#L74-L139 |
This comment was marked as off-topic.
This comment was marked as off-topic.
…into codex/add-wallet-name-validation
|
@takenagain, please take this over and see it through to completion. If it needs anything beyond minor tweaks, please close this PR and create your own. |
early return skipped the new wallet renaming dialog, preventing it from appearing
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
fixes "setState() or markNeedsBuild() called when widget tree was locked. This ScreenshotSensitivity widget cannot be marked as needing to build because the framework is locked." and "DartError: setState() or markNeedsBuild() called during build. This ScreenshotSensitivity widget cannot be marked as needing to build because the framework is already in the process of building widgets. A widget can be marked as needing to be built during the build phase only if one of its ancestors is currently building. This exception is allowed because the framework builds parent widgets before children, which means a dirty descendant will always be built. Otherwise, the framework might not visit this widget during this build phase."
Final issue I can see: When renaming wallet, though validation triggers on exact match, a trailing space passes. We should avoid allowing leading or trailing spaces in wallet names as it could lead to user input fails and confusion. After import of the same name wallet (with extra space), and logging out, there was only instance of the wallet name - so I assume trimming is applied before saving - and if so, this may result in an overwrite of the existing wallet. This bug also exists in the create/import wallet form's wallet name input field. Request that validation in rename form and create/import wallet form be performed with trimmed input. vokoscreenNG-2025-09-24_22-45-48.mp4 |
|
@cursor find all bugs introduced in this PR. |
|
I've thoroughly reviewed the PR context, including the description, comments, and the code changes themselves. Based on this, I've identified several bugs and potential issues introduced by this pull request:
Additionally, I noted an optional heads-up regarding the parsing of wallet names from file data using Learn more about Cursor Agents |
Co-authored-by: charl <charl@vanstaden.info>
|
@smk762, please test the fixes for the issues mentioned in #2792 (comment) to the extent you reasonably can |
There was a problem hiding this comment.
-
Trimmed vs. Untrimmed Name Mismatchtrims as expected -
Inconsistent Validation Rule in UI CopyPedantic technicality. IMO, fine as is. -
using split('.').first, which can truncate names unexpectedly and increase collision risk- with.not allowed, this split should not truncate. -
Missing Re-validation After Renamehighly unlikely another user/process will modify the specific file in question. -
Duplicate Check Ignores Legacy Wallets, Silent Duplicate Validation Skipunable to test in web, as CI url holds no cache. Linux desktop had more prior imported wallets, and none of the older ones had an issues with being ignored with duplicate checks. -
BuildContext Usage After Awaits: In the wallet import flow, BuildContext is used after await calls without proper mounted checks, and linting suppressions are used instead of fixing the underlying issue. This can lead to exceptions if the widget is disposed before the await completes.Not sure how to confirm/test this, seems to be more of a code review thing. If there is a test case to cover this, please let me know.
Additionally I tested re-importation of a seed file without renaming, after deleting wallet from login menu. Confirmed that this does not trigger a rename, and imports as usual, without needing to restart app.
Approving as fit for purpose, with caveats to perform further testing and/or delegate to issues with any remaining minor niggles.
…plugin and add cupertino_icons to satisfy font requirements
…ache warm-ups - Remove cache warm-ups in wallet import and rename dialog - Keep validation using fresh repository fetches - Reverted unintended global formatting; formatted only edited files - No Bloc introduced (repo methods suffice)
TODO: More fixes of the same warning type (stale context)
…\n\n- Replace wallet.name assignment with copyWith + setState in iguana manager\n- Use wallet.copy() to avoid shared references during login flow\n- Avoid widget.wallet.config.type mutation; pass copied wallet to onLogin\n- Avoid mutating wallet.config.seedPhrase in downloadEncryptedWallet; use working copy\n\nKeeps immutability and consistent state updates in BLoC flows.
… rename - Combine validation and uniqueness checks before showing rename dialog - Remove duplicate uniqueness check after validation - Improves flow by avoiding unnecessary prompts when both checks fail

This pull request introduces functionality to validate and rename wallet names across multiple areas of the application. It adds a new dialog for renaming wallets, integrates wallet name validation logic, and updates relevant workflows to handle invalid wallet names gracefully.
This bug stems from the newly implemented wallet storage feature in KDF which restricts wallet name characters on native platforms. This would cause issues if user is logging into or importing a wallet from an older version of the app which no longer meets the wallet name requirements.
Wallet Name Validation Enhancements:
lib/blocs/wallets_repository.dart: Added logic to validate wallet names using a regular expression that allows only letters, numbers, underscores, and hyphens.assets/translations/en.json: Added new error messages and dialog text for wallet name validation and renaming.Wallet Rename Dialog Implementation:
lib/views/wallets_manager/widgets/wallet_rename_dialog.dart: Introduced a newwalletRenameDialogfunction to display a dialog for renaming wallets with validation feedback.Integration with Wallet Workflows:
lib/views/wallets_manager/widgets/iguana_wallets_manager.dart: Updated the wallet manager to validate wallet names and invoke the rename dialog for legacy wallets with invalid names.lib/views/wallets_manager/widgets/wallet_import_by_file.dart: Integrated wallet name validation and rename dialog into the wallet import workflow for handling invalid names derived from file data.Summary by CodeRabbit