Fix minor issues and add wallet funding documentation
Some checks failed
Cross-Node Transaction Testing / transaction-test (push) Has been cancelled
Deploy to Testnet / deploy-testnet (push) Has been cancelled
Multi-Node Stress Testing / stress-test (push) Has been cancelled
Node Failover Simulation / failover-test (push) Has been cancelled
Documentation Validation / validate-docs (push) Has been cancelled
Documentation Validation / validate-policies-strict (push) Has been cancelled

Changes:
- Fix certificate viewing display issue in master_training_launcher.sh
  - Use array to store certificate files for reliable iteration
  - Add error handling for read command
  - Ensure CERT_DIR exists before checking for certificates
  - Fix certificate selection using array index instead of head/tail

- Add wallet funding script (scripts/training/fund_wallet.sh)
  - Fund wallets from genesis using genesis password
  - Reads password from /var/lib/aitbc/keystore/.genesis_password
  - Verifies genesis balance before funding
  - Shows transaction hash and wallet balance after funding

- Add wallet funding documentation (docs/agent-training/WALLET_FUNDING.md)
  - Genesis wallet details and password location
  - Quick funding script usage
  - Manual funding with AITBC CLI
  - Faucet service information
  - Common training wallets
  - Troubleshooting guide
  - Security notes
This commit is contained in:
aitbc
2026-05-07 14:13:57 +02:00
parent 4afa754499
commit 60a5abd2fd
3 changed files with 273 additions and 5 deletions

View File

@@ -0,0 +1,153 @@
# Wallet Funding Guide
This guide explains how to fund wallets for AITBC training and testing.
## Genesis Wallet
The genesis wallet is pre-funded with 997,999,290 AIT and serves as the primary funding source for training wallets.
**Genesis Wallet Details:**
- Name: `genesis`
- Address: `ait175406af70445617b0cd7eb8ff384d81b15c26b45`
- Balance: 997,999,290 AIT
- Password file: `/var/lib/aitbc/keystore/.genesis_password`
## Quick Funding Script
Use the provided script to fund wallets from genesis:
```bash
./scripts/training/fund_wallet.sh <wallet_name> [amount]
```
**Examples:**
```bash
# Fund hermes-trainee with default amount (1000 AIT)
./scripts/training/fund_wallet.sh hermes-trainee
# Fund a specific wallet with custom amount
./scripts/training/fund_wallet.sh training-wallet 5000
```
## Manual Funding
To manually fund a wallet using the AITBC CLI:
```bash
# Read genesis password
GENESIS_PASSWORD=$(cat /var/lib/aitbc/keystore/.genesis_password)
# Send funds from genesis to target wallet
./aitbc-cli wallet send genesis <target_wallet> <amount> "$GENESIS_PASSWORD"
```
**Example:**
```bash
./aitbc-cli wallet send genesis hermes-trainee 100 "EzE4d8cLJo20E9FlquSXq7hqy-e6p4M7Q1ZkM5eLpmY"
```
## Checking Wallet Balances
```bash
# Check specific wallet balance
./aitbc-cli wallet balance <wallet_name>
# List all wallets
./aitbc-cli wallet list
```
## Faucet Service
The AITBC system includes a faucet service for automated wallet funding.
### Faucet Setup (Deprecated)
The bash-based faucet setup script is deprecated. Use the Python-based setup system instead:
```bash
python3 -m aitbc.training_setup.cli setup
```
This will:
1. Check prerequisites
2. Setup genesis wallet as funding source
3. Fund training wallets
4. Configure messaging authentication
### Faucet API
If the faucet service is running, you can fund wallets via HTTP API:
```bash
curl -X POST http://localhost:8080/fund \
-H "Content-Type: application/json" \
-d '{"address": "ait1..."}'
```
**Default faucet configuration:**
- Port: 8080
- Funding amount: 1000 AIT per request
- Rate limit: 10 requests per hour per IP
## Common Training Wallets
**Default training wallets:**
- `hermes-trainee` - Primary training wallet
- `training-wallet` - General training operations
- `exam-wallet` - Exam and testing
- `faucet` - Faucet service wallet (if configured)
**Test wallets:**
- `test-agent` - Agent testing
- `scenario_user` - Scenario testing
- `openclaw-trainee` - OpenClaw training
## Troubleshooting
### Genesis Password Not Found
If the genesis password file is missing or empty:
```bash
# Check if file exists
ls -la /var/lib/aitbc/keystore/.genesis_password
# If missing, the genesis wallet may need to be reconfigured
# Contact your system administrator
```
### Insufficient Genesis Balance
If the genesis wallet has insufficient funds:
```bash
# Check genesis balance
./aitbc-cli wallet balance genesis
# If balance is low, you may need to mine new blocks
# or regenerate the genesis block
```
### Transaction Failed
If funding transactions fail:
1. Verify the target wallet exists
2. Check blockchain node status
3. Ensure services are running:
```bash
systemctl status aitbc-blockchain-node.service
```
## Security Notes
- The genesis password is stored in `/var/lib/aitbc/keystore/.genesis_password` with 0600 permissions
- Never share the genesis password
- Backup the genesis wallet file and password
- For production, consider using a separate faucet wallet instead of genesis
## Related Documentation
- [Training Environment Setup](ENVIRONMENT_SETUP.md)
- [Genesis Generation](/opt/aitbc/docs/infrastructure/genesis_generation.md)
- [Training Playground](/opt/aitbc/scripts/training/README.md)

