Add Wallet Data Export/Import Functionality#188
Open
sozidatel wants to merge 15 commits into
Open
Conversation
- Add data export dialog in settings with security warnings - Implement export function that collects: * Account data (name, publicKey, privateKey/encryptedPrivateKey) * Token preferences per account (converted to CODE-ISSUER format) * Saved contacts/address book - Support encrypted private keys for password-protected accounts - Export as JSON file with version and timestamp - Add Russian and English translations - Remove internal account IDs from export (use publicKey as identifier) - Preserve account order in export for future import sorting
- Add reliable encrypted key export from storage - Support encrypted private keys in import (base64 decoding) - Add cross-platform storage access function - Improve error handling for encrypted key operations - Add logging for export key types - Remove dependency on createAccount for import - Use direct key store operations for better reliability
- Add encryptionMetadata to ExportedAccount interface - Export nonce and iterations for encrypted keys - Restore encrypted keys with proper metadata structure - Use direct localStorage manipulation for encrypted key import - Preserve original encryption parameters for password compatibility
- Add refreshAccounts function to AccountsContext - Automatically refresh account list after successful import - No need to reload app to see imported accounts - Improves user experience by showing changes immediately
- Merge encryptionMetadata into encryptedPrivateKey object - Cleaner data structure with data, nonce, and iterations fields - Simplified export/import logic - Better encapsulation of encryption-related data
- Use accountID instead of publicKey in export for cosigner accounts - Properly handle cosignerOf field in import logic - Fix account lookup to use accountID for both regular and cosigner accounts - Ensure token preferences are saved with correct accountID - Support cosigner accounts where private key belongs to different account
- Reset file input value after processing to allow re-selecting same file - Add clear button to reset dialog state after errors/success - Better user experience for retrying imports with corrected files - Prevents stuck state when same file is selected multiple times
- Add automatic redirect to main page after successful import - Add 'Go to accounts' button for manual navigation - Ensure imported accounts are visible on main screen - Better user experience after import completion - Automatic redirect with 2-second delay to show success message
- Remove 'Go to accounts' button and automatic redirect - Remove 'Clear' button - auto-clear on new file selection - Add automatic page reload after successful import to ensure accounts appear - Simplify dialog interface with better user experience - Fix issue where imported accounts don't show without manual refresh
- Remove window.location.reload() to avoid confusing user experience - Add custom 'accountsUpdated' event dispatch after import - Add event listener in AllAccountsPage to refresh accounts - Preserve user's view of import results while updating account list - Better UX without full page reload
- Add refreshKey state to AccountsContext for forced re-rendering - Update refreshAccounts to increment refreshKey after loading accounts - Use refreshKey as key prop for AccountList to force re-render - Remove custom event approach in favor of React key mechanism - Ensure imported accounts appear immediately without page reload - Follow same pattern as account creation/deletion for consistency
- Add export/import dialogs in settings - Support both regular and encrypted private keys - Handle cosigner accounts correctly - Export account data, token preferences, and contacts - Import with conflict resolution for existing data - Add Russian and English translations - Use standard createAccount API for better React state management
- Add German, Spanish, Italian, Serbian (Cyrillic and Latin) translations - Complete localization support for all supported languages - Maintain consistency with existing translation patterns
- Replace all hardcoded Russian comments with English equivalents - Maintain code functionality while improving internationalization - Prepare codebase for international contributors
troggy
reviewed
Jan 8, 2026
| async function getEncryptedKeysFromStorage(): Promise<any> { | ||
| // In web environment use localStorage | ||
| if (typeof localStorage !== 'undefined') { | ||
| const rawKeys = localStorage.getItem("sunce:keys") |
Contributor
There was a problem hiding this comment.
это не работает для десктопного приложения. В экспорте не будет ключей.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements comprehensive wallet data export/import functionality, allowing users to backup and restore their wallet data across devices.
Features Added
Export Functionality:
Export all accounts with names, keys, and token preferences
Export contacts/address book
Support for both regular and encrypted private keys
Support for cosigner accounts
JSON file download with secure data structure
Import Functionality:
Smart conflict resolution for existing accounts
Preserve existing account names while updating token preferences
Import new contacts and update existing ones
Full support for encrypted keys with metadata
Detailed import reports with success/error statistics
User Interface:
New settings menu items for export/import
Dedicated dialogs with clear instructions and warnings
Progress indicators and error handling
File selection with validation
Technical Implementation
Data Structure:
Versioned export format with metadata
Consolidated encrypted key structure (data, nonce, iterations)
Token preference format conversion (ISSUER:CODE ↔ CODE-ISSUER)
Support for cosigner account relationships
Account Management:
Direct localStorage manipulation for encrypted keys
Standard createAccount API for regular keys
refreshKey mechanism for account list updates
Conflict resolution without data loss
Internationalization:
Complete translations for all supported languages (EN, RU, DE, ES, IT, SR-Cyrl, SR-Latn)
Replaced all hardcoded Russian comments with English
Consistent translation patterns
Security Considerations
Private keys are included in exports (user responsibility)
Clear warnings about data confidentiality
Secure file handling and validation
No data transmission - local operations only
Files Changed
New Components: DataExportDialog.tsx, DataImportDialog.tsx
Core Logic: export-data.ts (413 lines of export/import logic)
UI Integration: Settings menu, routing, context updates
Translations: 7 language files with complete localization
Account Management: Enhanced context with refresh mechanisms