Some checks failed
Blockchain Synchronization Verification / sync-verification (push) Failing after 3s
CLI Tests / test-cli (push) Failing after 3s
Cross-Chain Functionality Tests / test-cross-chain-sync (push) Successful in 2s
Cross-Chain Functionality Tests / test-cross-chain-transactions (push) Successful in 3s
Cross-Chain Functionality Tests / test-cross-chain-bridge (push) Has been skipped
Cross-Chain Functionality Tests / test-multi-chain-consensus (push) Successful in 2s
Cross-Chain Functionality Tests / aggregate-results (push) Has been skipped
Deploy to Testnet / deploy-testnet (push) Successful in 1m12s
Documentation Validation / validate-docs (push) Failing after 8s
Documentation Validation / validate-policies-strict (push) Successful in 3s
Integration Tests / test-service-integration (push) Successful in 2m6s
Multi-Chain Island Architecture Tests / test-multi-chain-island (push) Successful in 2s
Multi-Node Blockchain Health Monitoring / health-check (push) Failing after 4s
P2P Network Verification / p2p-verification (push) Successful in 4s
Package Tests / Python package - aitbc-agent-sdk (push) Successful in 32s
Package Tests / Python package - aitbc-core (push) Successful in 14s
Package Tests / Python package - aitbc-crypto (push) Successful in 12s
Package Tests / Python package - aitbc-sdk (push) Successful in 9s
Package Tests / JavaScript package - aitbc-sdk-js (push) Successful in 8s
Package Tests / JavaScript package - aitbc-token (push) Successful in 17s
Python Tests / test-python (push) Successful in 15s
Security Scanning / security-scan (push) Successful in 27s
Node Failover Simulation / failover-test (push) Successful in 7s
Multi-Node Stress Testing / stress-test (push) Successful in 6s
Cross-Node Transaction Testing / transaction-test (push) Successful in 4s
- Add SQLCipher encryption for ait-mainnet database with configurable flag - Add db_encryption_enabled and db_encryption_key_path config settings - Implement encryption key loading and PRAGMA key setup via connection events - Add shutdown_db function for proper database cleanup - Export middleware classes in aitbc/__init__.py - Fix import path in sync.py for settings - Remove duplicate agent documentation from docs
5.0 KiB
5.0 KiB
User Management System for AITBC Trade Exchange
Overview
The AITBC Trade Exchange now includes a complete user management system that allows individual users to have their own wallets, balances, and transaction history. Each user is identified by their wallet address and has a unique session for secure operations.
Features Implemented
1. User Registration & Login
- Wallet-based Authentication: Users connect with their wallet address
- Auto-registration: New wallets automatically create a user account
- Session Management: Secure token-based sessions (24-hour expiry)
- User Profiles: Each user has a unique ID, email, and username
2. Wallet Management
- Individual Wallets: Each user gets their own AITBC wallet
- Balance Tracking: Real-time balance updates
- Address Generation: Unique wallet addresses for each user
3. Transaction History
- Personal Transactions: Each user sees only their own transactions
- Transaction Types: Buy, sell, deposit, withdrawal tracking
- Status Updates: Real-time transaction status
API Endpoints
User Authentication
POST /api/users/login
{
"wallet_address": "aitbc1abc123..."
}
Response:
{
"user_id": "uuid",
"email": "wallet@aitbc.local",
"username": "user_abc123",
"created_at": "2025-12-28T...",
"session_token": "sha256_token"
}
User Profile
GET /api/users/me
Headers: X-Session-Token: <token>
User Balance
GET /api/users/{user_id}/balance
Headers: X-Session-Token: <token>
Response:
{
"user_id": "uuid",
"address": "aitbc_uuid123",
"balance": 1000.0,
"updated_at": "2025-12-28T..."
}
Transaction History
GET /api/users/{user_id}/transactions
Headers: X-Session-Token: <token>
Logout
POST /api/users/logout
Headers: X-Session-Token: <token>
Frontend Implementation
1. Connect Wallet Flow
- User clicks "Connect Wallet"
- Generates a demo wallet address
- Calls
/api/users/loginwith wallet address - Receives session token and user data
- Updates UI with user info
2. UI Components
- Wallet Section: Shows address, username, balance
- Connect Button: Visible when not logged in
- Logout Button: Clears session and resets UI
- Balance Display: Real-time AITBC balance
3. Session Management
- Session token stored in JavaScript variable
- Token sent with all API requests
- Automatic logout on token expiry
- Manual logout option
Database Schema
Users Table
id: UUID (Primary Key)email: Unique stringusername: Unique stringstatus: active/inactive/suspendedcreated_at: Timestamplast_login: Timestamp
Wallets Table
id: Integer (Primary Key)user_id: UUID (Foreign Key)address: Unique stringbalance: Floatcreated_at: Timestampupdated_at: Timestamp
Transactions Table
id: UUID (Primary Key)user_id: UUID (Foreign Key)wallet_id: Integer (Foreign Key)type: deposit/withdrawal/purchase/etc.status: pending/completed/failedamount: Floatfee: Floatcreated_at: Timestampconfirmed_at: Timestamp
Security Features
1. Session Security
- SHA-256 hashed tokens
- 24-hour automatic expiry
- Server-side session validation
- Secure token invalidation on logout
2. API Security
- Session token required for protected endpoints
- User isolation (users can only access their own data)
- Input validation and sanitization
3. Future Enhancements
- JWT tokens for better scalability
- Multi-factor authentication
- Biometric wallet support
- Hardware wallet integration
How It Works
1. First Time User
- User connects wallet
- System creates new user account
- Wallet is created and linked to user
- Session token issued
- User can start trading
2. Returning User
- User connects wallet
- System finds existing user
- Updates last login
- Issues new session token
- User sees their balance and history
3. Trading
- User initiates purchase
- Payment request created with user_id
- Bitcoin payment processed
- AITBC credited to user's wallet
- Transaction recorded
Testing
Test Users
Each wallet connection creates a unique user:
- Address:
aitbc1wallet_[random]x... - Email:
wallet@aitbc.local - Username:
user_[last_8_chars]
Demo Mode
- No real registration required
- Instant wallet creation
- Testnet Bitcoin support
- Simulated balance updates
Next Steps
1. Enhanced Features
- Email verification
- Password recovery
- 2FA authentication
- Profile customization
2. Advanced Trading
- Limit orders
- Stop-loss
- Trading history analytics
- Portfolio tracking
3. Integration
- MetaMask support
- WalletConnect protocol
- Hardware wallets (Ledger, Trezor)
- Mobile wallet apps
Support
For issues or questions:
- Check the logs:
journalctl -u aitbc-coordinator -f - API endpoints:
https://aitbc.bubuit.net/api/docs - Trade Exchange:
https://aitbc.bubuit.net/Exchange