diff --git a/docs/README.md b/docs/README.md index b79ed26..73bf3ab 100644 --- a/docs/README.md +++ b/docs/README.md @@ -8,6 +8,7 @@ |----------|-------------| | [Protocol Specification](./PROTOCOL.md) | Full RIP-200 consensus protocol | | [API Reference](./API.md) | All endpoints with curl examples | +| [Wallet User Guide](./WALLET_GUIDE.md) | Create and manage RTC wallets | | [Glossary](./GLOSSARY.md) | Terms and definitions | | [Tokenomics](./tokenomics_v1.md) | RTC supply and distribution | diff --git a/docs/WALLET_GUIDE.md b/docs/WALLET_GUIDE.md new file mode 100644 index 0000000..8cbf353 --- /dev/null +++ b/docs/WALLET_GUIDE.md @@ -0,0 +1,83 @@ +# RustChain Wallet User Guide + +This guide explains how to create, manage, and use RustChain (RTC) wallets. RustChain supports multiple wallet formats depending on your needs. + +## 1. Miner ID Wallets (Current Standard) + +The majority of active miners and GUI wallets currently use a **32-character Hex ID**. This ID is derived from a SHA256 hash and serves as both your identity on the network and your wallet address. + +### Creating a Miner ID +1. Run the RustChain miner for the first time. +2. The miner will generate a unique `miner_id` based on your hardware fingerprint. +3. This ID is saved locally (usually in a `.miner_id` file). + +### Checking Balance +You can check your balance via the web explorer or API: +```bash +curl -sk "https://50.28.86.131/wallet/balance?miner_id=YOUR_ID" +``` + +--- + +## 2. Compatibility CLI Wallet + +If you need a command-line tool to manage balances and send RTC without running a full miner, you can use the `rustchain_cli_wallet.py` tool (found in the `tools/` directory). + +### Setup +```bash +git clone https://github.com/Scottcjn/Rustchain.git +cd Rustchain/tools +pip install requests +``` + +### Usage + +**Create a new wallet:** +```bash +python3 rustchain_cli_wallet.py create +``` +*Note: This generates a random 32-char hex ID. Save this ID!* + +**Check balance:** +```bash +python3 rustchain_cli_wallet.py balance --miner-id YOUR_ID +``` + +**Send RTC:** +```bash +python3 rustchain_cli_wallet.py send --from-id YOUR_ID --to-id RECIPIENT_ID --amount 10.0 +``` + +--- + +## 3. Secure Wallets (Founder Edition) + +*Note: This format is currently being transitioned. The required `rustchain_crypto` module is pending release in the main repository.* + +The Secure Wallet format uses **Ed25519** keypairs and **BIP39** seed phrases (12-24 words). + +### Benefits +- Hierarchical Deterministic (HD) structure. +- Industry-standard security (similar to Solana/Polkadot). +- Supports offline signing. + +### Transition Status +Once `rustchain_crypto.py` is available, existing Miner ID wallets can be linked to Secure Wallets for enhanced protection. + +--- + +## 4. BoTTube Wallet Integration + +BoTTube (the AI video platform) uses RustChain for tipping and creator rewards. + +- **Rewards:** Uploading videos and reaching milestones earns RTC. +- **Tipping:** Viewers can tip creators directly in RTC. +- **Withdrawal:** You can link your BoTTube profile to your RustChain Miner ID to withdraw earnings. + +--- + +## 5. Security Best Practices + +1. **Protect your ID:** Your 32-char Hex ID is effectively your private key for current miners. Do not share it publicly unless you only want to receive funds. +2. **Hardware Binding:** Miner IDs are often bound to hardware fingerprints. If you move your wallet to a new machine, ensure you use the same ID to keep your balance. +3. **Pending Window:** All RTC transfers have a **24-hour pending window** for security and anti-fraud verification before they are finalized. diff --git a/tools/rustchain_cli_wallet.py b/tools/rustchain_cli_wallet.py new file mode 100644 index 0000000..612270e --- /dev/null +++ b/tools/rustchain_cli_wallet.py @@ -0,0 +1,105 @@ +#!/usr/bin/env python3 +""" +RustChain CLI Wallet (Compatibility Edition) +Supports the hex-ID format used by the current Linux Miner. +""" + +import requests +import json +import secrets +import sys +import argparse +from datetime import datetime +import urllib3 + +# Disable SSL warnings for self-signed certs +urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) + +NODE_URL = "https://50.28.86.131" +VERIFY_SSL = False + +def create_wallet(): + wallet_id = secrets.token_hex(16) + print(f"\n✨ New Wallet Created!") + print(f"ID: {wallet_id}") + print(f"āš ļø SAVE THIS ID! You will need it to access your RTC.") + return wallet_id + +def get_balance(wallet_id): + url = f"{NODE_URL}/wallet/balance?miner_id={wallet_id}" + try: + resp = requests.get(url, verify=VERIFY_SSL, timeout=10) + data = resp.json() + balance = data.get("amount_rtc", 0) + print(f"\nšŸ’° Balance: {balance:.8f} RTC") + return balance + except Exception as e: + print(f"āŒ Error fetching balance: {e}") + return None + +def send_rtc(from_wallet, to_wallet, amount): + url = f"{NODE_URL}/wallet/transfer" + payload = { + "from_miner": from_wallet, + "to_miner": to_wallet, + "amount_rtc": float(amount) + } + try: + resp = requests.post(url, json=payload, verify=VERIFY_SSL, timeout=10) + data = resp.json() + if data.get("ok"): + print(f"\nāœ… Success! Sent {amount} RTC to {to_wallet}") + print(f"New Balance: {data.get('sender_balance_rtc', 0):.8f} RTC") + else: + print(f"āŒ Failed: {data.get('error', 'Unknown error')}") + except Exception as e: + print(f"āŒ Error during transfer: {e}") + +def get_history(wallet_id): + url = f"{NODE_URL}/wallet/ledger?miner_id={wallet_id}" + try: + resp = requests.get(url, verify=VERIFY_SSL, timeout=10) + data = resp.json() + if "transactions" in data: + print(f"\nšŸ“œ Recent Transactions for {wallet_id[:10]}...") + print(f"{'Time':<20} | {'Type':<10} | {'Amount':<15} | {'Counterparty'}") + print("-" * 75) + for tx in data["transactions"][:10]: + tx_type = "Received" if tx.get("to") == wallet_id else "Sent" + amount = tx.get("amount_rtc", 0) + amount_str = f"{'+' if tx_type == 'Received' else '-'}{amount:.6f}" + counterparty = tx.get("from") if tx_type == "Received" else tx.get("to") + time_str = tx.get("timestamp", "")[:19].replace("T", " ") + print(f"{time_str:<20} | {tx_type:<10} | {amount_str:<15} | {counterparty}") + except Exception as e: + print(f"āŒ Error fetching history: {e}") + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="RustChain CLI Wallet") + subparsers = parser.add_subparsers(dest="command", help="Commands") + + subparsers.add_parser("create", help="Create a new wallet") + + balance_p = subparsers.add_parser("balance", help="Check wallet balance") + balance_p.add_argument("wallet_id", help="Your wallet hex ID") + + history_p = subparsers.add_parser("history", help="Show transaction history") + history_p.add_argument("wallet_id", help="Your wallet hex ID") + + send_p = subparsers.add_parser("send", help="Send RTC") + send_p.add_argument("from_id", help="Your wallet hex ID") + send_p.add_argument("to_id", help="Recipient wallet hex ID") + send_p.add_argument("amount", type=float, help="Amount to send") + + args = parser.parse_args() + + if args.command == "create": + create_wallet() + elif args.command == "balance": + get_balance(args.wallet_id) + elif args.command == "history": + get_history(args.wallet_id) + elif args.command == "send": + send_rtc(args.from_id, args.to_id, args.amount) + else: + parser.print_help()