This improved version of pywallet features smart auto-detection - you only need to remember one command that automatically handles all wallet types and formats.
- Automatically detects wallet format (Berkeley DB, SQLite, damaged files)
- Chooses optimal method (fast extraction vs recovery)
- Seamless fallback when one method fails
- Clear explanations of what's happening and why
- One command for all scenarios
- No more confusion about which method to use
- Client-friendly - works with preferred command syntax
- Robust handling of edge cases
- β
Fixed Python 3 compatibility - Resolved
has_key()AttributeError - β Enhanced error handling - Robust Berkeley DB corruption handling
- β Segmentation fault fixes - Safe binary search with bounds checking
- β Multiple fallback strategies - Advanced β Binary Search β Raw Recovery
- β Corrupted wallet support - Handles damaged database files gracefully
- Version display at startup: Shows current version and website
- Output file headers include version and attribution information
- Clear attribution to original Jackjack's pywallet.py codebase
- Professional branding for client confidence
This version has been specifically tested and optimized for Ubuntu 24.04 and native Linux environments. Key improvements include:
- β Fixed PEP 668 compatibility - Works with Ubuntu's strict Python environment management
- β Proper virtual environment isolation - No more "externally-managed-environment" errors
- β
All required dependencies - Pre-configured with
bsddb3,ecdsa,pycryptodome - β Cross-platform compatibility - Works on both WSL and native Ubuntu
- β Enhanced error handling - Better diagnostics for Ubuntu-specific issues
# Make build script executable and run it
chmod +x install.sh
./install.sh# Install system dependencies (Ubuntu/Debian)
sudo apt-get update
sudo apt-get install libdb-dev python3-dev build-essential python3-venv libssl-dev libffi-dev
# Create virtual environment (with proper isolation)
python3 -m venv pywallet_build_env --clear
source pywallet_build_env/bin/activate
# Install Python dependencies
pip install --upgrade pip
pip install bsddb3 ecdsa pycryptodome
# Test installation
python3 -c "import bsddb3; import ecdsa; import Crypto; print('β All dependencies working!')"| Feature | WSL | Native Ubuntu 24.04 |
|---|---|---|
| Python Environment | More permissive | PEP 668 enforced |
| Package Installation | Allows global installs | Requires proper venv |
| Virtual Environment | Sometimes broken | Needs explicit setup |
| Dependencies | Often pre-installed | Manual installation required |
| Performance | Good | Excellent |
β This version works perfectly on both!
./run_pywallet.sh --recover --recov_device=PATH_TO_WALLET --output_keys=output_file.txtThat's it! The system automatically:
- π Analyzes your wallet file or device
- π― For .dat files: Tries targeted extraction first (fast method)
- β‘ Smart fallback: Falls back to traditional recovery if needed
- π§ For devices/raw data: Uses traditional recovery method
- π Explains what it's doing and why
The --recover command now works with ANY wallet type:
- Rwallet/wallet5.dat β Automatically uses targeted extraction
- regular/wallet.dat β Tries targeted first, then traditional recovery
- corrupted/wallet.dat β Graceful fallback to recovery mode
- /dev/sda1 β Traditional device recovery
- Any file or device β Automatically chooses the best method
./run_pywallet.sh --recover --recov_device=wallet.dat --output_keys=my_keys.txt./run_pywallet.sh --recover --recov_device=RWT/wall.dat --output_keys=targeted_results.txt./run_pywallet.sh --recover --recov_device=xtest/xtest1/wallet.dat --output_keys=recovered_keys.txt./run_pywallet.sh --recover --recov_device=/dev/sda1 --recov_size=100MB --output_keys=recovered_keys.txtπ All examples use the SAME command format! No more confusion about which method to use.
π SMART RECOVERY - Analyzing target...
============================================================
π SMART WALLET DETECTION
============================================================
You used --recover command on: wallet.dat
Auto-analyzing to choose the best extraction method...
Testing if wallet file is intact...
β
Wallet integrity OK - Format: advanced
β
WALLET IS INTACT - Using Advanced Extraction
============================================================
π― RECOMMENDATION: Your wallet file is complete and undamaged.
Using FAST advanced extraction instead of slow recovery.
This will get you ALL keys efficiently!
π Enter the wallet password (or press Enter for default '1234'):
Password: [your_password]
β‘ Method: Advanced Extraction (FAST & COMPLETE)
β WALLET APPEARS DAMAGED - Using Recovery Method
============================================================
π§ Your wallet file appears corrupted or damaged.
Using traditional recovery method to scan for key fragments.
This will be slower but may recover partial data.
β οΈ Advanced extraction failed: [technical error]
π Automatically falling back to traditional recovery method...
Using password from previous attempt: [password]
Starting recovery.
β
SUCCESS! 202 unique keys recovered
π Keys saved to: recovered_keys.txt
Every time you run the script, you'll see the version information:
Pywallet 2.3-gsc - https://pywallet.org
π SMART RECOVERY - Analyzing target...
All generated files include version attribution:
# Recovered private keys
# Data extracted by: Pywallet 2.3-gsc - https://pywallet.org
# Generated by pywallet recovery
# Format: private keys in both hex and WIF formats
- β Multiple different commands for different wallet types
- β Users had to guess which command to use
- β Arguments about "correct" vs "wrong" commands
- β Manual fallback when methods failed
- β One command for all wallet types
- β Automatic detection and method selection
- β Smart fallback when methods fail
- β Clear explanations of what's happening
- β Client satisfaction - they use their preferred command
The smart detection automatically handles:
| Wallet Type | Format | Detection Method | Extraction Method |
|---|---|---|---|
| Bitcoin Core (old) | Berkeley DB | DB structure analysis | Advanced extraction |
| Bitcoin Core (new) | SQLite | File signature detection | Recovery parsing |
| Damaged/Corrupted | Any | Error fallback | Recovery scanning |
| Disk Images | Raw data | Size/device analysis | Recovery scanning |
| Backup Files | Various | Extension + content | Auto-detected method |
All recovered keys are saved in both HEX and WIF formats:
# Recovered private keys
# Generated by pywallet recovery
# Format: private keys in both hex and WIF formats
Key #1 (HEX): 3c9229289a6125f7fdf1885a77bb12c37a8d3b4962d936f7e3084dece32a3ca1
Key #1 (WIF): 5JA7QYoYKimso8jHZrUGDLLiqwEJa3uKyUQnpMcPyxP8jNG8acc
Key #2 (HEX): e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
Key #2 (WIF): 5Jbm9rrusXMYL8HqtVJWANrKZWGNgMXTYqN9VVvV71TjdphjRPR
...
--recover- Activates smart recovery mode--recov_device=PATH- Path to wallet file or device--output_keys=FILE- Output file for recovered keys
--recov_size=SIZE- Limit recovery size (auto-detected for files)- Examples:
100MB,2GB,500MB - Not needed for wallet files (auto-detected)
- Examples:
- Modern:
100MB,2GB,500MB - Legacy:
100Mo,2Gio(still supported)
- β Simple: Only one command to remember
- β Reliable: Automatic method selection
- β Transparent: Clear explanations of actions
- β Robust: Automatic fallback on failures
- β No arguments about which commands to use
- β Self-documenting process with clear output
- β Handles edge cases automatically
- β Client satisfaction through preference accommodation
Situation: Your wallet.dat file won't open in Bitcoin Core, shows corruption errors, or the application crashes when trying to load it.
Command:
# Standard Bitcoin Core location (Linux)
./run_pywallet.sh --recover --recov_device=~/.bitcoin/wallet.dat --output_keys=recovered_keys.txt
# Custom location
./run_pywallet.sh --recover --recov_device=/path/to/your/wallet.dat --output_keys=recovered_keys.txtWhat to Expect:
β WALLET APPEARS DAMAGED - Using Recovery Method
π§ Your wallet file appears corrupted or damaged.
Using traditional recovery method to scan for key fragments.
π Enter the wallet password: [enter your password]
β
SUCCESS! 47 unique keys recovered
Situation: Hard drive crashed, but you can still access some sectors. Wallet file may be partially readable.
Command:
# For damaged hard drive partition
./run_pywallet.sh --recover --recov_device=/dev/sda1 --recov_size=500MB --output_keys=recovered_keys.txt
# For damaged wallet file with known size issues
./run_pywallet.sh --recover --recov_device=/path/to/damaged/wallet.dat --output_keys=recovered_keys.txtWhat to Expect:
π SMART RECOVERY - Analyzing target...
β οΈ Advanced extraction failed: I/O error
π Automatically falling back to traditional recovery method...
β
Found 1 possible wallet
β
Found 23 possible encrypted keys
Situation: Very old wallet from early Bitcoin days, different database format.
Command:
./run_pywallet.sh --recover --recov_device=/path/to/old/wallet.dat --output_keys=old_wallet_keys.txtWhat to Expect:
β
Detected Berkeley DB wallet format (traditional Bitcoin Core)
β
WALLET IS INTACT - Using Advanced Extraction
β‘ Method: Advanced Extraction (FAST & COMPLETE)
β
SUCCESS! 1,247 unique keys recovered
Situation: Wallet is encrypted but you know the password. File may or may not be corrupted.
Command:
./run_pywallet.sh --recover --recov_device=/path/to/encrypted/wallet.dat --output_keys=decrypted_keys.txtWhat to Expect:
π Enter the wallet password (or press Enter for default '1234'):
Password: [enter your actual password]
β
Password accepted - decrypting keys...
β
SUCCESS! 89 unique keys recovered (decrypted)
π Security Note: Keys will be saved in unencrypted format in the output file!
Situation: You have several wallet files and want to recover from all of them.
Commands (run separately):
# Wallet 1
./run_pywallet.sh --recover --recov_device=wallet1.dat --output_keys=keys_wallet1.txt
# Wallet 2
./run_pywallet.sh --recover --recov_device=wallet2.dat --output_keys=keys_wallet2.txt
# Wallet 3
./run_pywallet.sh --recover --recov_device=backup/old_wallet.dat --output_keys=keys_backup.txtCombine Results:
# Merge all recovered keys (remove duplicates manually)
cat keys_wallet1.txt keys_wallet2.txt keys_backup.txt > all_recovered_keys.txtSituation: Wallet file is on external storage that may have connection issues.
Command:
# First, copy wallet to local drive for stability
cp /media/usb/wallet.dat ./wallet_backup.dat
# Then recover from local copy
./run_pywallet.sh --recover --recov_device=./wallet_backup.dat --output_keys=usb_wallet_keys.txtWhy: Reduces risk of I/O errors during recovery process.
Situation: Wallet file is unusually large, recovery might take a long time.
Command:
# Standard recovery (may take hours)
./run_pywallet.sh --recover --recov_device=/path/to/large/wallet.dat --output_keys=large_wallet_keys.txtWhat to Expect:
π SMART RECOVERY - Analyzing target...
No size specified. Using full file size: 524288000 bytes (500.0 MB)
β οΈ Large file detected - this may take several hours
π Processing... [progress indicators]
π‘ Tip: Run in screen or tmux session for long recoveries:
screen -S wallet_recovery
./run_pywallet.sh --recover --recov_device=large_wallet.dat --output_keys=keys.txt
# Press Ctrl+A, then D to detach
# Later: screen -r wallet_recovery to reattachThis is normal for wallet files:
No size specified. Using full file size: 933888 bytes (0.89 MB)
The system automatically detects the file size.
This triggers automatic fallback:
β οΈ Advanced extraction failed: [error details]
π Automatically falling back to traditional recovery method...
This is expected behavior for certain wallet formats.
The system now handles these gracefully with multiple recovery strategies:
DB open error: (22, 'Invalid argument -- BDB3037 file size not a multiple of the pagesize')
DB open error: (22, 'Invalid argument -- BDB2509 the log files from a database environment')
Solution: β Automatic fallback to binary search and raw recovery methods
# Make sure you have read access to the wallet file
chmod 644 /path/to/wallet.dat
# Or copy to a location you own
cp /path/to/wallet.dat ~/my_wallet_copy.dat
./run_pywallet.sh --recover --recov_device=~/my_wallet_copy.dat --output_keys=keys.txt# Check if file exists
ls -la /path/to/wallet.dat
# Find wallet files on system
find / -name "wallet.dat" 2>/dev/null
find ~ -name "*.dat" 2>/dev/null | grep -i wallet# Check progress (in another terminal)
ps aux | grep pywallet
top -p $(pgrep -f pywallet)
# If stuck, try with smaller size limit
./run_pywallet.sh --recover --recov_device=wallet.dat --recov_size=50MB --output_keys=keys.txtPossible causes:
- Wrong password: Try without password or different passwords
- File is not a wallet: Verify it's actually a Bitcoin wallet file
- Completely corrupted: File may be beyond recovery
- Wrong file: Make sure you're using the right wallet.dat
Solutions:
# Try without password
./run_pywallet.sh --recover --recov_device=wallet.dat --output_keys=keys.txt
# (Press Enter when prompted for password)
# Try with different common passwords
# Run the command and try: password, 123456, bitcoin, etc.
# Verify file type
file wallet.dat
hexdump -C wallet.dat | head -20Fixed: β
All AttributeError: 'dict' object has no attribute 'has_key' errors resolved
Fixed: β Added comprehensive safety checks to prevent crashes during binary search
This is handled automatically by the fallback system. The error is caught and recovery continues with an alternative method.
Every wallet recovery operation now generates a comprehensive diagnostic report for troubleshooting and remote debugging assistance.
Report Generation:
π Creating detailed diagnostic report: pywallet_report_20250710_201505.log
Diagnostic report saved to: pywallet_report_20250710_201505.log
You can share this file for remote debugging assistance.
Each diagnostic report includes:
- π§ System Information: OS, Python version, memory, disk space
- π Wallet File Analysis: File size, type, permissions, integrity checks
- β‘ Command Details: Exact command executed, parameters used
- π Error Patterns: Detected issues, segmentation faults, database errors
- π Performance Metrics: Processing time, memory usage
- π οΈ Recovery Statistics: Keys found, encryption status, success rates
PYWALLET DIAGNOSTIC REPORT
========================
Timestamp: Thu Jul 10 08:15:05 PM MSK 2025
Command: ./run_pywallet.sh --recover --recov_device=wallet.dat --output_keys=keys.txt
Exit Code: 0
SYSTEM INFORMATION:
-------------------
OS: Linux ubuntu-desktop 6.11.0-29-generic
Python: Python 3.12.3
Memory: 16.0Gi total, 4.6Gi available
Disk Space: 47G available
WALLET FILE ANALYSIS:
--------------------
File: wallet0708/wallet.dat
Size: 11411456 bytes (10.88 MB)
Type: Berkeley DB (Btree, version 9, native byte-order)
Permissions: -rw-r--r--
Encryption: Encrypted (master key detected)
RECOVERY RESULTS:
-----------------
Keys Extracted: 1998 unique keys
WIF Keys Generated: 3996 total
Success Rate: 100%
Method Used: Binary recovery with master key decryption
- For Remote Support: Share the
.logfile with support team - For Self-Diagnosis: Review error patterns and suggestions
- For Multiple Attempts: Compare different recovery runs
- For Performance Analysis: Monitor system resource usage
# List all diagnostic reports
ls -la pywallet_report_*.log
# View latest report
cat $(ls -t pywallet_report_*.log | head -1)
# Clean old reports (keep last 5)
ls -t pywallet_report_*.log | tail -n +6 | xargs rm -f-
π Backup Original: Always copy your wallet.dat before recovery
cp wallet.dat wallet_backup_$(date +%Y%m%d).dat -
π Go Offline: Disconnect from internet during recovery for maximum security
-
π₯οΈ Clean Environment: Use a dedicated, clean computer if possible
- π Secure Terminal: Make sure no one can see your screen when entering passwords
- π No Screenshots: Never take screenshots of private keys
- π« No Cloud Storage: Don't save recovery files to cloud services
-
π₯ Secure Deletion: Securely delete recovery files after importing keys
shred -vfz -n 3 recovered_keys.txt
-
π New Wallet: Import keys into a new, secure wallet immediately
-
πΈ Move Funds: Transfer funds to a new wallet with fresh keys
-
π§Ή Clean Up: Clear terminal history and temporary files
# Bitcoin Core
bitcoin-cli importprivkey "your_WIF_key_here" "label" false
# Electrum
# Use: Wallet β Private Keys β Import- Python: 3.6 or higher
- OS: Linux, macOS, Windows (with WSL)
- Memory: Minimum 1GB RAM (more for large recoveries)
- Storage: Space for output files
./run_pywallet.sh --recover --recov_device=wallets/wallet1.dat --output_keys=keys.txtResult: β Fast extraction, 2001 keys recovered in 30 seconds
./run_pywallet.sh --recover --recov_device=xtest/xtest1/wallet.dat --output_keys=keys.txtResult: β Auto-fallback to recovery, 202 keys recovered from SQLite format
./run_pywallet.sh --recover --recov_device=/dev/sda1 --recov_size=500MB --output_keys=keys.txtResult: β Deep scan recovery, partial key recovery from damaged sectors
- Issue:
AttributeError: 'dict' object has no attribute 'has_key' - Solution: Replaced deprecated
has_key()method with Python 3 compatibleinoperator - Impact: Tool now works properly with Python 3.x
- Issues:
BDB3037 file size not a multiple of the pagesizeBDB2509 the log files from a database environmentBDB0210 metadata page checksum error
- Solution: Multi-strategy database opening with graceful fallback
- Impact: Corrupted wallets now process successfully instead of crashing
- Issue: Binary search causing crashes during key extraction
- Solution: Comprehensive bounds checking and safe data parsing
- Impact: Stable operation even with severely corrupted wallet data
- Enhancement: Three-tier recovery strategy
- Advanced Extraction (fastest, for intact wallets)
- Binary Search (medium speed, for corrupted DB files)
- Raw Recovery (slowest, for severely damaged files)
- Impact: Maximum key recovery success rate
Before Fixes:
β AttributeError: 'dict' object has no attribute 'has_key'
β DB open error: file size not a multiple of the pagesize
β Segmentation fault (core dumped)
After Fixes:
β
Detected Berkeley DB wallet format (traditional Bitcoin Core)
β
Advanced extraction failed, falling back to recovery method...
β
Found 1 possible wallet
β
Found 7 possible encrypted keys
β
Recovery completed successfully
| Issue Type | Status | Solution |
|---|---|---|
| Python 3 Compatibility | β FIXED | has_key() β in operator |
| Berkeley DB Corruption | β HANDLED | Multi-strategy opening |
| Segmentation Faults | β PREVENTED | Bounds checking |
| Fallback Mechanism | β ENHANCED | 3-tier recovery |
| Error Messages | β IMPROVED | Clear user feedback |
Common Parameter Confusion Resolved:
| β Previous Issues | β Now Fixed |
|---|---|
--output_keys=file.txt (didn't work) |
--output_keys=file.txt β
WORKS |
--keys=file.txt (only option) |
Both --keys= and --output_keys= work |
| Confusing error messages | Clear parameter validation |
Both parameter formats now work:
# Either of these work identically:
./run_pywallet.sh --recover --recov_device=wallet.dat --output_keys=keys.txt
./run_pywallet.sh --recover --recov_device=wallet.dat --keys=keys.txtKey Improvements for Ubuntu Users:
- β PEP 668 Compliance: Fixed "externally-managed-environment" errors
- β Proper Virtual Environment: Isolated Python environment that actually works
- β
All Dependencies:
bsddb3,ecdsa,pycryptodomeproperly installed - β Cross-Platform: Works on both WSL and native Ubuntu
- β Performance: Better performance on native Ubuntu vs WSL
If you're moving from WSL to Ubuntu:
-
Old WSL setup (might have issues):
# WSL was more permissive pip install package # worked globally
-
New Ubuntu setup (properly isolated):
# Ubuntu requires proper virtual environment python3 -m venv pywallet_build_env --clear source pywallet_build_env/bin/activate pip install package # works in venv
β This version handles both environments seamlessly!
| Environment | Status | Notes |
|---|---|---|
| WSL Ubuntu | β Working | Backward compatible |
| Ubuntu 22.04 | β Working | Tested |
| Ubuntu 24.04 | β Working | Optimized |
| Debian 12 | β Working | Compatible |
| Linux Mint | β Working | Ubuntu-based |
One command. All wallet types. Smart detection. Automatic fallback. Rock-solid stability. Perfect Ubuntu compatibility.
That's the power of smart pywallet - eliminating complexity while maximizing results, now with enterprise-grade reliability for corrupted wallet recovery and seamless Ubuntu 24.04 support.