feat: implement simple AITBC wallet CLI tool
All checks were successful
Documentation Validation / validate-docs (push) Successful in 11s
CLI Tests / test-cli (push) Successful in 1m20s
Security Scanning / security-scan (push) Successful in 1m3s

- Add simple_wallet.py with create, send, list commands
- Compatible with existing keystore structure (/var/lib/aitbc/keystore)
- Uses requests library (available in central venv)
- Supports password file authentication
- Provides JSON and table output formats
- Replaces complex CLI fallbacks with working implementation
- Update workflow to use simple wallet CLI
- Cross-node deployment to both aitbc1 and aitbc

This provides a fully functional CLI tool for wallet operations
as requested, eliminating the need for Python script fallbacks.
This commit is contained in:
aitbc1
2026-03-29 16:03:56 +02:00
parent e7f55740ee
commit e9d69f24f0
2 changed files with 272 additions and 63 deletions

View File

@@ -259,25 +259,15 @@ fi
### 5. Create Wallet on aitbc
```bash
# On aitbc, create a new wallet using AITBC CLI tool
# Note: CLI tool may not be fully implemented - fallback to Python script if needed
if ssh aitbc "source /opt/aitbc/venv/bin/activate && aitbc wallet create --name aitbc-user --password-file /var/lib/aitbc/keystore/.password" 2>/dev/null; then
echo "Wallet created using CLI tool"
else
echo "CLI not fully implemented, using Python script fallback..."
ssh aitbc 'cd /opt/aitbc/apps/blockchain-node && /opt/aitbc/venv/bin/python scripts/keystore.py --name aitbc-user --create --password $(cat /var/lib/aitbc/keystore/.password)'
fi
# On aitbc, create a new wallet using AITBC simple wallet CLI
ssh aitbc 'python /opt/aitbc/cli/simple_wallet.py create --name aitbc-user --password-file /var/lib/aitbc/keystore/.password'
# Note the new wallet address
WALLET_ADDR=$(ssh aitbc 'cat /var/lib/aitbc/keystore/aitbc-user.json | jq -r .address')
echo "New wallet: $WALLET_ADDR"
# Verify wallet was created successfully
if ssh aitbc "source /opt/aitbc/venv/bin/activate && aitbc wallet list --format json" 2>/dev/null; then
ssh aitbc "source /opt/aitbc/venv/bin/activate && aitbc wallet list --format json | jq '.[] | select(.name == \"aitbc-user\")'"
else
echo "Wallet created (CLI list not available)"
fi
ssh aitbc "python /opt/aitbc/cli/simple_wallet.py list --format json | jq '.[] | select(.name == \"aitbc-user\")'"
```
**🔑 Wallet Attachment & Coin Access:**
@@ -297,57 +287,17 @@ The newly created wallet on aitbc will:
### 6. Send 1000 AIT from Genesis to aitbc Wallet
```bash
# On aitbc1, send 1000 AIT using AITBC CLI tool
# Note: CLI tool may not be fully implemented - fallback to manual method if needed
source /opt/aitbc/venv/bin/activate
if aitbc wallet send --from aitbc1genesis --to $WALLET_ADDR --amount 1000 --password-file /var/lib/aitbc/keystore/.password --fee 10 2>/dev/null; then
echo "Transaction sent using CLI tool"
# Get transaction hash for verification
TX_HASH=$(aitbc wallet transactions --from aitbc1genesis --limit 1 --format json 2>/dev/null | jq -r '.[0].hash' || echo "Transaction hash retrieval failed")
else
echo "CLI not fully implemented, using manual transaction method..."
# Manual transaction method (fallback)
GENESIS_KEY=$(/opt/aitbc/venv/bin/python -c "
import json, sys
from cryptography.hazmat.primitives.asymmetric import ed25519
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
from cryptography.hazmat.primitives import hashes
with open('/var/lib/aitbc/keystore/aitbc1genesis.json') as f:
ks = json.load(f)
# Decrypt private key
crypto = ks['crypto']
salt = bytes.fromhex(crypto['kdfparams']['salt'])
kdf = PBKDF2HMAC(hashes.SHA256(), 32, salt, crypto['kdfparams']['c'])
key = kdf.derive('aitbc123'.encode())
aesgcm = AESGCM(key)
nonce = bytes.fromhex(crypto['cipherparams']['nonce'])
priv = aesgcm.decrypt(nonce, bytes.fromhex(crypto['ciphertext']), None)
print(priv.hex())
")
# Create and submit transaction
TX_JSON=$(cat << EOF
{
"sender": "$(cat /var/lib/aitbc/keystore/aitbc1genesis.json | jq -r .address)",
"recipient": "$WALLET_ADDR",
"value": 1000,
"fee": 10,
"nonce": 0,
"type": "transfer",
"payload": {}
}
EOF
)
curl -X POST http://localhost:8006/sendTx \
-H "Content-Type: application/json" \
-d "$TX_JSON"
fi
# On aitbc1, send 1000 AIT using AITBC simple wallet CLI
python /opt/aitbc/cli/simple_wallet.py send \
--from aitbc1genesis \
--to $WALLET_ADDR \
--amount 1000 \
--fee 10 \
--password-file /var/lib/aitbc/keystore/.password \
--rpc-url http://localhost:8006
# Get transaction hash for verification (simplified - using RPC to check latest transaction)
TX_HASH=$(curl -s http://localhost:8006/rpc/transactions --limit 1 | jq -r '.transactions[0].hash' 2>/dev/null || echo "Transaction hash retrieval failed")
echo "Transaction hash: $TX_HASH"
# Wait for transaction to be mined