feat: bip85 alias, revoke, activate, copy and UI improvements - #1639
Conversation
…ntities instead of paths
…nd integrate them into the locator and widget
|
@claude please review this PR |
|
Claude finished @leesalminen's task in 2m 28s —— View job Code Review for PR #1639 ✅I've completed a thorough review of the BIP85 alias, revoke, activate, copy and UI improvements feature. Overall, the implementation is well-structured and follows clean architecture principles. Here are my findings: ✅ Strengths
🔴 Critical Issues1. Security Risk: Sensitive Data Exposure in Widget (lib/core/widgets/bip85_derivation_widget.dart:67-70)final data = bip85.Bip85Entropy.deriveFromHardenedPath(
xprvBase58: widget.xprvBase58,
path: bip85.Bip85HardenedPath(widget.derivation.path),
);Problem: The sensitive entropy data is re-derived on every widget rebuild. This is inefficient and exposes the master xprv to the widget layer unnecessarily. Recommendation: Consider deriving the entropy once in the cubit/use case layer and passing it as a parameter, or cache it to avoid repeated derivations. 2. Widget State Not Updated After Alias Change (lib/core/widgets/bip85_derivation_widget.dart:46-50)Future<void> _saveAlias() async {
if (widget.onAliasChanged != null) {
await widget.onAliasChanged!(widget.derivation, _aliasController.text);
setState(() => _isEditingAlias = false);
}
}Problem: When the alias is saved, the widget exits edit mode but still displays the old alias text from Current Flow:
Issue: The 🟡 Major Issues3. Missing Error Handling in Widget Callbacks (lib/core/widgets/bip85_derivation_widget.dart:46-63)The async callback methods ( Recommendation: Wrap in try-catch and show user-friendly error messages via SnackBar or similar. 4. Unnecessary Try-Catch with RethrowMultiple locations just catch and rethrow without adding value:
Recommendation: Remove these unnecessary try-catch blocks since they don't transform or log errors. Let exceptions propagate naturally. 5. Loading State Management Issue (lib/features/bip85_entropy/presentation/cubit.dart:60-64)Future<void> fetchAllDerivations() async {
emit(state.copyWith(isLoading: true));
final derivations = await _fetchAllBip85DerivationsUsecase.execute();
emit(state.copyWith(derivations: derivations, isLoading: false));
}Problem: This method is called from Recommendation: Consider making 6. Potential Memory Leak (lib/core/widgets/bip85_derivation_widget.dart:157)child: TextField(
controller: TextEditingController(text: data),
obscureText: _isObscured,
readOnly: true,
...
),Problem: Creating a new Recommendation: Either use a managed controller or use the 🟢 Minor Issues / Suggestions7. Inconsistent Error Handling in AliasBip85DerivationUsecase (lib/core/bip85/domain/alias_bip85_derivation_usecase.dart:10-15)This use case doesn't wrap the call in try-catch, while Recommendation: Be consistent - either all use cases handle errors or none do. 8. Missing Input Validation for Alias (lib/core/bip85/data/bip85_datasource.dart:146-154)The alias can be set to any string, including empty strings or extremely long strings. Recommendation: Add validation for alias length and content (e.g., max 50 characters, no special characters if needed). 9. UI: Cramped Header Row (lib/core/widgets/bip85_derivation_widget.dart:85-110)The header row displays path, application, status, and action buttons all in one row with Recommendation: Consider a more responsive layout, perhaps wrapping text or using a Column for better spacing. 10. No Confirmation Dialog for Revoke (lib/core/widgets/bip85_derivation_widget.dart:53-57)Revoking a derivation is a significant action but has no confirmation dialog. Recommendation: Add a confirmation dialog before revoking to prevent accidental revocations. 11. Hard-Coded SnackBar Text (lib/core/widgets/bip85_derivation_widget.dart:176)content: Text('Copied to clipboard'),Recommendation: Use localized strings from 12. Loading Indicator Positioning (lib/features/bip85_entropy/bip85_home_page.dart:27-29)The Recommendation: Simplify the trigger to just 📝 Code Quality Observations
🧪 Testing Recommendations
📋 SummaryApprove with Changes: This PR adds valuable functionality and follows good architectural patterns. However, the critical issues (especially #1 and #2) should be addressed before merging. The major issues are important for robustness but could be addressed in a follow-up PR if needed. Priority fixes:
|
5599a92 to
1aa1954
Compare
…and update state management to handle derivations with entropy
Closes #1629
Closes #1212