Wallet Generation Update - Step 7
Overview
The cold wallet USB flash process now includes a 7th step that automatically generates the keypair and wallet during the flash process, making the USB drive ready for transactions immediately upon mounting.
What Changed
Previous Behavior (6 Steps)
- Download Alpine Linux minirootfs
- Extract filesystem
- Configure offline OS
- Configure Python environment
- Create bootable image
- Flash to USB drive
The wallet was NOT generated - users had to:
- Boot from the USB on an air-gapped device
- Run the wallet generation script manually
- Or create the wallet separately after mounting
New Behavior (7 Steps)
- Download Alpine Linux minirootfs
- Extract filesystem
- Configure offline OS
- Configure Python environment
- Create bootable image
- Flash to USB drive
- Generate keypair and wallet on USB ✨ NEW!
The wallet IS NOW generated automatically - when the drive is mounted, it's ready to:
- Receive SOL immediately (public key is available)
- Sign transactions (private key is encrypted and stored on USB)
- No additional setup required
Features of Step 7
Automatic Wallet Generation
- Generates a new Solana keypair using
solders - Creates both
keypair.json(encrypted) andpubkey.txtfiles - Stores them in the
/walletdirectory on the USB
Security Features
- Password Protection: Prompts for a password during the flash process
- Encryption: Uses
SecureWalletHandlerto encrypt the private key - Memory Safety: Clears keypair from memory immediately after saving
- Secure Permissions: Sets appropriate file permissions (0o600 for keypair)
User Experience
- Displays the public key (wallet address) at the end of the flash process
- Shows a clear visual panel with the wallet address
- Provides instructions for next steps
- Warns users to write down/photograph the address
Overwrite Protection
- Checks if a wallet already exists on the USB
- Prompts for confirmation before overwriting
- Allows users to keep existing wallets
Technical Implementation
Key Files Modified
src/iso_builder.py
- Added
_generate_wallet_on_usb()method - Updated
_flash_to_usb_windows()to call Step 7 - Updated
_flash_to_usb_linux()to call Step 7 - Updated all step counts from 6 to 7
- Added
self.generated_pubkeyto store the generated address
main.py
- Updated flash process description to mention wallet generation
- Added display of generated public key after successful flash
- Updated step counter from 6 to 7
- Enhanced success messaging with wallet information
Code Flow
# Step 7: Generate wallet on USB
def _generate_wallet_on_usb(self, mount_point: str) -> bool:
1. Check if wallet already exists
2. Generate new Solana keypair
3. Prompt for encryption password
4. Encrypt keypair using SecureWalletHandler
5. Save encrypted keypair.json
6. Save public key to pubkey.txt
7. Set secure file permissions
8. Clear keypair from memory
9. Display public key to user
10. Store pubkey for later display
Dependencies
solders: Solana SDK for keypair generationsrc.secure_memory: SecureWalletHandler for encryptionsrc.ui: get_password_input and UI functions
User Workflow
Before (Manual Wallet Creation)
1. Flash USB drive (6 steps)
2. Mount USB on computer
3. Navigate to wallet directory
4. Run wallet generation script manually
5. Set password and generate keys
6. Now ready for transactions
After (Automatic Wallet Creation)
1. Flash USB drive (7 steps, includes wallet generation)
2. Mount USB on computer
3. ✅ Ready for transactions immediately!
Benefits
- Convenience: No manual wallet generation required
- Time Savings: One-step setup process
- User-Friendly: Less technical knowledge required
- Immediate Use: Can receive SOL right away
- Secure: Same encryption and security as manual generation
- Flexible: Can still overwrite or use existing wallets
Security Considerations
✅ Maintains Security
- Password-protected encryption still required
- Private key never exposed to memory longer than necessary
- Secure file permissions automatically set
- Works with existing SecureWalletHandler module
⚠️ Important Notes
- Password must be remembered - cannot recover funds without it
- Write down public key - needed to receive SOL
- Keep USB secure - contains encrypted private key
- Use offline for signing - never sign on internet-connected machines
Testing Recommendations
- Flash a test USB and verify wallet files are created
- Check encryption - ensure keypair.json is encrypted
- Verify public key - confirm it's saved correctly in pubkey.txt
- Test transactions - try receiving and sending SOL
- Password protection - verify password prompts work correctly
- Overwrite protection - test with existing wallet on USB
Compatibility
- ✅ Windows: Full support (uses PowerShell for drive detection)
- ✅ Linux: Full support (uses mount points)
- ✅ macOS: Should work (uses Unix-like mount points)
Future Enhancements
Potential improvements for future versions:
- Option to skip wallet generation (keep it manual)
- Support for generating multiple wallets
- Backup wallet to secondary location during flash
- QR code generation for easy public key sharing
- Mnemonic phrase generation for recovery
Troubleshooting
Wallet generation fails during flash
- Check that
soldersis installed:pip install solders - Verify
src.secure_memorymodule is available - Ensure sufficient permissions on USB drive
Password prompt doesn't appear
- Check terminal supports interactive input
- Verify
src.ui.get_password_inputis working
Public key not displayed
- Check
self.generated_pubkeyis being set - Verify the flash process completed successfully
Summary
The addition of Step 7 transforms the cold wallet USB creation process from a multi-stage setup to a single-command solution. Users can now flash a USB drive and immediately have a fully functional, encrypted cold wallet ready to receive and send SOL - all in one seamless operation.
B - Love U 3000 💙