1 unstable release
0.1.1 | Feb 28, 2025 |
---|
#394 in Magic Beans
140 downloads per month
32KB
407 lines
Mockchain Wallet CLI
A command-line interface for interacting with a mockchain network using a modular Rust architecture.
Table of Contents
- Features
- Installation
- Quick Start
- Usage
- Architecture
- Project Documentation
- Development
- Security
- Contributing
- License
Features
- ✅ Create and manage multiple wallets
- ✅ Check wallet balances
- ✅ Send transactions between wallets
- ✅ Request funds from mockchain faucet
- ✅ Secure local key storage
- ✅ Modular, maintainable codebase
- ✅ Comprehensive error handling
Installation
Prerequisites
- Rust and Cargo (1.54.0+)
- Running mockchain service at
http://[::1]:50051
From Source
# Clone repository
git clone https://github.com/0xsouravm/mockchain-wallet-rs.git
cd mockchain-wallet-rs
# Build release version
cargo build --release
# Run the executable
./target/release/mockallet
From Crates.io
# Install Directly
cargo install mockallet
Quick Start
# Create a new wallet
./mockallet new alice
# Request funds from faucet
./mockallet faucet alice
# Check balance
./mockallet balance alice
# Create another wallet
./mockallet new bob
# Send transaction
./mockallet send alice bob 100
Usage
Create a Wallet
mockallet new <wallet_name>
Creates a new wallet with a randomly generated key pair.
List Wallets
mockallet list
Displays all wallets in your local storage.
Check Balance
mockallet balance <wallet_name>
Retrieves the current balance for a wallet.
Send Transaction
mockallet send <from_wallet> <to_wallet> <amount>
Sends funds from one wallet to another. The recipient can be specified either by wallet name or by public key address.
Request from Faucet
mockallet faucet <wallet_name>
Requests funds from the mockchain's faucet service.
Architecture
This application follows a modular architecture for improved maintainability:
src/
├── main.rs # Entry point with error handling
├── commands.rs # Command definitions using StructOpt
├── models.rs # Data structures
├── wallet.rs # Mockchain interactions
├── storage.rs # Wallet storage management
├── errors.rs # Error handling system
└── proto.rs # gRPC protocol initialisation
Key architectural decisions:
- Separation of concerns between data, storage, and network operations
- Custom error types with context-rich error messages
- Domain-driven design with clear boundaries between modules
- gRPC communication with the mockchain service
Project Documentation
Generate and view the API documentation:
cargo doc --open
Development
Building
# Development build
cargo build
# Release build
cargo build --release
Adding New Features
To add a new command:
- Add a new variant to the
Command
enum incommands.rs
- Add the command handler in the
run()
function inmain.rs
- Implement the necessary functionality in appropriate modules
Security
- Private keys are stored locally in
.wallets/wallets.json
- Keys use secp256k1 cryptography (same as Bitcoin)
- Transactions are signed with ECDSA signatures
- Private keys never leave your local machine
⚠️ Warning: Secure access to the .wallets
directory on your machine
Contributing
Contributions are welcome! Here are some areas where help would be appreciated:
- Improving the security with which the wallet keypairs are stored
- Including BIP39 mnemonics for wallet creation and recovery
- Adding password confirmation before sending transactions
Please feel free to submit a Pull Request.
Please follow the Rust code style guidelines and include appropriate tests.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Dependencies
~14–21MB
~253K SLoC