104
scripts/training/fund_wallet.sh Executable file
View File

@@ -0,0 +1,104 @@
#!/bin/bash
# AITBC Wallet Funding Script
# Funds a wallet from the genesis wallet using the genesis password
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
AITBC_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)"
CLI_PATH="$AITBC_DIR/aitbc-cli"
GENESIS_PASSWORD_FILE="/var/lib/aitbc/keystore/.genesis_password"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
print_status() {
echo -e "${BLUE}[INFO]${NC} $1"
}
print_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
usage() {
echo "Usage: $0 <wallet_name> [amount]"
echo ""
echo "Arguments:"
echo " wallet_name Name of the wallet to fund"
echo " amount Amount of AIT to send (default: 1000)"
echo ""
echo "Example:"
echo " $0 hermes-trainee 1000"
echo ""
echo "Note: The genesis password is read from $GENESIS_PASSWORD_FILE"
exit 1
}
if [ $# -lt 1 ]; then
usage
fi
WALLET_NAME="$1"
AMOUNT="${2:-1000}"
print_status "Funding wallet: $WALLET_NAME"
print_status "Amount: $AMOUNT AIT"
# Check if genesis password file exists
if [ ! -f "$GENESIS_PASSWORD_FILE" ]; then
print_error "Genesis password file not found: $GENESIS_PASSWORD_FILE"
print_error "Please ensure the genesis wallet is properly configured"
exit 1
fi
# Read genesis password
GENESIS_PASSWORD=$(cat "$GENESIS_PASSWORD_FILE")
if [ -z "$GENESIS_PASSWORD" ]; then
print_error "Genesis password file is empty"
exit 1
fi
print_status "Genesis password loaded"
# Check if CLI exists
if [ ! -f "$CLI_PATH" ]; then
print_error "AITBC CLI not found: $CLI_PATH"
exit 1
fi
# Check genesis wallet balance
print_status "Checking genesis wallet balance..."
GENESIS_BALANCE=$("$CLI_PATH" wallet balance genesis 2>&1 || echo "0")
print_status "Genesis wallet balance: $GENESIS_BALANCE"
# Fund the wallet
print_status "Sending $AMOUNT AIT from genesis to $WALLET_NAME..."
cd "$AITBC_DIR"
RESULT=$("$CLI_PATH" wallet send genesis "$WALLET_NAME" "$AMOUNT" "$GENESIS_PASSWORD" 2>&1)
if [ $? -eq 0 ]; then
print_success "Transaction sent successfully"
echo "Transaction hash: $RESULT"
# Verify balance
print_status "Verifying wallet balance..."
WALLET_BALANCE=$("$CLI_PATH" wallet balance "$WALLET_NAME" 2>&1 || echo "0")
print_success "Wallet $WALLET_NAME balance: $WALLET_BALANCE"
else
print_error "Funding failed: $RESULT"
exit 1
fi
print_success "Wallet funding completed"

View File

@@ -357,7 +357,18 @@ display_badge() {
view_certificates() { view_certificates() {
print_header "Stage Completion Certificates" print_header "Stage Completion Certificates"
if [ ! -d "$CERT_DIR" ] || [ -z "$(ls -A $CERT_DIR)" ]; then # Ensure directory exists
mkdir -p "$CERT_DIR"
# Check for certificates
local cert_files=()
for cert_file in "$CERT_DIR"/stage*_certificate.json; do
if [ -f "$cert_file" ]; then
cert_files+=("$cert_file")
fi
done
if [ ${#cert_files[@]} -eq 0 ]; then
print_warning "No certificates found yet" print_warning "No certificates found yet"
echo "Complete stages to earn certificates" echo "Complete stages to earn certificates"
return 0 return 0
@@ -367,7 +378,7 @@ view_certificates() {
echo echo
local cert_count=0 local cert_count=0
for cert_file in "$CERT_DIR"/stage*_certificate.json; do for cert_file in "${cert_files[@]}"; do
if [ -f "$cert_file" ]; then if [ -f "$cert_file" ]; then
((cert_count++)) ((cert_count++))
local stage_num=$(echo "$cert_file" | grep -o 'stage[0-9]' | grep -o '[0-9]') local stage_num=$(echo "$cert_file" | grep -o 'stage[0-9]' | grep -o '[0-9]')
@@ -385,10 +396,10 @@ view_certificates() {
echo echo
echo -n "View certificate details? [1-$cert_count/N]: " echo -n "View certificate details? [1-$cert_count/N]: "
read -r view_choice read -r view_choice || view_choice="N"
if [[ "$view_choice" =~ ^[0-9]+$ ]] && [ "$view_choice" -le "$cert_count" ]; then if [[ "$view_choice" =~ ^[0-9]+$ ]] && [ "$view_choice" -ge 1 ] && [ "$view_choice" -le "$cert_count" ]; then
local cert_file=$(ls "$CERT_DIR"/stage*_certificate.json | head -"$view_choice" | tail -1) local cert_file="${cert_files[$((view_choice-1))]}"
if [ -f "$cert_file" ]; then if [ -f "$cert_file" ]; then
echo echo
echo -e "${BOLD}Certificate Details:${NC}" echo -e "${BOLD}Certificate Details:${NC}"