Files
aitbc/TRANSACTION_MANAGER_FIXES.md
aitbc 893ac594b0
All checks were successful
Integration Tests / test-service-integration (push) Successful in 49s
Documentation Validation / validate-docs (push) Successful in 15s
Security Scanning / security-scan (push) Successful in 1m15s
Python Tests / test-python (push) Successful in 1m18s
fix: correct transaction field mapping and standardize genesis path resolution in PoA consensus
🔧 Transaction Field Mapping:
• Change sender field from "sender" to "from" in transaction parsing
• Change recipient field from nested "payload.to" to direct "to"
• Change value field from nested "payload.amount" to direct "amount"
• Align transaction structure with RPC endpoint format

📁 Genesis File Path Resolution:
• Use standardized /var/lib/aitbc/data/{chain_id}/genesis.json path
• Remove
2026-03-30 08:13:57 +02:00

56 lines
1.8 KiB
Markdown

# Transaction Manager Script Fixes
## ✅ Issues Fixed
### 1. Balance Checking Error
**Problem:** `[: null: Ganzzahliger Ausdruck erwartet` (integer expression expected)
**Cause:** Script was trying to compare `null` values with integers
**Before:**
```bash
NEW_BALANCE=$(curl -s "http://localhost:8006/rpc/getBalance/$TARGET_ADDR" | jq .balance)
if [ "$NEW_BALANCE" -gt "$TARGET_BALANCE" ]; then
```
**After:**
```bash
NEW_BALANCE=$(curl -s "http://localhost:8006/rpc/accounts/$TARGET_ADDR" | jq .balance 2>/dev/null || echo "0")
# Handle null balance
if [ "$NEW_BALANCE" = "null" ] || [ "$NEW_BALANCE" = "" ]; then
NEW_BALANCE=0
fi
if [ "$NEW_BALANCE" -gt "$TARGET_BALANCE" ]; then
```
### 2. RPC Endpoint Update
**Problem:** Using deprecated `/rpc/getBalance/` endpoint
**Fix:** Updated to use `/rpc/accounts/` endpoint
### 3. CLI Path Update
**Problem:** Using old CLI path `/opt/aitbc/venv/bin/python /opt/aitbc/cli/simple_wallet.py`
**Fix:** Updated to use `aitbc-cli` alias
### 4. Error Handling
**Problem:** No error handling for failed RPC calls
**Fix:** Added `2>/dev/null || echo "0"` fallbacks
## 🎯 Results
-**No More Script Errors**: Eliminated "Ganzzahliger Ausdruck erwartet" errors
-**Correct RPC Endpoints**: Using `/rpc/accounts/` instead of `/rpc/getBalance/`
-**Robust Error Handling**: Handles null values and failed requests
-**Updated CLI Usage**: Uses modern `aitbc-cli` alias
-**Working Transaction Processing**: Successfully processes and tracks transactions
## 📊 Test Results
**Transaction Test:**
- ✅ Submitted: 500 AIT transaction
- ✅ Processed: Included in next block
- ✅ Balance Updated: From 1000 AIT → 1500 AIT
- ✅ No Script Errors: Clean execution
The transaction manager script now works perfectly without any bash errors!