rustywallet-address
Cryptocurrency address generation and validation for Bitcoin and Ethereum.
Features
- Bitcoin Legacy (P2PKH) - Addresses starting with
1(mainnet) orm/n(testnet) - Bitcoin SegWit (P2WPKH) - Addresses starting with
bc1q(mainnet) ortb1q(testnet) - Bitcoin Taproot (P2TR) - Addresses starting with
bc1p(mainnet) ortb1p(testnet) - Ethereum - Addresses starting with
0xwith EIP-55 checksum support
Installation
[]
= "0.1"
= "0.1"
Quick Start
use PrivateKey;
use *;
// Generate a random private key
let private_key = random;
let public_key = private_key.public_key;
// Bitcoin Legacy (P2PKH)
let p2pkh = from_public_key?;
println!; // 1...
// Bitcoin SegWit (P2WPKH)
let p2wpkh = from_public_key?;
println!; // bc1q...
// Bitcoin Taproot (P2TR)
let p2tr = from_public_key?;
println!; // bc1p...
// Ethereum
let eth = from_public_key?;
println!; // 0x...
Address Validation
use *;
// Validate any address with auto-detection
validate?;
// Validate specific types
validate?;
// Validate Ethereum checksum (EIP-55)
validate_checksum?;
Address Type Detection
use *;
let addr = from_str?;
assert!;
let addr = from_str?;
assert!;
Supported Networks
| Address Type | Mainnet Prefix | Testnet Prefix | Encoding |
|---|---|---|---|
| P2PKH | 1 |
m, n |
Base58Check |
| P2WPKH | bc1q |
tb1q |
Bech32 |
| P2TR | bc1p |
tb1p |
Bech32m |
| Ethereum | 0x |
0x |
Hex + EIP-55 |
License
MIT