A fast cryptocurrency CLI tool implemented in Rust
Project description
Coinwagon
🪙 Coinwagon
A fast, reliable Python package for cryptocurrency operations built with Rust. Get real-time prices, check wallet balances, and manage multiple addresses with ease.
✨ Features
- 🚀 Fast: Built with Rust for maximum performance
- 💰 Real-time Prices: Get current cryptocurrency prices in multiple fiat currencies
- 🏦 Address Balance: Check balance of individual cryptocurrency addresses
- 📊 Wallet Management: Manage and calculate total value of multiple addresses
- 🔄 Smart Caching: Built-in caching with configurable TTL (5-minute default)
- 🌐 Multiple APIs: Uses BlockCypher and Blockchair APIs with automatic fallback
- 📝 Verbose Mode: Detailed logging for debugging and monitoring
- 🔒 Error Handling: Comprehensive error handling with descriptive messages
🚀 Installation
From PyPI
pip install coinwagon
From Source
git clone https://github.com/randyungaro/coinwagon.git
cd coinwagon
pip install maturin
maturin develop
📖 Quick Start
import coinwagon
# Get Bitcoin price in USD
price = coinwagon.run_command("current-price", ["bitcoin", "usd"])
print(price) # Output: "67234.50 USD"
# Check Bitcoin address balance
balance = coinwagon.run_command("address-balance", ["bitcoin", "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"])
print(balance) # Output: "68.91234567 BITCOIN"
# Check wallet balance from file
result = coinwagon.run_command("wallet-balance", ["my_wallet.txt", "usd"])
print(result)
# Output:
# BITCOIN: 1.50000000 BITCOIN = 100851.75 USD
# BITCOIN: 0.25000000 BITCOIN = 16808.63 USD
# Total: 117660.38 USD
🛠️ Usage
1. Get Current Cryptocurrency Price
import coinwagon
# Basic usage
price = coinwagon.run_command("current-price", ["bitcoin", "usd"])
print(f"Bitcoin price: {price}")
# With verbose output
price = coinwagon.run_command("current-price", ["bitcoin", "usd", "--verbose"])
# Different currencies
eur_price = coinwagon.run_command("current-price", ["bitcoin", "eur"])
jpy_price = coinwagon.run_command("current-price", ["ethereum", "jpy"])
2. Check Address Balance
import coinwagon
# Check Bitcoin address
btc_address = "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"
balance = coinwagon.run_command("address-balance", ["bitcoin", btc_address])
print(f"Balance: {balance}")
# With verbose output for debugging
balance = coinwagon.run_command("address-balance", ["bitcoin", btc_address, "--verbose"])
3. Wallet Balance Management
Create a wallet file (my_wallet.txt):
# My cryptocurrency addresses
bitcoin,1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa
bitcoin,1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2
bitcoin,3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy
Check total wallet value:
import coinwagon
# Get total wallet value in USD
result = coinwagon.run_command("wallet-balance", ["my_wallet.txt", "usd"])
print(result)
# With verbose output
result = coinwagon.run_command("wallet-balance", ["my_wallet.txt", "usd", "--verbose"])
📋 Command Reference
current-price
Get real-time cryptocurrency prices.
Usage: coinwagon.run_command("current-price", [crypto, fiat, "--verbose"])
Parameters:
crypto: Cryptocurrency symbol (e.g., "bitcoin", "ethereum")fiat: Fiat currency symbol (e.g., "usd", "eur", "jpy")--verbose: Optional flag for detailed output
address-balance
Check balance of a specific cryptocurrency address.
Usage: coinwagon.run_command("address-balance", [crypto, address, "--verbose"])
Parameters:
crypto: Cryptocurrency symbol (e.g., "bitcoin")address: Wallet address to check--verbose: Optional flag for detailed output
wallet-balance
Calculate total value of multiple addresses from a file.
Usage: coinwagon.run_command("wallet-balance", [wallet_file, fiat, "--verbose"])
Parameters:
wallet_file: Path to wallet file (format:crypto,addressper line)fiat: Fiat currency for total calculation--verbose: Optional flag for detailed output
📁 Wallet File Format
Create a text file with one address per line in the format crypto,address:
# Comments start with #
bitcoin,1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa
bitcoin,1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2
ethereum,0x742d35Cc6634C0532925a3b8D4Fddfac9e2C4cb7
# Empty lines are ignored
bitcoin,3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy
🔧 Advanced Usage
Error Handling
import coinwagon
try:
balance = coinwagon.run_command("address-balance", ["bitcoin", "invalid_address"])
print(balance)
except ValueError as e:
print(f"Invalid arguments: {e}")
except RuntimeError as e:
print(f"Runtime error: {e}")
Batch Operations
import coinwagon
addresses = [
"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",
"1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2",
"3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy"
]
for addr in addresses:
try:
balance = coinwagon.run_command("address-balance", ["bitcoin", addr])
print(f"{addr}: {balance}")
except Exception as e:
print(f"Error checking {addr}: {e}")
🔍 Supported Cryptocurrencies
- Bitcoin (
bitcoin) - Ethereum (
ethereum) - Litecoin (
litecoin) - And many more supported by CoinGecko API
For the complete list, check the CoinGecko API documentation.
⚡ Performance
- Caching: Automatic caching with 5-minute TTL reduces API calls
- Async Operations: Built on Tokio for non-blocking I/O
- Rust Performance: Core operations written in Rust for maximum speed
- Multiple APIs: Automatic fallback ensures reliability
🐛 Troubleshooting
Common Issues
-
API Rate Limits: If you encounter rate limit errors, the built-in caching will help reduce API calls.
-
Invalid Address Format: Make sure cryptocurrency addresses are in the correct format for the specific blockchain.
-
Network Issues: The package will retry failed requests and use fallback APIs when possible.
Debug Mode
Use the --verbose flag to see detailed information about API calls:
result = coinwagon.run_command("address-balance", ["bitcoin", "address", "--verbose"])
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙋♂️ Support
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file coinwagon-0.1.0.tar.gz.
File metadata
- Download URL: coinwagon-0.1.0.tar.gz
- Upload date:
- Size: 17.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed54597fd620735bb0d5aef66aa87e51807ce605320baa741eea575e059342ec
|
|
| MD5 |
7d847547dd737ceefb367c691e84b740
|
|
| BLAKE2b-256 |
e4b8e9dea65c148d267d090f894963b77378de663182af8af0d68a1f87b52f11
|
File details
Details for the file coinwagon-0.1.0-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: coinwagon-0.1.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5bf2d88243d0384d743579bd5218af6c5cc5d6e9b91bd1276dc5c6856b3b2654
|
|
| MD5 |
37d1f2a4089b76a51eb6a96298551a5c
|
|
| BLAKE2b-256 |
581b438a3bdc11bf9991706d096c8da139f8cdd4949019b5b5b1937d6c6c568c
|